GUI Programming Help
Can anyone point me to any kind of resources (tutorials, books, websites, etc) to do with programming GUIs in Java, more specifically, the interaction between components and programming events.
I have designed a programme, all the GUI work is done, i am now in the process of making it fully functional (adding events to the components) and I am having trouble understanding how to access different containers.
For example, i have a menubar which has an option to change the colour of some text, which is in the same frame, nested in a JPanel, within a JLabel.
How do I get access to that JLabel, from the menubar, actually from the event that the JMenuItem triggers.
In the past, when not dealing with menubars, I have used getParent(), to move through the containers, then using get() methods to access other objects. Is there an easier or more elegant way of doing this?
Any help would be great, I can post examples if I have not made myself clear.
Bump, any ideas?
I was going to put this in the advanced sub-forum, but thought otherwise.. was I wrong?
Unfortunately your question is not as easy to answer as anyone would like it to be... You can start by Googling Java key words like:
That should give you a good head start...
If all your components are in one class, then each component should have an instance field. If the panels are in separate classes, then treat the panels as objects and provide appropriate methods to modify their contents.
Look at the Sun Java Tutorial on Swing, about halfway down the main page. BTW, learn about the EventQueue and the event dispatcher thread.