Finishing GUI |
As we saw from last time to insert a GUI item on the screen we must:
If we want selecting the GUI object to trigger an immediate response we must:
We've spoken mainly about JComboBoxes, but we can also work with JButtons, JLabel, JSlider, JTextField, and JTextArea. See the documentation on the GUI cheat sheet on the course documentation page.
Remember when you add items to the window, use the BorderLayout, which requires you to state where in the window you place the item (NORTH, SOUTH, EAST, or WEST) while JPanels use FlowLayout and you leave off the place information.
When executing an event handling method, you can find out what GUI component generated the event by evaluating evt.getSource() if evt is the event.
Finishing GUI |