hi i am having a bit of trouble displaying the mouse position in JTextField. i have currently done this code. i need to display the x and y positions inside the textfield.

private JTextField xTextField, yTextField;
private int mouseX, mouseY;

JPanel mousePanel = new JPanel();
    xTextField = new JTextField (10);
    yTextField = new JTextField (10);
    mousePanel.add(xTextField);
    mousePanel.add(yTextField);
    visibleArea.add(mousePanel, BorderLayout.NORTH);
    addMouseListener(this);
public void mousePressed(MouseEvent e) {
   mouseX = e.getX();
   mouseY = e.getY();
   repaint();
	}

i am sure i am forgeting something very straight forward but if anyone knows how i can do this it would be greatly appreciated.
cheers

You've forgotten to put the values of mouseX and mouseY into the two TextFields

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.