Detailed usage of swing split window control JSplitPane, swingjsplitpane

Source: Internet
Author: User

Detailed usage of swing split window control JSplitPane, swingjsplitpane

This article shares the usage of JSplitPane for your reference. The specific content is as follows:

1. The swing split window control JSplitPane is used to split the window into two parts.

2. Only one control can be placed in each split window. If you want to add multiple controls, you can create one JPane panel on the top so that multiple controls can be created. The swing split window control JSplitPane is used to split the window into two parts. JSplitPane provides two constants for you to determine whether vertical or horizontal segmentation is required. The two constants are: HORIZONTAL_SPIT and VERTICAL_SPLIT.

3. Usage:

① SetDividerSize (int size): set the size of the split entry.

② GetDividerSize () to get the size of the split.

③ SetDividerLocation (int size) sets the split position according to the percentage.

④ GetOrientation.

4. Constructor

JSplitPane (): Creates a new JSplitPane, which contains two default buttons and arranged horizontally without the Continuous Layout function.

JSplitPane (int newOrientation): Creates a specified horizontal or vertical cutting JSplitPane, but does not have the Continuous Layout function.

JSplitPnae (int newOrientation, boolean newContinuousLayout): Creates a JSplitPane that specifies horizontal or vertical cutting, and specifies whether the Continuous Layout function is available.

JSplitPane (int newOrientation, boolean newContinuousLayout, Component
NewLeftComponent, Component newRightComponent): Creates a JSplitPane for horizontal or vertical cutting, specifies the Component to be displayed in the display area, and sets whether to use the Continuous Layout function.

JSplitPane (int newOrientation, COmponent newLeftComponent, COmponent newRightComponent ):
Create a JSplitPane for horizontal or vertical cutting and specify the components to be displayed in the display area. However, the Continuous Layout function is not available.

The Continuous Layout mentioned above indicates whether the components in the window dynamically change the size when you drag the separator line of the cut panel. NewContinuousLayout is a boolean value. If it is set to true, the component size is changed along with the drag of the separator line. If it is set to false, the component size is determined only when the separator line is stopped. You can also use the setContinuousLayout () method in JSplitPane to set this project.

5. Instances

Package swing; import java. awt. event. componentAdapter; import java. awt. event. componentEvent; import javax. swing. JFrame; import javax. swing. JSplitPane; import javax. swing. JPanel; public class MainFrame extends JFrame {/*****/JSplitPane jSplitPane1 = new JSplitPane (); JPanel jPanel1 = new JPanel (); JPanel jPanel2 = new JPanel (); private static final long serialVersionUID = 1L; public static void m Ain (String [] args) {new MainFrame ();} public void myinit () {this. setdefaclocloseoperation (JFrame. EXIT_ON_CLOSE); // sets the process to automatically exit after the form is closed. this. setSize (800,600); // set the default size of the form. this. setExtendedState (JFrame. MAXIMIZED_BOTH); // sets the form status to maximize the screen size, that is, full screen size. This. setVisible (true); // display the form this. jSplitPane1.setDividerLocation (0.7); // set the ratio of left and right sides of the split panel (this takes effect now. It will not work until it is placed in setVisible (true .) This. addComponentListener (new ComponentAdapter () {public void componentResized (ComponentEvent e) {jSplitPane1.setDividerLocation (0.7) ;}} public MainFrame () {try {jbInit (); myinit ();} catch (Exception ex) {ex. printStackTrace () ;}} private void jbInit () throws Exception {this. getContentPane (). add (jSplitPane1, java. awt. borderLayout. CENTER); jSplitPane1.add (jPanel1, JSplitPane. LEFT); jSplitPane1.add (jPanel2, JSplitPane. RIGHT); jSplitPane1.setEnabled (false); jSplitPane1.setOneTouchExpandable (true );}}

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.