Adding graphics to JPanel using PopupMenu
Right. I really need help at this stage so I'll try and be as clear as I can.
I essentially want to be able to create a flowchart dynamically by adding different statements. Now it doesn't look like I have much done but this is probably my 4th attempt.
I basically want to draw the "Assignment", "While", "IF", blocks onto a JPanel by right clicking on nodes where I would like to insert these blocks.
One of my problems is: Can I add a MouseListener to my node in order to generate a popupmenu. At the moment I have a mouse listener for the whole JPanel and the popupmenu is generated where ever you right-click the mouse. I would like this to happen just over nodes. I know that mouselisteners can only be applied to JComponents so I extended the FCNode class with JComponent. I tried to add the mouse listener at this stage but it didn't work but I thought that maybe that was because of where I did it. Is what I want possible? If so how and where should I do it.
The code below isn't what it should be yet but I am just testing some of my theories. Initially I did have alot of the nested inner classes in seperate files but then put them all in one class based on something I read on another thread. Is this the right thing to do?
In the code below I simply created the default window that I want to see when the application is started. So basically the next thing I want to be able to do is right click on the node present, see a popup window appear, click "Assignment" and then see the "Assignment" graphic appear between the "start" and end "graphic".
Is this possible and if so how?
Sorry for rambling and thanks in advance for the help.
Regards,
Deirdre
Right. I really need help at this stage so I'll try and be as clear as I can.
I essentially want to be able to create a flowchart dynamically by adding different statements. Now it doesn't look like I have much done but this is probably my 4th attempt.
I basically want to draw the "Assignment", "While", "IF", blocks onto a JPanel by right clicking on nodes where I would like to insert these blocks.
One of my problems is: Can I add a MouseListener to my node in order to generate a popupmenu. At the moment I have a mouse listener for the whole JPanel and the popupmenu is generated where ever you right-click the mouse. I would like this to happen just over nodes. I know that mouselisteners can only be applied to JComponents so I extended the FCNode class with JComponent. I tried to add the mouse listener at this stage but it didn't work but I thought that maybe that was because of where I did it. Is what I want possible? If so how and where should I do it.
The code below isn't what it should be yet but I am just testing some of my theories. Initially I did have alot of the nested inner classes in seperate files but then put them all in one class based on something I read on another thread. Is this the right thing to do?
In the code below I simply created the default window that I want to see when the application is started. So basically the next thing I want to be able to do is right click on the node present, see a popup window appear, click "Assignment" and then see the "Assignment" graphic appear between the "start" and end "graphic".
Is this possible and if so how?
Sorry for rambling and thanks in advance for the help.
Regards,
Deirdre