How can I record mouse motions over the entire window?

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4

48 Replies - 1518 Views - Last Post: 20 June 2020 - 09:37 AM Rate Topic: -----

#31 nicephotog   User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 34
  • Joined: 06-June 20

Re: How can I record mouse motions over the entire window?

Posted 11 June 2020 - 12:24 AM

// all packs here are Java.awt ex
PointerInfo ptLoc = (PointerInfo) Java.awt.MouseInfo.getPointerInfo();
// Static call and static returned - cast removes static context
Point mousPt = ptLoc.getLocation();
int X = new Double(mousPt.getX()).intValue();
I'm using a phone so as best I could - look up the classes in the API docs.
Was This Post Helpful? 0
  • +
  • -

#32 NormR   User is offline

  • D.I.C Lover
  • member icon

Reputation: 832
  • View blog
  • Posts: 6,392
  • Joined: 25-December 13

Re: How can I record mouse motions over the entire window?

Posted 11 June 2020 - 04:56 AM

Thanks for the code that shows where the cursor is currently located. The OP's question was how to track the movement of the cursor. Do you have code that does that? Or would the OP need a special thread that repeatedly got the cursor position and pass some event when the cursor's position had changed?

This post has been edited by NormR: 11 June 2020 - 04:57 AM

Was This Post Helpful? 0
  • +
  • -

#33 nicephotog   User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 34
  • Joined: 06-June 20

Re: How can I record mouse motions over the entire window?

Posted 11 June 2020 - 07:17 AM

View PostNormR, on 11 June 2020 - 04:56 AM, said:

Thanks for the code that shows where the cursor is currently located. The OP's question was how to track the movement of the cursor. Do you have code that does that? Or would the OP need a special thread that repeatedly got the cursor position and pass some event when the cursor's position had changed?


// all packages here are Java.awt.
PointerInfo ptLoc = (PointerInfo) Java.awt.MouseInfo.getPointerInfo();
// Static call and static returned - cast removes static context
Point mousPt = ptLoc.getLocation();
int X = new Double(mousPt.getX()).intValue();
// do the Y coord here



The code gets the OS mouse "POINTER" coordinates on the screen (GraphicsDevice) not Cursor, a "Cursor" is for editing ***but often misuded in documentation !!!

Within a timer class that code will update if set to 500 on the timer every 1/2 second.

For individual Panels e.g. Window Panel Frame the interface MouseMotionListener is used.

example - not sure if it needs a clean up - RUN ON COMMAND LINE CONSOLE

// example class MousePointOutput written by [email protected] 11 June 2020
import javax.swing.JFrame;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.Point;
java.awt.Dimension;
java.io.IOException;
//
class MousePointOutput extends JFrame implements MouseMotionListener{
//
Point pointComponent;
Point pointScreen;
//
int counter = 0;
//
int xpointComponent = 0;
int ypointComponent = 0;
int xscreen = 0;
int yscreen = 0;
//
double xpointComponent = 0D;
double ypointComponent = 0D;
double xscreen = 0D;
double yscreen = 0D;

MousePointOutput(){
pointComponent = new Point(); // initialize  (0, 0)
pointScreen = new Point(); // initialize  (0, 0)
setPreferredSize(new Dimension(800I,600I));
setSize(new Dimension(800I,600I));
setVisible(true);
}//enconstr

public void MouseMoved(MouseEvent mve){

if(counter<5){
xpointComponent = mve.getX(); // RETURNS AN INT IN LISTENER unlike GraphicsDevice class
ypointComponent = mve.getY(); // RETURNS AN INT IN LISTENER unlike GraphicsDevice class
xscreen = mve.getXOnscreen(); // RETURNS AN INT IN LISTENER
yscreen = mve.getYOnscreen(); // RETURNS AN INT IN LISTENER
pointComponent = mve.getPoint(); //
pointScreen = mve.getLocationOnScreen(); // 
xpointComponent = pointComponent.getX(); // // RETURNS A Double from Point
ypointComponent = pointComponent.getY(); // // RETURNS A Double from Point
xscreen = pointScreen.getX(); // RETURNS A Double from Point
yscreen = pointScreen.getY();// RETURNS A Double from Point
//
try{
System.out.println("   INTEGERS FROM java.awt.event.MouseEvent alone:    "); 
System.out.println("   xpointComponent "+xpointComponent); 
System.out.println("   ypointComponent "+ypointComponent); 
System.out.println("   xscreen  "+xscreen);
System.out.println("   yscreen "+yscreen); 
System.out.println("   DOUBLE VALUES FROM java.awt.Point from java.awt.event.MouseEvent: ");
System.out.println("   xpointComponent "+xpointComponent); 
System.out.println("   ypointComponent "+ypointComponent); 
System.out.println("   xscreen "+xscreen); 
System.out.println("   yscreen "+yscreen); 
}catch (IOException e){
e.printStackTrace();
}catch (Exception f){
f.printStackTrace();
}finally{
System.out.println("THE BIG ?"); 
}
counter++;
}//enif

}//enlis

public static void main(String[] args){
new MousePointOutput();
}//enmain


}//enclss


