Which should you use, AWT or Swing?
|Roughly Equivalent Components in AWT and Swing
|Run inside a browser.
|decorate with a fancy edge.
|User clicks button to make something happen.
|JPanel or JLayeredPane
|Place to roll your own low-level drawing
|JCheckBox (checked) or JRadioButton (round) or JToggleButton (full button)
|Checkbox is a small box, the user can tick or not to indicate a desired option. A RadioButton displays as a round button. JToggleButton displays as a rectangular button, usually with a custom icon. By default, the background changes colour slightly when selected. You can use these in isolation, or in clusters controlled by a CheckboxGroup or ButtonGroup.
|Used in conjunction with Checkbox, JCheckBox, JRadioButton and JToggleButton to allow only on of group of options to be selected.
|Allows user to pick one from a drop-down menu of choices. JComboBox has a write-in feature. Ironically, JComboxBox does not support combinations of choices. For that you need a java.awt.List or JList.
|Describes a colour with 8 bits each of red, green, blue and transparency.
|Let’s user choose a colour from a palette, or numerically, but not using hex.
|Used to roll your own widgets.
|Used to manage the Chinese boxes of panels within panels.
|JDialog or JOptionPane
|Pop up a box to ask the user a question. JOptionPane is a simplified JDialog to handle common cases.
|Let the user select a directory or file from a tree.
|Let the user key in a field where certain characters must be alphabetic or numeric.
|JFrame or JInternalFrame
|Normal top level moveable window with widgets on it for minimize and close.
|Used to label fields. Displays text. User cannot type into it. It tends to blend into the background.
|JList + JScrollPane
|JList lets the user make a selection, or many selections from a presented list which is always expanded. For long lists, you scroll. See also JComboBox
|Lets you design your layouts so they automatically reflow with different amounts of screen real estate, different text, difference translations, different available fonts etc.
|Menu with MenuBar and MenuItem
|JMenu with JMenuBar, JMenuItem, JRadioButtonMenuItem and JPopupMenu
|Drop down menus to select functions to perform. JRadioButtonMenuItem allows toggling option selections in the menus. JPopupMenu lets the user pop up a menu when she right clicks a component.
|JPanel or JToolBar or JSplitPane or JTabbedPane, or JLayeredPane.
|Panels collect components together into rectangles to simplify layout and enable encapsulation. A panel can be treated like an atomic component for most purposes. JToolBar is just a panel specialised for holding a row of buttons. JSplitPane is a split panel where the user can move the divide. JTabbedPane lets you cram many panels in small space. The user selects a tab, much as on a file folder, to bring one of them into full view. JLayeredPane is an advanced feature for composing transparent overlays, e.g. sprites.
|For entering passwords.
|For scrolling a panel where there is not enough room to see it all at once.
|A decorative horizontal or vertical line. Note the spelling: JSeparat or.
|The user uses the mouse to move an analog slider to select a value.
|The user uses arrow keys or a mouse to select a value by making it go higher or lower.
|JTextArea or JEditorPane or JTextPane
|TextArea and JTextArea allow multi-line text display and data entry. JEditorPane allows display of formatted HTML (Hypertext Markup Language) or RTF (Rich Text Format) with colours and fonts whereas JTextPane is like JEditorPane with the additional ability to edit styles and character attributes.
|Allow display or entering of one line of unformatted text. They always have a box around the text unlike labels which blend into the background. For more than one line see TextArea and JTextArea.
|Displaying and editing tree-structured data.
|Like a frame without the top bar widgets.
This page is posted
Optional Replicator mirror
Your face IP:[18.104.22.168]
You are visitor number