Java GUI - OverwriteMatrix/RosettaCode GitHub Wiki

Java GUI Components

🧱 Top-Level Containers

Component Description
JFrame A main window with title bar
JDialog A pop-up dialog window
JWindow A borderless window

📦 Containers & Layout Components

Component Description
JPanel A generic container
JScrollPane Adds scrollbars to a component
JSplitPane Splits space between two components
JTabbedPane Tabbed navigation container
JLayeredPane Overlapping components in layers
JDesktopPane Container for internal frames
JInternalFrame Child window inside JDesktopPane
JToolBar Container for toolbar buttons
Box Horizontal or vertical component box

👨‍💻 Input Components

Component Description
JButton Clickable button
JToggleButton Button that can stay pressed
JCheckBox Checkbox option
JRadioButton Part of a radio button group
JComboBox Drop-down list
JTextField Single-line text input
JPasswordField Text field that hides characters
JTextArea Multi-line text area
JSpinner Numeric selector (up/down arrows)
JSlider Slider for selecting numeric value
JList List of selectable items (On JScrollPane)
JTable Spreadsheet-style data grid
JTree Hierarchical tree structure

📄 Display Components

Component Description
JLabel Displays text or image
JProgressBar Visual progress indicator
JSeparator Horizontal/vertical dividing line
JToolTip Tooltip that appears on hover
JEditorPane Displays rich content (HTML, RTF)
JTextPane Styled, editable text content

🍔 Menu Components

Component Description
JMenuBar Top-level menu bar
JMenu A dropdown menu
JMenuItem An item inside a menu
JCheckBoxMenuItem A checkbox menu item
JRadioButtonMenuItem A radio button menu item

🧰 Utility Components

Component Description
JFileChooser File open/save dialog
JColorChooser✅ Color picker dialog
Timer Used for scheduled tasks (javax.swing.Timer)
InputVerifier Validates input focus transfers

💡 (Bonus) AWT Components (less common in Swing apps)

Component Description
Canvas✅ Drawing surface
Label Basic text display
TextField AWT text input
Checkbox AWT checkbox
Choice AWT drop-down
List AWT list of items
Scrollbar AWT scroll bar

Java GUI Listeners

Listener Interface Commonly Used Components Typical Use Case
ActionListener JButton, JMenuItem, JCheckBox, JRadioButton, JComboBox, JTextField Button clicks, item selection, enter key
KeyListener JTextField, JTextArea, JPanel, JFrame Typing, shortcuts, key detection
MouseListener JPanel, JLabel, JButton, custom components Click, press, enter, exit events
MouseMotionListener JPanel, custom drawing areas Cursor movement, dragging
MouseWheelListener JScrollPane, JPanel, custom scrollable components Mouse wheel scrolling, zooming
ComponentListener JFrame, JPanel, any Component Resize, move, show, hide
ContainerListener JPanel, JFrame, JLayeredPane Component added/removed from containers
FocusListener JTextField, JComboBox, JTextArea Input focus gain/loss
HierarchyListener Any Component Parent/ancestor changes in component tree
HierarchyBoundsListener JComponent, JPanel Moved/resized in component tree
WindowListener JFrame, JDialog Open, close, iconify, activate window
WindowFocusListener JFrame, JDialog Window focus gain/loss
WindowStateListener JFrame Maximize, minimize, restore state
ItemListener JCheckBox, JRadioButton, JComboBox Selection toggle or item change
ChangeListener JSlider, JSpinner, JProgressBar, JTabbedPane, JToggleButton Value or state change
AdjustmentListener JScrollBar Scrollbar position changes
InputMethodListener JTextField, JTextArea, other text inputs IME (Input Method Editor) composition events