Was This Post Helpful? 0
  • +
  • -

#34 NormR   User is offline

  • D.I.C Lover
  • member icon

Reputation: 832
  • View blog
  • Posts: 6,392
  • Joined: 25-December 13

Re: How can I record mouse motions over the entire window?

Posted 11 June 2020 - 07:21 AM

What happened to the formatting? Logically nested statements should be indented.
Please edit your post and fix the code's formatting.

1/2 second delay may not be quick enough. That would skip lots of positions that the mouse had passed over.

NOTE: The posted code is full of compiler errors. Please fix the errors and post code that compiles without errors.

This post has been edited by NormR: 11 June 2020 - 07:26 AM

Was This Post Helpful? 0
  • +
  • -

#35 nicephotog   User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 34
  • Joined: 06-June 20

Re: How can I record mouse motions over the entire window?

Posted 11 June 2020 - 07:28 AM

View PostNormR, on 11 June 2020 - 07:21 AM, said:

What happened to the formatting? Logically nested statements should be indented.
Please edit your post and fix the code's formatting.

1/2 second delay may not be quick enough. That would skip lots of positions that the mouse had passed over.

NOTE: The posted code is full of compiler errors. Please fix the errors and post code that compiles without errors.


1ST !!! I do not write your code for you but i will give it some help if i can.
2ND Formatting code has no convention - it is pure choice.
final.
Was This Post Helpful? -1
  • +
  • -

#36 NormR   User is offline

  • D.I.C Lover
  • member icon

Reputation: 832
  • View blog
  • Posts: 6,392
  • Joined: 25-December 13

Re: How can I record mouse motions over the entire window?

Posted 11 June 2020 - 07:31 AM

Quote

1ST !!! I do not write your code for you but i will give it some help if i can.

If you are posting example code, it is expected that the code will compile and execute and do the job.

Quote

2ND Formatting code has no convention - it is pure choice.

That is pure BS. Too bad I can only give that post a single -1.

This post has been edited by NormR: 11 June 2020 - 10:26 AM
Reason for edit:: spelling

Was This Post Helpful? 1
  • +
  • -

#37 nicephotog   User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 34
  • Joined: 06-June 20

Re: How can I record mouse motions over the entire window?

Posted 11 June 2020 - 07:45 AM

View PostNormR, on 11 June 2020 - 07:31 AM, said:

Quote

1ST !!! I do not write your code for you but i will give it some help if i can.

If you are posting example code, it is expected that the code will compile and execute and do the job.

Quote

2ND Formatting code has no convention - it is pure choice.

That is pure BS. Too bad I can only give that post a single -1.

Perhaps other moderators on this forum will give there views on this.


I am extremely sorry you view that such a way.
Philanthropic altruism whether one way or either is not to be an encouragement to plagiarism or parasitism upon others intellectual property right and work niether an obligation as it goes against all the free world stands for of ethic,
Niether encouraging lameness (for lack of better expression).

