Easy to Learn Java: Programming Articles, Examples and Tips

Start with Java in a few days with Java Lessons or Lectures

Home

Code Examples

Java Tools

More Java Tools!

Java Forum

All Java Tips

Books

Submit News
Search the site here...
Search...
 

Swing Chapter 8. (The basics) Split Panes. Easy for reading, Click here!

Swing Chapter 8. (The basics) Split Panes. Easy for reading, Click here!

[ Return to Swing (Book) ]

Page: 1/3 


Next Page (2/3) Next Page
Subpages: 1. Split Panes: JSplitPane 
2. 
Basic split pane example 
3. Gas model simulation using a split pane 

Chapter 8. Split Panes

In this chapter:

  •          JSplitPane
  •          Basic split pane example
  •          Gas model simulation using a split pane

8.1    JSplitPane

class javax.swing.JSplitPane

Split panes allow the user to dynamically change the size of two or more components displayed side-by-side (within a window or another panel). Special dividers can be dragged with the mouse to increase space for one component and decrease the display space for another.  Note that the total display area does not change. This gives applications a more modern and sophisticated view. A familiar example is the combination of a tree and a table separated by a horizontal divider (e.g. file explorer-like applications). The Swing framework for split panes consists only of JSplitPane.

JSplitPane can hold two components separated by a horizontal or vertical divider. The components on either side of a JSplitPane can be added either in one of the constructors, or with the proper setXXComponent() methods (where XX is substituted by Left, Right, Top, or Bottom). We can also set the orientation at run-time using its setOrientation() method.

The divider between the side components represents the only visible part of JSplitPane. It's size can be managed with the setDividerSize() method, and its position by the two overloaded setDividerLocation() methods (which take an absolute location in pixels or proportional location as a double). The divider location methods have no affect until JSplitPane is displayed. JSplitPane also maintains a oneTouchExpandable property which, when true, places two small arows inside the divider that will move the divider to its extremities when clicked.

UI Guideline : Resizable Panelled Display

Split pane becomes really useful when your design has panelled the display for ease of use but you (as designer) have no control over the actual window size. The Netscape e-mail reader is a good example of this. A split pane is introduced to let the user vary the size of the message header panel against the size of the message text panel.

An interesting feature of the JSplitPane component is that you can specify whether or not to repaint side components during the divider's motion using the setContinuousLayout() method. If you can repaint components fast enough, resizing will have a more natural view with this setting. Otherwise, this flag should be set to false, in which case side components will be repainted only when the divider's new location is chosen. In this latter case, a divider line will be shown as the divider location is dragged to illustrate the new position.

JSplitPane will not size any of its constituent components smaller than their minimum sizes. If the minimum size of each component is larger than the size of the splitpane the divider will be effectively disabled (unmovable). Also note that we can call its resetToPreferredSize() method to resize its children to their preferred sizes, if possible.

UI Guideline : Use Split Pane in conjunction with Scroll Pane

Its important to use a Scroll Pane on the panels which are being split with the Split Pane. The scroll bar will then invoke automatically as required when data is obscured as the split pane is dragged back and forth. The introduction of the scroll pane gives the viewer a clear indication that there is some hidden data. They can then choose to scroll with the scroll bar or uncover the data using the split pane.



[ Return to Swing (Book) ]


Search Books
Custom Search
Latest articles
 SSL with GlassFish v2, page 5

 SSL with GlassFish v2, page 4

 SSL with GlassFish v2, page 3

 SSL with GlassFish v2, page 2

 The Java Lesson 2: Anatomy of a simple Java program, page 2

 New site about Java for robots and robotics: both software and hardware.

 Exceptions -III: What's an exception and why do I care?

 Exceptions -II: What's an exception and why do I care?

 Exceptions: What's an exception and why do I care?

 Double your Java code quality in 10 minutes, here is receipt

 Murach's Java Servlets and JSP

 How to get ascii code from a char in Java?

 Can we just try without catch? Yes!

 Make Tomcat page load faster

 Make your Tomcat More secure - limit network address for certain IP addresses

 New Java book online starts now here...

 Implementing RESTful Web Services in Java

 Firefox trimming from 1 GB to 40 Mb with many tabs opened

 SSL with GlassFish v2

 My request to replublish Tech Tips

 Search JavaFAQ.nu site here

 New Advanced Installer for Java 6.0 brings XML updates and imports 3rd party MSI

 EJB programming restrictions

 Maven vs Ant or Ant vs Maven?

 Why Java does not use default value which it should?

 How to unsign signed bytes in Java - your guide is here

 The Java Lesson 3: Identifiers and primitive data types. Page 2

 The Java Lesson 7: Bitwise operations with good examples, click here! Page 4

 The Java Lesson 7: Bitwise operations with good examples, click here! Page 3

 The Java Lesson 7: Bitwise operations with good examples, click here! Page 2


[ More in News Section ]


Home Code Examples Java Forum All Java Tips Books Submit News, Code... Search... Offshore Software Tech Doodling

RSS feed Java FAQ RSS feed Java FAQ News     

    RSS feed Java Forums RSS feed Java Forums

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest 1999-2006 by Java FAQs Daily Tips.

Interactive software released under GNU GPL, Code Credits, Privacy Policy