Java JSplitPane getPref(JSplitPane jSplitPane)

Here you can find the source of getPref(JSplitPane jSplitPane)

Description

get Pref

License

Open Source License

Declaration

public static int getPref(JSplitPane jSplitPane) 

Method Source Code


//package com.java2s;
/*/*from w  w  w . j a v a2  s. c  om*/
 * Copyright (c) 2009 Albert Kurucz. 
 *
 * This file, Util.java is part of JTStand.
 *
 * JTStand is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * JTStand is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with GTStand.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.awt.Component;

import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;

public class Main {
    public static int getPref(JSplitPane jSplitPane) {
        if (jSplitPane == null) {
            return 0;
        }
        Component c = jSplitPane.getTopComponent();
        if (c == null || c.getPreferredSize() == null) {
            if (jSplitPane.getSize() != null) {
                return jSplitPane.getSize().height;
            } else {
                return 0;
            }
        }
        if (JScrollPane.class.isAssignableFrom(c.getClass())) {
            JScrollBar jsb = ((JScrollPane) c).getHorizontalScrollBar();
            if (jsb.isShowing()) {
                return jsb.getSize().height + c.getPreferredSize().height + jSplitPane.getInsets().top;
            }
        }
        return c.getPreferredSize().height + jSplitPane.getInsets().top;
    }
}

Related

  1. createSplitPane(int orientation, Component left, Component right)
  2. createStrippedSplitPane(int orient, JComponent comp1, JComponent comp2)
  3. createUndecoratedSplitPane(int orientation)
  4. createVertSplitPane(Component left, Component right)
  5. flattenJSplitPane(JSplitPane splitPane)
  6. getSplitPane(boolean vertical, JComponent left, JComponent right)
  7. getSplitPaneComponentLength(JSplitPane splitPane, Component component)
  8. getSplitPaneSize(JSplitPane splitPane)
  9. hsplit(Component left, Component right, double resizeWeight)