Swing learning note 4 --- Window with panel

xiaoxiao2021-03-20  228

Swing's container structure is used by JLAYEREDPANE:

Swing containers include Japplet, JFrame, JDialog, Jwindow, JinternalFrame, JinternalFrame is the LightWeight container, and others are Heavyweight. When we want to join a component to Swing, it is not directly added to Rootpane, but adds a member of a member (LayeredPane or ContentPane).

In the rootpane structure, ContentPane and MenuBar are just one of the layers of LayeredPane, which is called Frame-Content Layer. Frame-Content Layer can be obtained by Frame_Content_Layer constant. Level of LayeredPane.

How do I know the relationship between LayeredPane? Z-Order.

Z-Order itself has two integers, one is the depth of the layer, and the other represents the same level. When the Layer resin of Z-Order is, it is indicated that its position is in the low layer, and it is overchair. In the JLAYEREDPANE class, 6 Z-Order's Layer constants are defined for users to refer:

Default_Layer: The Layer value is 0, indicated by integer object integer (0). Generally, the components we join are not marked, the default value is to put the components in this layer.

Palette_Layer: The value of the Layer is 100, located on Defaultlayer,

Generally used to place toolbars.

MODAL_LAYER: 200, above the Palettelayer, the dialog is placed.

Popup_layer: 300, MODALLAYER, for the Quick Menu and Toolbar Tips.

Drag_lyayer: 400, topuplayer is used to drag the assembly.

Frame_content_layer: -30000. Generally, the bottom layer is used to indicate the location of ContentPane and Menubar, and the number of times will not be changed in most cases.

Another value of z-Order Position: In contrast to Layer, the same level of the component, if the Position value is at the lower layer, the greater the Position value, the more the lower level. The Position value ranges from -1 to n-1, n refers to the number of components in the same level, and -1 represents the bottom layer, 0 represents the top layer.

The general programming language provides a good Z-Order automatic management mechanism without manual processing. Users simply add the required components to ContentPane.

JINTERNALFRAME:

Like JFrame, the only difference is JinternalFrame to make LightWeight, so JinternalFrame can use Java's LookandFeel feature completely different from the shape provided by the original operating system, which is more flexible than JFrame.

Journal of JinternalFrame is usually added to Desktoppane management. Desktoppane is a special LayeredPane to create virtual desktops (VirtualDesktop), which can display and manage the hierarchical relationship between many jinternalFrames.

JPANEl's use:

Panel is also one of the containers that Java usage. Panel can effectively utilize Panel to make panel management easier in addition to allowing components. Swing JPanel supports Double Buffering features, making JPanel more fluent on the process of processing. JSPLITPANE:

Splitpane can display two components at the same time in two display areas. If you want to display components in multiple areas, you must use multiple splitpanes simultaneously, two constants are used to set up horizontal segmentation or vertical segmentation: Horizontal_Split With vertical_split.

JTabbedpane's use:

JTabbedpane is like placing a file folder, when the user wants to see the file, as long as the instructions on the label are looking for, it can be displayed after finding it.

JTabbedpane's time handle is dominated by Changeevent, and whenever the label is selected back.

JScrollPane's use:

ScroolPane can be used to scroll through the window, in fact, composed of JVIEWPORT and JScrollbar. JViewPort is primarily responsible for displaying the size of the content area, the shape is a flat rectangle; JscrollBar generates a window scroll shaft.

JScrollPane can use the following parameters to set the emergence of the scroll shaft, which is defined in the ScrollPaneConstants interface:

Horizontal_scrollbar_always: Show Level Rolling Shaft

Horizontal_scrollbar_needed: The content horizontal area is larger than the display area display the scroll shaft

Horizontal_scrollbar_never: No scroll shaft

VERTICAL_SCROLLBAR_ALWAYS: Displays a vertical scroll shaft

Vertical_scrollbar_as_needed: Displays the scroll shaft when the content vertical area is greater than the display area

Vertical_scrollbar_never: does not display the scroll shaft

JScrollBar use:

If you want to make a thinner setting for the scroll shaft, if you dragging how much area is slopted, you must understand the features provided by JScrollBar. 4 parameters:

Value: JScrollBar starts at the beginning of the start, 0 represents the topmost.

Extent: Extension, limiting the range of rolling shafts can scroll.

Minimum: Minimum scale value.

Maximum: Maximum scale value.

转载请注明原文地址:https://www.9cbs.com/read-130361.html

New Post(0)