Results 1 to 2 of 2
Thread: Linking code to GUI Interface
- 07-02-2007, 02:16 PM #1Member
- Join Date
- Jun 2007
- Rep Power
Linking code to GUI Interface
I have a GUI Interface with Add, Edit, Delete, Filter, Sort, Search methods.
How do I connect the coding for each of the methods above to the GUI Interface so that when the buttons are pressed, the correct method is called and the required output is seen.
Let's say that I want to add an information or filter something. When I click the appropriate button on the GUI Interface, the correct option has to pop up for me to do what I want to do, in this case, add or filter.
- 07-02-2007, 02:36 PM #2
As an abstract description:
You will have a data class which will hold your data and a view class (e.g. your jframe). You will register event listeners in your GUI and these event listeners (e.g. listener which listens for mouse clicks on certain components) will obtain necessary data from GUI elements (e.g. getting input from the user via a textfield) and call required methods of your data class to change the data. If you dont need to change data and just need to change representation, the listeners will call GUI methods instead of methods of your data class.
Here you can find list of listeners and events in Swing:
javax.swing.event (Java 2 Platform SE v1.4.2)
And here is a tutorial for listeners:
Lesson: Writing Event Listeners (The Java™ Tutorials > Creating a GUI with JFC/Swing)