Example usage for javax.swing JSplitPane getTopComponent

List of usage examples for javax.swing JSplitPane getTopComponent

Introduction

In this page you can find the example usage for javax.swing JSplitPane getTopComponent.

Prototype

public Component getTopComponent() 

Source Link

Document

Returns the component above, or to the left of the divider.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton leftComponent = new JButton("left");
    JButton rightComponent = new JButton("right");

    JButton topComponent = new JButton("top");
    JButton bottomComponent = new JButton("bottom");

    JSplitPane hpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftComponent, rightComponent);

    JSplitPane vpane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topComponent, bottomComponent);

    leftComponent = (JButton) hpane.getLeftComponent();
    rightComponent = (JButton) hpane.getRightComponent();

    topComponent = (JButton) vpane.getTopComponent();
    bottomComponent = (JButton) vpane.getBottomComponent();

    hpane.setLeftComponent(topComponent);
    hpane.setRightComponent(bottomComponent);

    vpane.setTopComponent(leftComponent);
    vpane.setBottomComponent(rightComponent);
}

From source file:Main.java

public static Component getChild(Component parent, String name) {
    parent = getContainer(parent);//from   ww w.  ja v a  2s .  c om

    if (parent instanceof JSplitPane) {
        JSplitPane split = (JSplitPane) parent;
        if (JSplitPane.TOP.equals(name)) {
            return split.getTopComponent();
        } else if (JSplitPane.LEFT.equals(name)) {
            return split.getLeftComponent();
        } else if (JSplitPane.RIGHT.equals(name)) {
            return split.getRightComponent();
        } else if (JSplitPane.BOTTOM.equals(name)) {
            return split.getBottomComponent();
        }
    }
    Container cont = (Container) parent;
    for (int i = 0; i < cont.getComponentCount(); i++) {
        Component comp = cont.getComponent(i);
        if (name.equals(comp.getName())) {
            return comp;
        }
    }
    if (name.endsWith(VIEW_SUFFIX)) {
        String subName = name.substring(0, name.length() - VIEW_SUFFIX.length());
        if (subName.isEmpty()) {
            return parent;
        }
        return getContainer(getChild(parent, subName));
    }

    throw new IllegalArgumentException("No component named " + name);
}

From source file:ec.util.chart.swing.JTimeSeriesRendererSupportDemo.java

private Component createMissionControl() {
    ListSelectionModel seriesSelectionModel = new DefaultListSelectionModel();
    JSplitPane result = ModernUI.withEmptyBorders(new JSplitPane(JSplitPane.VERTICAL_SPLIT,
            createSeriesTable(seriesSelectionModel), createObsTable(seriesSelectionModel)));
    result.getTopComponent().setMinimumSize(new Dimension(100, 100));
    result.setDividerLocation(.5);//  w w  w  .j a v a  2s.c  o m
    return result;
}

From source file:org.nuclos.client.layout.wysiwyg.LayoutMLGenerator.java

/**
 * Method converting the {@link WYSIWYGSplitPane} to LayoutML XML.
 *
 *
 * @see LayoutMLBlock/*from www . j  a v a2  s  . c o  m*/
 * @param splitPane
 * @param tableLayout
 * @param blockDeep
 * @return {@link StringBuffer} with the LayoutML
 */
private synchronized StringBuffer getLayoutMLForSplitPane(WYSIWYGSplitPane splitPane, TableLayout tableLayout,
        int blockDeep) throws CommonValidationException {
    LayoutMLBlock block = new LayoutMLBlock(blockDeep);
    block.append("<" + ELEMENT_SPLITPANE);
    block.append(getLayoutMLAttributesFromProperties(WYSIWYGSplitPane.PROPERTIES_TO_LAYOUTML_ATTRIBUTES,
            splitPane.getProperties()));
    block.append(" >");
    block.append(getLayoutMLTableLayoutConstraints(splitPane, tableLayout, blockDeep + 1));
    block.append(getLayoutMLBordersFromProperty(splitPane.getProperties(), blockDeep + 1));
    block.append(getLayoutMLMinimumSizeFromComponent(splitPane, blockDeep + 1));
    block.append(getLayoutMLPreferredSizeFromProperty(splitPane.getProperties(), blockDeep + 1));

    Component[] allComponents = splitPane.getComponents();
    for (int i = 0; i < allComponents.length; i++) {
        Component c = allComponents[i];
        if (c instanceof JSplitPane) {
            JSplitPane jpnSplit = ((JSplitPane) c);

            Object propOrientation = splitPane.getProperties()
                    .getProperty(WYSIWYGSplitPane.PROPERTY_ORIENTATION).getValue();

            if (propOrientation != null) {
                if (ATTRIBUTEVALUE_HORIZONTAL.equals(propOrientation)) {
                    block.append(getLayoutMLForPanel((WYSIWYGLayoutEditorPanel) jpnSplit.getLeftComponent(),
                            blockDeep + 1,
                            getLayoutMLSplitPaneConstraints(ATTRIBUTEVALUE_LEFT, blockDeep + 2)));
                    block.append(getLayoutMLForPanel((WYSIWYGLayoutEditorPanel) jpnSplit.getRightComponent(),
                            blockDeep + 1,
                            getLayoutMLSplitPaneConstraints(ATTRIBUTEVALUE_RIGHT, blockDeep + 2)));
                } else {
                    block.append(getLayoutMLForPanel((WYSIWYGLayoutEditorPanel) jpnSplit.getTopComponent(),
                            blockDeep + 1, getLayoutMLSplitPaneConstraints(ATTRIBUTEVALUE_TOP, blockDeep + 2)));
                    block.append(getLayoutMLForPanel((WYSIWYGLayoutEditorPanel) jpnSplit.getBottomComponent(),
                            blockDeep + 1,
                            getLayoutMLSplitPaneConstraints(ATTRIBUTEVALUE_BOTTOM, blockDeep + 2)));
                }
            }
        }
    }

    block.linebreak();
    block.append("</" + ELEMENT_SPLITPANE + ">");
    return block.getStringBuffer();
}