Was This Post Helpful? 0
  • +
  • -

#38 NormR   User is offline

  • D.I.C Lover
  • member icon

Reputation: 832
  • View blog
  • Posts: 6,392
  • Joined: 25-December 13

Re: How can I record mouse motions over the entire window?

Posted 11 June 2020 - 07:50 AM

It might be better for all if you ...

This post has been edited by NormR: 11 June 2020 - 07:52 AM

Was This Post Helpful? 0
  • +
  • -

#39 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15724
  • View blog
  • Posts: 62,994
  • Joined: 12-June 08

Re: How can I record mouse motions over the entire window?

Posted 11 June 2020 - 07:51 AM

Everyone, please ease up.
Was This Post Helpful? 1
  • +
  • -

#40 nicephotog   User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 34
  • Joined: 06-June 20

Re: How can I record mouse motions over the entire window?

Posted 12 June 2020 - 12:34 AM

This operated now though i have not had time for a basically almost superfluous piece.




/*  BAT FILE COMMANDS EXAMPLE 
REQUIRES JAVA 6

COMPILE COMMAND: 

"C:\Program Files (x86)\Java\jdk1.6.0_22\bin\javac.exe" "C:\Users\Administrator\Desktop\New folder\MousePointOutput.java"
pause

RUN COMMAND:
"C:\Program Files (x86)\Java\jdk1.6.0_22\bin\java.exe" -classpath "C:\Users\Administrator\Desktop\New folder"; MousePointOutput

*/

// example class MousePointOutput written by [email protected] 12 June 2020
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.Point;
import java.awt.Dimension;
import java.io.IOException;
//
public class MousePointOutput extends JFrame implements MouseMotionListener{
//
Point pointComponent;
Point pointScreen;
//
int counter = 0;
//
int xpointComponent = 0;
int ypointComponent = 0;
int xscreen = 0;
int yscreen = 0;
//
double xpointComponentd = 0;
double ypointComponentd = 0;
double xscreend = 0;
double yscreend = 0;



//constructor
MousePointOutput(){
pointComponent = new Point(); // initialize  (0, 0)
pointScreen = new Point(); // initialize  (0, 0)
addMouseMotionListener(this);
setPreferredSize(new Dimension(800,600));
setSize(new Dimension(800,600));
setVisible(true);
}//enconstr

public void mouseMoved(MouseEvent mve){
//
if(counter<5){
xpointComponent = mve.getX(); // RETURNS AN INT IN LISTENER unlike GraphicsDevice class
ypointComponent = mve.getY(); // RETURNS AN INT IN LISTENER unlike GraphicsDevice class
xscreen = mve.getXOnScreen(); // RETURNS AN INT IN LISTENER
yscreen = mve.getYOnScreen(); // RETURNS AN INT IN LISTENER
pointComponent = mve.getPoint(); //
pointScreen = mve.getLocationOnScreen(); //
xpointComponentd = pointComponent.getX(); // // RETURNS A Double from Point
ypointComponentd = pointComponent.getY(); // // RETURNS A Double from Point
xscreend = pointScreen.getX(); // RETURNS A Double from Point
yscreend = pointScreen.getY();// RETURNS A Double from Point
//
try{

System.out.println("   INTEGERS FROM java.awt.event.MouseEvent alone:    ");
System.out.println("   xpointComponent "+xpointComponent);
System.out.println("   ypointComponent "+ypointComponent);
System.out.println("   xscreen  "+xscreen);
System.out.println("   yscreen "+yscreen);
System.out.println("   DOUBLE VALUES FROM java.awt.Point from java.awt.event.MouseEvent: ");
System.out.println("   xpointComponentd "+xpointComponentd);
System.out.println("   ypointComponentd "+ypointComponentd);
System.out.println("   xscreend "+xscreend);
System.out.println("   yscreend "+yscreend);

}catch(Exception e){
e.printStackTrace();
}finally{
System.out.println("THE BIG ?");
}
/*   FOLLOWING OPTIONPANE CODE HAS NOT BEEN DEBUGGED
String msgglut = "   INTEGERS FROM java.awt.event.MouseEvent alone:    "+"\r\n";
msgglut += ("   xpointComponent "+xpointComponent+"\r\n");
msgglut += ("   ypointComponent "+ypointComponent+"\r\n");
msgglut += ("   xscreen  "+xscreen+"\r\n");
msgglut += ("   yscreen "+yscreen+"\r\n");
msgglut += ("   DOUBLE VALUES FROM java.awt.Point from java.awt.event.MouseEvent: "+"\r\n");
msgglut += ("   xpointComponentd "+xpointComponentd+"\r\n");
msgglut += ("   ypointComponentd "+ypointComponentd+"\r\n");
msgglut += ("   xscreend "+xscreend+"\r\n");
msgglut += ("   yscreend "+yscreend+"\r\n");

JOptionPane.showInternalMessageDialog(new java.awt.Frame(),msgglut,msgglut, JOptionPane.INFORMATION_MESSAGE);
*/

counter++;
}//enif

}//enlis


public void mouseDragged(MouseEvent mdg){
}// end interface requirement

public static void main(String[] args){
new MousePointOutput();
}//enmain


}//enclss



