<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-font-kerning:1.0pt;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} --> <!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-font-kerning:1.0pt;} p {mso-style-noshow:yes; mso-style-priority:99; mso-margin-top-alt:auto; margin-right:0cm; mso-margin-bottom-alt:auto; margin-left:0cm; mso-pagination:widow-orphan; font-size:12.0pt; font-family:宋体; mso-bidi-font-family:宋体;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:595.3pt 841.9pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:42.55pt; mso-footer-margin:49.6pt; mso-paper-source:0; layout-grid:15.6pt;} div.Section1 {page:Section1;} -->
下表对 AWT、SWT 和 Swing 库的很多特性进行了比较,这种比较并没有按照任何特定顺序来进行。尽管没有完全列出所有特性,但是列出了很多最重要的特性。
功能/角色/外表 AWT Swing SWT(风格)
显示静态文本 Label JLabel Label, CLabel
显示多行静态文本 Multiple Labels 具有 HTML 内容的 Multiple JLabels 或 JLabel 具有新行的 Multiple Labels 或 Label
显示多行格式化静态文本 具有不同字体的 Multiple Labels 具有 HTML 内容的 JLabel 具有不同字体的 Multiple Labels
单行文本输入 TextField JTextField Text(SWT.SINGLE)
多行文本输入 TextArea JTextArea Text(SWT.MULTI)
显示图像 N/A JLabel Label
显示文本和图像 N/A JLabel CLabel
提示弹出帮助 N/A 组件的 setToolTip,JToolTip 子类 控件的 setToolTip
风格化的文本输入 N/A JEditorPane StyledText
从条目列表中进行选择 List JList List
简单按下具有文本的按钮 Button JButton Button(SWT.PUSH)
简单按下具有文本或图像的按钮 N/A JButton Button(SWT.PUSH)
绘图区域;可能用于定制控件 Canvas JPanel Canvas
选中/取消复选框 CheckBox JCheckBox Button(SWT.CHECK)
单选按钮选择 CheckBoxGroup ButtonGroup 和 Menu Group 和 Menu
从一个下拉列表中选择 Choice JComboBox Combo、CCombo
输入文本或从下拉列表中选择 N/A JComboBox Combo、CCombo
可滚动区域 ScrollPane JScrollPane 创建 Scrollable 子类
顶层窗口 Dialog、Frame、Window JDialog、JFrame、JWindow 具有不同风格的 Shell
通用窗口 Window JWindow Shell
框架窗口 Frame JFrame Shell(SWT.SHELL_TRIM)
对话框窗口 Dialog JDialog Shell(SWT.DIALOG_TRIM)
菜单 Menu JMenu Menu
MenuItem MenuItem JMenuItem MenuItem
菜单快捷键 通用击键 与 AWT 相同 依赖于主机的快捷键
弹出菜单 PopupMenu JPopupMenu Menu(SWT.POPUP)
菜单条 MenuBar JMenuBar Menu(SWT.BAR)
显示插入符号 N/A Caret Caret
Web 浏览器 N/A JTextPane(HTML 3.2) Browser(通过嵌入式浏览器)
Web 页面中的嵌入式控件 Applet JApplet 主机控件(例如 OLE)
其他控件的通用容器 Panel JPanel Composite
其他控件的有边界通用容器 Panel(如果是手工画的) 具有 Border 的 JPanel Composite(SWT.BORDER)
其他控件的有边界和标题的通用容器 N/A 具有 TitledBorder 的 JPanel Group
单选按钮(一个被选中) Checkbox JRadioButton Button(SWT.RADIO)
单选按钮的控件扩充 CheckboxGroup RadioButtonGroup Group
箭头按钮 N/A 具有图像的 JButton Button(SWT.ARROW)
支持文本显示方向 通过 ComponentOrientation 与 AWT 相同 很多组件都可以支持这种风格
焦点切换 Policy 和 Manager 对象 与 AWT 相同 下一个控件
定制对话框 Dialog 子类 JDialog 子类 Dialog 子类
访问系统事件 EventQueue 服务 与 AWT 相同 Display 服务(不如 AWT 健壮)
系统访问对话框 FileDialog JColorChooser、JFileChooser ColorDialog、DirectoryDialog、FileDialog、FontDialog、PrintDialog
显示简单消息对话框 N/A(必须是 Dialog 子类) JOptionPane 静态方法 具有很多风格的 MessageBox
显示简单提示对话框 N/A(必须是 Dialog 子类) JOptionPane 静态方法 N/A(JFace 中用来实现这种功能的子类)
布局管理器 BorderLayout、CardLayout、FlowLayout、GridLayout、GridBagLayout AWT 加上 BoxLayout、CenterLayout、SpringLayout FillLayout、FormLayout、GridLayout、RowLayout、StackLayout
基本的绘图控件 Canvas JPanel Canvas
基本绘图 Graphics 和 Graphics2D 对象 —— 基本形状和文本,任意 Shapes 和 Strokes、Bezier 以及文件 与 AWT 相同 GC 对象 —— 基本形状和文本
绘图转换 Affine,合成 与 AWT 相同 N/A
离屏绘图(Off screen drawing) BufferedImage、drawImage 与 AWT 相同 Image、drawImage
双缓冲区 手工 自动或手工 除非由主机控件提供,否则就是手工
打印 PrintJob 和 PrintGraphics 与 AWT 相同 向 Printer 设备绘图
定制颜色 Color 与 AWT 相同 Color
定制字体 Font、FontMetrics 与 AWT 相同 Font
光标选择 Cursor 与 AWT 相同 Cursor
图像特性 从文件中加载,动态创建,可扩充地编辑 与 AWT 相同 从文件中加载,动态创建,基本编辑
输入自动化 Robot 与 AWT 相同 N/A
显示工具条 N/A JToolBar ToolBar、CoolBar
显示进度条 N/A JProgressBar ProgressBar
将空间划分成区域 N/A JSplitPane Sash 或 SashForm
显示一个分标签页的区域 N/A JTabbedPane TabFolder、CTabFolder
显示制表信息 N/A JTable Table
格式化表的列 N/A TableColumn TableColumn
显示层次化信息 N/A JTree Tree
从一定范围的值中进行选择 N/A JSlider Slider
从一组离散范围的值中进行选择 N/A JSpinner Scale
对于基本显示的访问 Toolkit、GraphicsConfiguration、GraphicsDevice 与 AWT 相同 Display
将条目添加到系统托盘(system tray)中 N/A N/A Tray
关键:N/A —— 不适用。在很多情况中,这种特性都可以通过创建定制控件或控件容器或利用其他定制编程来实现,不过实现的难度会有所不同。