AWT,Swing,SWT组件间的对应关系

 

Function/Role/Aspect

AWTSwingSWT (style)
Display static textLabelJLabelLabel, CLabel
Display multi-line static textMultiple LabelsMultiple JLabels or JLabel with HTML contentMultiple Labels or Label with newlines
Display multi-line formatted static textMultiple Labels with different fontsJLabel with HTML contentMultiple Labels with different fonts
Single-line text entryTextFieldJTextFieldText(SWT.SINGLE)
Multi-line text entryTextAreaJTextAreaText(SWT.MULTI)
Display an imageN/AJLabelLabel
Display text and imageN/AJLabelCLabel
ToolTip pop-up helpN/AsetToolTip on component, subclass JToolTipsetToolTip on control
Styled text entryN/AJEditorPaneStyledText
Select from list of itemsListJListList
Simple push button with textButtonJButtonButton(SWT.PUSH)
Simple push button with text and/or imageN/AJButtonButton(SWT.PUSH)
Drawing area; possibly for custom controlsCanvasJPanelCanvas
On/off check boxCheckBoxJCheckBoxButton(SWT.CHECK)
Radio selectionCheckBoxGroupButtonGroup and menusGroup and Menu
Select from a drop-down listChoiceJComboBoxCombo, CCombo
Enter text or select from a drop-down listN/AJComboBoxCombo, CCombo
Scrollable areaScrollPaneJScrollPaneCreate Scrollable subclass
Top level windowsDialog, Frame, WindowJDialog, JFrame, JWindowShell with different styles
Generic windowWindowJWindowShell
Frame windowFrameJFrameShell(SWT.SHELL_TRIM)
Dialog windowDialogJDialogShell(SWT.DIALOG_TRIM)
MenuMenuJMenuMenu
MenuItemMenuItemJMenuItemMenuItem
Menu shortcutsGeneric keystrokessame as AWThost dependent mnemonics and accelerators
Pop-up menuPopupMenuJPopupMenuMenu(SWT.POPUP)
Menu barsMenuBarJMenuBarMenu(SWT.BAR)
Display an insertion caretN/ACaretCaret
Web browserN/AJTextPane (HTML 3.2)Browser (via embedded browser)
Embed control in web pageAppletJAppletHost control (ex. OLE)
Generic container of other controlsPanelJPanelComposite
Generic container of other controls with a borderPanel (if drawn manually)JPanel with a BorderComposite(SWT.BORDER)
Generic container of other controls with a border and titleN/AJPanel with a TitledBorderGroup
Radio button (one of set on)CheckboxJRadioButtonButton(SWT.RADIO)
Control extent of radio buttonsCheckboxGroupRadioButtonGroupGroup
Arrow buttonsN/AJButton with imageButton(SWT.ARROW)
Supports int'l text orientationsvia ComponentOrientationsame as AWTMany components support styles for this
Focus TraversalPolicy and Manager objectssame as AWTNext on control
Custom dialogsDialog subclassJDialog subclassDialog subclass
Access to system eventsEventQueue servicessame as AWTDisplay services (less robust than AWT)
System access dialogsFileDialogJColorChooser, JFileChooserColorDialog, DirectoryDialog, FileDialog, FontDialog, PrintDialog
Display simple message dialogN/A (must subclass Dialog)JOptionPane static methodsMessageBox with numerous styles
Display simple prompting dialogN/A (must subclass Dialog)JOptionPane static methodsN/A (classes exist in JFace to do this)
Layout managersBorderLayout, CardLayout, FlowLayout, GridLayout, GridBagLayoutAWT plus BoxLayout, CenterLayout, SpringLayoutFillLayout, FormLayout, GridLayout, RowLayout, StackLayout
Basic drawing controlCanvasJPanelCanvas
Basic drawingGraphics and Graphics2D objects - Basic shapes and text, arbitrary Shapes and Strokes, Bezier, fills, etc.same as AWTGC object - Basic shapes and text
Drawing transformsAffine, compositessame as AWTN/A
Off screen drawingBufferedImage, drawImagesame as AWTImage, drawImage
Double bufferingManualAutomatic or manualManual unless provided by host control
PrintingPrintJob and PrintGraphicssame as AWTdraw to Printer device
Custom colorsColorsame as AWTColor
Custom fontsFont, FontMetricssame as AWTFont
Cursors selectionCursorsame as AWTCursor
Image featuresload from file, create dynamically, extensive editssame as AWTload from file, create dynamically, basic edits
Input automationRobotsame as AWTN/A
Display a tool barN/AJToolBarToolBar, CoolBar
Display a progress barN/AJProgressBarProgressBar
Divide space between areasN/AJSplitPaneSash or SashForm
Display tabbed areasN/AJTabbedPaneTabFolder, CTabFolder
Display tabular infoN/AJTableTable
Format table columnsN/ATableColumnTableColumn
Display hierarchical infoN/AJTreeTree
Select from range of valuesN/AJSliderSlider
Select from discrete range of valuesN/AJSpinnerScale
Access to the base displayToolkit, GraphicsConfiguration, GraphicsDevicesame as AWTDisplay
Add items to the system trayN/AN/ATray
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值