Title: Gui Components Summary
Course: CPS 261: Advanced Java Concepts ~ DL & MM MASTER

Gui Components Summary

GUI Component High Level

- AWT (Abstract Windowing Toolkit) versus Swing packages of Components
- JFrame fundamentals versus JApplet fundamentals.
- Note that Applets used to be more prevalent than now. Applets have had some security issues, so getting applet code to work in your browser requires being more lax on your browser security settings.
- Creating a program that can be an applet and a window application (BasicBoth.java).

Gui Component Basics

- JTextArea, JTextField and the useful associated methods: setText, append, getText, getSelectedText, ...
- Other components: JLabel and JButton
- How to connect up an ActionListener interface to find out when a JButton is clicked or when someone hits the Enter key in JTextField
- Using the methods getSource() and getActionCommand() to determine which Button was clicked
- Using inner classes and anonymous classes

GUI LayoutManagers

- FlowLayout demo
- GridLayout demo
- BorderLayout demo
- Using JPanel to construct useful GUI layouts. JPanel works especially well with BorderLayout

GUI Menus

- JMenuItem works similar to JButton and can take an ActionListener interface
- JMenu and JMenuBar containers for JMenuItem
- Nested Menus

GUI More Book Examples

- WindowListener example
- ImageIcon and adding images to JLabel or to JButton
- Providing Scrolling capabilities. The primary component that needs this is JTextArea, but JScrollPane can be used for other GUI components as well.
- Using the setVisible method to make GUI objects disappear and then reappear.
- JColorChooser class

Gui Additional Examples

- Check.java example using JCheckBox, JRadioButton, and ButtonGroup
- Selection.java example using JList and JScrollPane
- GridBagLayout manager example
- CardLayout manager example
- Null Layout Manager example
- Creating your own button class similar to JButton
- Creating your own Layout manager (CustomLayout.java)

Last Modified: June 8, 2014 8:04 AM