Ok so lets say I have 3 Jpanels – 1 parent and 2 Children
//Assume necessary imports etc
parent is something like:
public class ParentPanel extends JFrame {
private JPanel mainPanel,controlPanel;
public ParentPanel(){
MainPanel pp= new ParentPanel();
controlPanel cp = new controlPanel();
}
...
Main Panel in real thing is like a 2d graphics thing but not important for the point so simplified:
public class MainPanel implements MouseMotionListener{
public MainPanel(){
//not important now
}
public void MouseMoved(MouseEvent arg0){
int xPos e.getX
}
...
What i want to do is get the X pos of the mouse and pass it from main panel up to the parent and into a label for example on the sibling control panel.
Any ideas clues or pointers appreciated thanks
Depending on how complicated the GUI is you can pass the ParentPanel object as a parameter to the MainPanel object. In the MainPanel you have access to all the ParentPanel’s components etc.
And in the ParentPanel when you create teh MainPanel:
This is of course a very simple solution and more complicated GUIs will not be suitable.