Java JSplitPane createSplitPane(int newOrientation, Component newLeftComponent, Component newRightComponent)

Here you can find the source of createSplitPane(int newOrientation, Component newLeftComponent, Component newRightComponent)

Description

Creates a new JSplitPane, sets the name to a default value and sets the 2 child components to a zero minimum size to allow the split pane to resize itself.

License

Open Source License

Declaration

public static JSplitPane createSplitPane(int newOrientation, Component newLeftComponent,
        Component newRightComponent) 

Method Source Code


//package com.java2s;
/*// w  w  w . java2  s  .  c  o m
 * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved.
 * 
 * This software is open source. 
 * See the bottom of this file for the licence.
 * 
 * $Id: SwingUtils.java,v 1.1.1.1 2001/05/22 08:13:01 jstrachan Exp $
 */

import javax.swing.*;
import java.awt.*;
import javax.swing.*;

public class Main {
    public static final Dimension ZERO_DIMENSION = new Dimension(0, 0);

    /** Creates a new JSplitPane, sets the name to a default value
      * and sets the 2 child components to a zero minimum size to allow
      * the split pane to resize itself.
      */
    public static JSplitPane createSplitPane(int newOrientation, Component newLeftComponent,
            Component newRightComponent) {
        // allow the splitPane to completely resize!
        setZeroMinimumSize(newLeftComponent);
        setZeroMinimumSize(newRightComponent);

        JSplitPane answer = new JSplitPane(newOrientation, newLeftComponent, newRightComponent);
        answer.setName("SplitPane");
        answer.setOneTouchExpandable(true);
        return answer;
    }

    /** Sets the component to a minimum size of zero to allow split panes
      * and layout managers from shrinking the components
      */
    public static void setZeroMinimumSize(Component component) {
        if (component instanceof JComponent) {
            ((JComponent) component).setMinimumSize(ZERO_DIMENSION);
        }
    }
}

Related

  1. addTooltipsToSplitter(final JSplitPane splitpane, final String hide, final String reveal)
  2. applyDefaultProperties(final JSplitPane comp)
  3. createSplitPane(int newOrientation, Component newLeftComponent, Component newRightComponent)
  4. createSplitPane(int orientation, Component left, Component right)
  5. createStrippedSplitPane(int orient, JComponent comp1, JComponent comp2)
  6. createUndecoratedSplitPane(int orientation)
  7. createVertSplitPane(Component left, Component right)