📜  SWING-控件

📅  最后修改于: 2020-11-10 04:46:48             🧑  作者: Mango


每个用户界面都考虑以下三个主要方面-

  • UI元素-这些是用户最终看到并与之交互的核心视觉元素。 GWT提供了大量从基本到复杂的广泛使用和常见元素,我们将在本教程中介绍。

  • 布局-它们定义应如何在屏幕上组织UI元素,并为GUI(图形用户界面)提供最终外观。这部分将在“布局”一章中介绍。

  • 行为-这些是用户与UI元素进行交互时发生的事件。这部分将在事件处理一章中介绍。

UI类

每个SWING控件都继承以下Component类的属性。

S.No. Class & Description
1 Component

A Component is the abstract base class for the non menu user-interface controls of SWING. Component represents an object with graphical representation

2 Container

A Container is a component that can contain other SWING components

3 JComponent

A JComponent is a base class for all SWING UI components. In order to use a SWING component that inherits from JComponent, the component must be in a containment hierarchy whose root is a top-level SWING container

SWING UI元素

以下是使用SWING设计GUI时常用的控件列表。

S.No. Class & Description
1 JLabel

A JLabel object is a component for placing text in a container.

2 JButton

This class creates a labeled button.

3 JColorChooser

A JColorChooser provides a pane of controls designed to allow a user to manipulate and select a color.

4 JCheck Box

A JCheckBox is a graphical component that can be in either an on (true) or off (false) state.

5 JRadioButton

The JRadioButton class is a graphical component that can be in either an on (true) or off (false) state. in a group.

6 JList

A JList component presents the user with a scrolling list of text items.

7 JComboBox

A JComboBox component presents the user with a to show up menu of choices.

8 JTextField

A JTextField object is a text component that allows for the editing of a single line of text.

9 JPasswordField

A JPasswordField object is a text component specialized for password entry.

10 JTextArea

A JTextArea object is a text component that allows editing of a multiple lines of text.

11 ImageIcon

A ImageIcon control is an implementation of the Icon interface that paints Icons from Images

12 JScrollbar

A Scrollbar control represents a scroll bar component in order to enable the user to select from range of values.

13 JOptionPane

JOptionPane provides set of standard dialog boxes that prompt users for a value or informs them of something.

14 JFileChooser

A JFileChooser control represents a dialog window from which the user can select a file.

15 JProgressBar

As the task progresses towards completion, the progress bar displays the task’s percentage of completion.

16 JSlider

A JSlider lets the user graphically select a value by sliding a knob within a bounded interval.

17 JSpinner

A JSpinner is a single line input field that lets the user select a number or an object value from an ordered sequence.