Which should you use, AWT or Swing?
Roughly Equivalent Components in AWT and Swing | ||
---|---|---|
AWT | Swing | Purpose |
Applet | JApplet | Run inside a browser. |
none | Border | decorate with a fancy edge. |
Button | JButton | User clicks button to make something happen. |
Canvas | JPanel or JLayeredPane | Place to roll your own low-level drawing |
Checkbox | 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. |
CheckboxGroup | ButtonGroup | Used in conjunction with Checkbox, JCheckBox, JRadioButton and JToggleButton to allow only on of group of options to be selected. |
Choice | JComboBox | 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. |
Color | Color | Describes a colour with 8 bits each of red, green, blue and transparency. |
none | JColorChooser | Let’s user choose a colour from a palette, or numerically, but not using hex. |
Component | JComponent | Used to roll your own widgets. |
Container | Container | Used to manage the Chinese boxes of panels within panels. |
Dialog | JDialog or JOptionPane | Pop up a box to ask the user a question. JOptionPane is a simplified JDialog to handle common cases. |
FileDialog | JFileChooser | Let the user select a directory or file from a tree. |
none | JFormattedTextField | Let the user key in a field where certain characters must be alphabetic or numeric. |
Frame | JFrame or JInternalFrame | Normal top level moveable window with widgets on it for minimize and close. |
Label | JLabel | Used to label fields. Displays text. User cannot type into it. It tends to blend into the background. |
List | 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 |
LayoutManager | LayoutManager | 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. |
Panel | 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. |
none | JPasswordField | For entering passwords. |
ScrollPane | JScrollPane | For scrolling a panel where there is not enough room to see it all at once. |
none | JSeparator | A decorative horizontal or vertical line. Note the spelling: JSeparat or. |
none | JSlider | The user uses the mouse to move an analog slider to select a value. |
none | JSpinner | The user uses arrow keys or a mouse to select a value by making it go higher or lower. |
TextArea | 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. |
TextField | JTextField | 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. |
none | JTable | |
none | JTree | Displaying and editing tree-structured data. |
Window | JWindow | Like a frame without the top bar widgets. |
This page is posted |
http://mindprod.com/jgloss/awt.html | |
Optional Replicator mirror
|
J:\mindprod\jgloss\awt.html | |
Please read the feedback from other visitors,
or send your own feedback about the site. Contact Roedy. Please feel free to link to this page without explicit permission. | ||
Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[3.133.154.17] |
| |
Feedback |
You are visitor number | |