Swing components are grouped by function and can be divided into the following categories:
? Top-level containers: JFrame, JApplet, JDialog and JWindow
? Intermediate containers: JPanel, JScrollPane, JSplitPane, JToolBar
? Special containers: intermediate containers that have special effects on the user interface, such as: JInternalFrame, JRootPane, JLayeredPane, and Jdestoppane
? Basic components: JButton, JComboBox, JList, JMenu, JSlider
? Display component of non-editable information: A component that displays non-editable information to the user, such as: JLabel, JProgressBar, JToolTip, etc.
? Components for editable information: JTable, JTextArea, and JTextField
? Special dialog box components: JColorChooser and JFileChooser
Layout Manager is used to manage the layout of components in containers
All containers have a default layout manager, and if no layout manager is specified for the container, the default layout manager is used
Specify the layout manager for the container by calling SetLayout (new xxxlayout), such as:
C. setlayout (New Xxxlayout)
Common layout managers:
1. FlowLayout, the component moves in a direction like the flow of water, JPanel uses the FlowLayout layout Manager by default (does not limit the component size, the container scale component size is unchanged, but the position changes)
2. BorderLayout, divide the container into south, north, left, right, and five parts, if you can use Borderlayout.south to set the position of the component
3. GridLayout, Grid Layout, constructed as follows: gridelayout (int rows,int cols), gridelayout (int rows,int cols,int hgap,int vgap), when the container to the layout manager When adding components, the default is from left to right, from top to bottom in each grid (the relative position of the component does not change with the container scaling, but the size changes, all components are the same size)
4. CardLayout layout Manager, treat all components that join the container as a stack of cards
5. GridBagLayout, powerful, but very complex
6. BoxLayout, retains many of the advantages of gridbaglayout, but not so complicated
Java common components and layout manager