Java Learning: JSplitPane controls

Source: Internet
Author: User

The JSplitPane control is a tile display control in swing that can display up to 2 controls only. The user can adjust and manipulate the two controls.

Controls in JSplitPane can be set from left to right through the Jsplitpane.horizontal_split property setting , or Jsplitpane.vertical_split property settings are arranged from top to bottom.

jsplitpane () JSplitPane (int neworientation) JSplitPane (int neworientation, boolean newcontinuouslayout) JSplitPane (Int newOrientation,  boolean newContinuousLayout, Component newLeftComponent, Component  newrightcomponent) JSplitPane (int neworientation, component newleftcomponent, component  newrightcomponent) 

The middle parameters of the above 5 constructors:

int neworientation: Sets the horizontal or vertical display Jsplitpane.vertical_split Jsplitpane.horizontal_splitboolean Newcontinuouslayout: Sets redraw true when resizing interlaced or when resizing is complete redraw false when adjustment is complete newleftcomponent newrightcomponent: the control to display

The above parameters can be set at construction time, or after an instance is created.

Setcontinuouslayout (Boolean newcontinuouslayout) setorientation (int orientation) Add (Component comp, int index)

Specific cases

Public class jsplitpane1 {    public jsplitpane1 ()  {         jframe f = new jframe ("JSplitPaneDemo");         container contentpane = f.getcontentpane ();         jlabel label1 = new jlabel ("Label 1", Jlabel.center);         label1.setbackground (Color.green);         label1.setopaque (True);         Jlabel label2 = new jlabel ("Label 2", Jlabel.center);         label2.setbackground (Color.pink);         Label2.setopaque (true);         jlabel label3 = new  jlabel ("Label 3", jlabel.center);  &nbSp;      label3.setbackground (Color.yellow);         label3.setopaque (true);         //adds a slide control and places 2 labels in the control         JSplitPane splitPane1 =                 new jsplitpane ( jsplitpane.horizontal_split,                         false,                          label1,                         LABEL2);         Splitpane1.setdividerlocation (0.3);    &nbsP;    splitpane1.setonetouchexpandable (True);         splitpane1.setdividersize         //Add the main slide control, which is the slide control, and the label         /*JSplitPane splitPane2 =                 new jsplitpane ( jsplitpane.vertical_split,                                true,                                 splitPane1,                              &nBSP;  LABEL3); */        jsplitpane splitpane2 =  new jsplitpane ();         splitpane2.setcontinuouslayout ( true);         splitpane2.setorientation (Jsplitpane.vertical_split);         splitpane2.add (Splitpane1, jsplitpane.bottom);         splitpane2.add (label3, jsplitpane.top);         splitpane2.setdividerlocation (;        ) Splitpane2.setonetouchexpandable (False);         Splitpane2.setdividersize (5);         contentpane.add (SplitPane2);         f.setsize (250,200);         f.setvisible (true);      &Nbsp;  f.addwindowlistener (New windowadapter ()  {             public void windowclosing (windowevent e)  {                 system.exit (0);             }        } );     }    public static void main (String[] arg)  {        new jsplitpane1 ();     }}


Java Learning: JSplitPane controls

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.