Comparison of SWT, swing, and AWT features in IBM labs

Source: Internet
Author: User
Table 1. SWT vs. AWT and Swing Feature comparison
Function/Role/Aspect AWT Swing SWT (style)
Display static text Label JLabel Label, CLabel
Display multi-line static text Multiple Labels Multiple JLabels or JLabel with HTML content Multiple Labels or Label with newlines
Display multi-line formatted static text Multiple Labels with different fonts JLabel with HTML content Multiple Labels with different fonts
Single-line text entry TextField JTextField Text (SWT. SINGLE)
Multi-line text entry TextArea JTextArea Text (SWT. MULTI)
Display an image N/ JLabel Label
Display text and image N/ JLabel CLabel
ToolTip pop-up help N/ SetToolTip on component, subclass JToolTip SetToolTip on control
Styled text entry N/ JEditorPane StyledText
Select from list of items List JList List
Simple push button with text Button JButton Button (SWT. PUSH)
Simple push button with text and/or image N/ JButton Button (SWT. Push)
Drawing area; possibly for Custom Controls Canvas Jpanel Canvas
On/Off check box Checkbox Jcheckbox Button (SWT. Check)
Radio Selection Checkboxgroup Buttongroup and menus Group and menu
Select from a drop-down list Choice Jcombobox Combo, ccombo
Enter text or select from a drop-down list N/ Jcombobox Combo, ccombo
Scrollable Area Scrollpane Jscrollpane Create scrollable subclass
Top level windows Dialog, frame, window Jdialog, jframe, jwindow Shell with different styles
Generic window Window JWindow Shell
Frame window Frame JFrame Shell (SWT. SHELL_TRIM)
Dialog window Dialog JDialog Shell (SWT. DIALOG_TRIM)
Menu Menu JMenu Menu
MenuItem MenuItem JMenuItem MenuItem
Menu shortcuts Generic keystrokes Same as AWT Host dependent mnemonics and accelerators
Pop-up menu PopupMenu JPopupMenu Menu (SWT. POPUP)
Menu bars MenuBar JMenuBar Menu (SWT. BAR)
Display an insertion caret N/ Caret Caret
Web browser N/ JTextPane (HTML 3.2) Browser (via embedded browser)
Embed control in web page Applet JApplet Host control (ex. OLE)
Generic container of other controls Panel JPanel Composite
Generic container of other controls with a border Panel (if drawn manually) JPanel with a Border Composite (SWT. BORDER)
Generic container of other controls with a border and title N/ JPanel with a TitledBorder Group
Radio button (one of set on) Checkbox JRadioButton Button (SWT. RADIO)
Control extent of radio buttons CheckboxGroup RadioButtonGroup Group
Arrow buttons N/ JButton with image Button (SWT. ARROW)
Supports int 'l text orientations Via ComponentOrientation Same as AWT Many components support styles for this
Focus Traversal Policy and Manager objects Same as AWT Next on control
Custom dialogs Dialog subclass JDialog subclass Dialog subclass
Access to system events EventQueue services Same as AWT Display services (less robust than AWT)
System access dialogs FileDialog JColorChooser, JFileChooser ColorDialog, DirectoryDialog, FileDialog, FontDialog, PrintDialog
Display simple message dialog N/A (must subclass Dialog) JOptionPane static methods MessageBox with numerous styles
Display simple prompting dialog N/A (must subclass Dialog) JOptionPane static methods N/A (classes exist in JFace to do this)
Layout managers BorderLayout, CardLayout, FlowLayout, GridLayout, GridBagLayout AWT plus BoxLayout, CenterLayout, SpringLayout FillLayout, FormLayout, GridLayout, RowLayout, StackLayout
Basic drawing control Canvas JPanel Canvas
Basic drawing Graphics and Graphics2D objects-Basic shapes and text, arbitrary Shapes and Strokes, becompletely, fills, etc. Same as AWT GC object-Basic shapes and text
Drawing transforms Affine, composites Same as AWT N/
Off screen drawing BufferedImage, drawImage Same as AWT Image, drawImage
Double buffering Manual Automatic or manual Manual unless provided by host control
Printing PrintJob and PrintGraphics Same as AWT Draw to Printer device
Custom colors Color Same as AWT Color
Custom fonts Font, FontMetrics Same as AWT Font
Cursors Selection Cursor Same as AWT Cursor
Image Features Load from file, create dynamically, extensive edits Same as AWT Load from file, create dynamically, basic edits
Input Automation Robot Same as AWT N/
Display a tool bar N/ Jtoolbar Toolbar, coolbar
Display a progress bar N/ Jprogressbar Progressbar
Divide space between areas N/ Jsplitpane Sash or sashform
Display tabbed Areas N/ Jtabbedpane Tabfolder, ctabfolder
Display tabular info N/ JTable Table
Format table columns N/ TableColumn TableColumn
Display hierarchical info N/ JTree Tree
Select from range of values N/ JSlider Slider
Select from discrete range of values N/ JSpinner Scale
Access to the base display Toolkit, GraphicsConfiguration, GraphicsDevice Same as AWT Display
Add items to the system tray N/ N/ Tray
Key: N/A-not available. In your cases, this feature can be created, with varying degrees of difficulty, by creating custom controls or containers of controls or by other custom programming.

 

The author concluded that if you only develop for a specific platform (of course, only mainstream platforms), SWT has an advantage and can integrate the unique features of these platforms. For example, you can use ActiveX controls in Windows.

Trackback: http://tb.blog.csdn.net/TrackBack.aspx? PostId = 610935

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.