Was This Post Helpful? 0
  • +
  • -

#41 idlewild   User is offline

  • New D.I.C Head

Reputation: 3
  • Posts: 35
  • Joined: 19-June 20

Re: How can I record mouse motions over the entire window?

Posted 19 June 2020 - 09:43 PM

/*
 * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *   - Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *   - Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *
 *   - Neither the name of Oracle or the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */ 

import javax.swing.*;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

import javax.swing.event.MouseInputAdapter;

/** An application that requires no other files. */
public class TestCase extends JPanel{
	JButton jb1=new JButton("button 1");
JButton jb2=new JButton("button 2");
	static double x;static double y;
    static private MyGlassPane myGlassPane;
  JPanel p=this;
  JWindow cas=new JWindow();
  JCheckBox changeButton =
                new JCheckBox("Glass pane \"visible\"");
    /**
     * Create the GUI and show it.  For thread safety,
     * this method should be invoked from the
     * event-dispatching thread.
     */
    private   void createAndShowGUI() {
        //Create and set up the window.
        //this = new TestCase("TestCase");
    	//final TestCase cas=new TestCase();
    	  
    	//cas.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //Start creating and adding components.
   cas.setFocusable(true);
   cas.isBackgroundSet();
        changeButton.setSelected(false);
        //Set up the content pane, where the "main GUI" lives.
        Container contentPane = cas.getContentPane();
        contentPane.setLayout(new FlowLayout());
        //p.add(changeButton);
        p.add(jb1);
        p.add(jb2);
        cas.add(this);
cas.setSize(400, 400);
        //Set up the menu bar, which appears above the content pane.
       /* JMenuBar menuBar = new JMenuBar();
        JMenu menu = new JMenu("Menu");
        menu.add(new JMenuItem("Do nothing"));
        cas.add(menu);
        cas.setJMenuBar(menuBar);

        //Set up the glass pane, which appears over both menu bar
        //and content pane and is an item listener on the change
        //button.
        myGlassPane = new MyGlassPane(changeButton, menuBar,
                                      cas.getContentPane());
        changeButton.addItemListener(myGlassPane);
        cas.setGlassPane(myGlassPane);
*/
        //Show the window.
        //frame.pack();
jb1.addItemListener(new ItemListener(){
	public void itemStateChanged(ItemEvent e) {
    setVisible(e.getStateChange() == ItemEvent.SELECTED);
}
	
});

jb2.addMouseMotionListener(new MouseMotionListener(){

	@Override
	public void mouseDragged(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseMoved(MouseEvent arg0) {
		// TODO Auto-generated method stub
		x=arg0.getX();
		y=arg0.getY();
		cas.repaint();
		p.repaint();
		jb1.repaint();
	}
	
});



jb1.addMouseMotionListener(new MouseMotionListener(){

	@Override
	public void mouseDragged(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseMoved(MouseEvent arg0) {
		// TODO Auto-generated method stub
		x=arg0.getX();
		y=arg0.getY();
		cas.repaint();
		p.repaint();
		jb1.repaint();
	}
	
	
});
p.addMouseMotionListener(new MouseMotionListener(){

	@Override
	public void mouseDragged(MouseEvent arg0) {
		// TODO Auto-generated method stub
		x=arg0.getX();
		y=arg0.getY();
		cas.repaint();
		p.repaint();
	}

	@Override
	public void mouseMoved(MouseEvent arg0) {
		// TODO Auto-generated method stub
		x=arg0.getX();
		y=arg0.getY();
		cas.repaint();
		p.repaint();
	}
	
	
});
        cas.setVisible(true);cas.setSize(800,800);
        cas.addMouseMotionListener(new MouseMotionListener(){

		 
			public void mouseClicked(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}

 			public void mouseEntered(MouseEvent arg0) {
				// TODO Auto-generated method stub
				x=arg0.getX();
				y=arg0.getY();
				cas.repaint();
				repaint();
			}

			 
			public void mouseExited(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			 
			public void mousePressed(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			public void mouseReleased(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void mouseDragged(MouseEvent arg0) {
				// TODO Auto-generated method stub
				x=arg0.getX();
				y=arg0.getY();
				cas.repaint();
				p.repaint();
			}

			@Override
			public void mouseMoved(MouseEvent arg0) {
				// TODO Auto-generated method stub
				x=arg0.getX();
				y=arg0.getY();
				cas.repaint();
				p.repaint();
				System.out.println(x+"      "+y);
			}
        	
        	
        });
    }

    public void paint(Graphics g){
    	
   super.paint(g);
    	Graphics rr=cas.getGraphics();
   rr.drawString("here",(int) x, (int)y);
    }
    	public static void main(String[]args){
    		
    		new TestCase().createAndShowGUI();;
    	
}
    	

}

/**
 * We have to provide our own glass pane so that it can paint.
 */
class MyGlassPane extends JComponent
                  implements ItemListener {
    Point point;

    //React to change button clicks.
    public void itemStateChanged(ItemEvent e) {
        setVisible(e.getStateChange() == ItemEvent.SELECTED);
    }

    protected void paintComponent(Graphics g) {
        if (point != null) {
            g.setColor(Color.red);
            g.fillOval(point.x - 10, point.y - 10, 20, 20);
        }
    }

    public void setPoint(Point p) {
        point = p;
    }

    public MyGlassPane(AbstractButton aButton,
                       JMenuBar menuBar,
                       Container contentPane) {
        CBListener listener = new CBListener(aButton, menuBar,
                                             this, contentPane);
        addMouseListener(listener);
        addMouseMotionListener(listener);
    }
}

/**
 * Listen for all events that our check box is likely to be
 * interested in.  Redispatch them to the check box.
 */
class CBListener extends MouseInputAdapter {
    Toolkit toolkit;
    Component liveButton;
    JMenuBar menuBar;
    MyGlassPane glassPane;
    Container contentPane;

    public CBListener(Component liveButton, JMenuBar menuBar,
                      MyGlassPane glassPane, Container contentPane) {
        toolkit = Toolkit.getDefaultToolkit();
        this.liveButton = liveButton;
        this.menuBar = menuBar;
        this.glassPane = glassPane;
        this.contentPane = contentPane;
    }

    public void mouseMoved(MouseEvent e) {
        redispatchMouseEvent(e, false);
    }

    public void mouseDragged(MouseEvent e) {
        redispatchMouseEvent(e, false);
    }

    public void mouseClicked(MouseEvent e) {
        redispatchMouseEvent(e, false);
    }

    public void mouseEntered(MouseEvent e) {
        redispatchMouseEvent(e, false);
    }

    public void mouseExited(MouseEvent e) {
        redispatchMouseEvent(e, false);
    }

    public void mousePressed(MouseEvent e) {
        redispatchMouseEvent(e, false);
    }

    public void mouseReleased(MouseEvent e) {
        redispatchMouseEvent(e, true);
    }

    //A basic implementation of redispatching events.
    private void redispatchMouseEvent(MouseEvent e,
                                      boolean repaint) {
        Point glassPanePoint = e.getPoint();
        Container container = contentPane;
        Point containerPoint = SwingUtilities.convertPoint(
                                        glassPane,
                                        glassPanePoint,
                                        contentPane);
        if (containerPoint.y < 0) { //we're not in the content pane
            if (containerPoint.y + menuBar.getHeight() >= 0) { 
                //The mouse event is over the menu bar.
                //Could handle specially.
            } else { 
                //The mouse event is over non-system window 
                //decorations, such as the ones provided by
                //the Java look and feel.
                //Could handle specially.
            }
        } else {
            //The mouse event is probably over the content pane.
            //Find out exactly which component it's over.  
            Component component = 
                SwingUtilities.getDeepestComponentAt(
                                        container,
                                        containerPoint.x,
                                        containerPoint.y);
                            
            if ((component != null) 
                && (component.equals(liveButton))) {
                //Forward events over the check box.
                Point componentPoint = SwingUtilities.convertPoint(
                                            glassPane,
                                            glassPanePoint,
                                            component);
                component.dispatchEvent(new MouseEvent(component,
                                                     e.getID(),
                                                     e.getWhen(),
                                                     e.getModifiersEx(),
                                                     componentPoint.x,
                                                     componentPoint.y,
                                                     e.getClickCount(),
                                                     e.isPopupTrigger()));
            }
        }
        
        //Update the glass pane if requested.
        if (repaint) {
            glassPane.setPoint(glassPanePoint);
            glassPane.repaint();
        }
    }
} 



I have updated your code as you have used a lot of statics which afaik is not good for OOP design

Plus, I have managed to track the position over the 2 buttons takng off the glasspane(after it is on, nothing is selectable)

my code gets when on buttons the y position right however due to some reason gets the x position below where the buttons are, but i guess they can be fixed by adding extra x when the cursor is over the buttons' y's
Was This Post Helpful? 1
  • +
  • -

#42 Sciuriware   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 83
  • Joined: 17-August 13

Re: How can I record mouse motions over the entire window?

Posted 19 June 2020 - 09:47 PM

Thanks, I almost forgot the case.
;JOOP!
Was This Post Helpful? 0
  • +
  • -

#43 idlewild   User is offline

  • New D.I.C Head

Reputation: 3
  • Posts: 35
  • Joined: 19-June 20

Re: How can I record mouse motions over the entire window?

Posted 19 June 2020 - 10:26 PM

thanks for the rep up

public void paint(Graphics g){
    	
   super.paint(g);
   Graphics2D ggg=(Graphics2D)g;
   super.paint(ggg);
    	Graphics rr=this.getGraphics();
   ggg.drawString("here", x,y);
}

i noticed the snippet above further ameliorates the code and does what you almost want.
Was This Post Helpful? 0
  • +
  • -

#44 Sciuriware   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 83
  • Joined: 17-August 13

Re: How can I record mouse motions over the entire window?

Posted 19 June 2020 - 11:32 PM

"rr" ?????

;JOOP!
Was This Post Helpful? 0
  • +
  • -

#45 idlewild   User is offline

  • New D.I.C Head

Reputation: 3
  • Posts: 35
  • Joined: 19-June 20

Re: How can I record mouse motions over the entire window?

Posted 19 June 2020 - 11:36 PM

i am sorry for my naming convention.
might as well be getGraphx;

but the Graphics2D cast is a better way to approach the question imo
Was This Post Helpful? 0
  • +
  • -

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4