Example usage for javax.swing JSplitPane getLeftComponent

List of usage examples for javax.swing JSplitPane getLeftComponent

Introduction

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

Prototype

@BeanProperty(bound = false, preferred = true, description = "The component to the left (or above) the divider.")
public Component getLeftComponent() 

Source Link

Document

Returns the component to the left (or above) 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 getOtherComponent(JSplitPane split, Component current) {
    if (split == null || current == null)
        return null;

    Component other = split.getLeftComponent();
    if (other == current)
        other = split.getRightComponent();
    return other;
}

From source file:Main.java

public static Component getChild(Component parent, String name) {
    parent = getContainer(parent);//from  www  .  j a  va2s.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.nbdemetra.ui.demo.ComponentsDemo.java

public ComponentsDemo() {
    initStaticResources();/*from   w  w w  . j a  va 2 s . co m*/

    final Map<Id, Component> demoData = lookupComponents();

    final JPanel main = new JPanel(new BorderLayout());
    final JTree tree = new JTree();
    tree.setRootVisible(false);
    tree.setCellRenderer(new IdRenderer(demoData));

    IdsTree.fill(tree, Lists.newArrayList(demoData.keySet()));
    expandAll(tree);

    tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            TreePath p = tree.getSelectionPath();
            if (p != null) {
                main.removeAll();
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) p.getLastPathComponent();
                Id id = IdsTree.translate(node);
                Component c = demoData.get(id);
                main.add(c != null ? c : new JPanel());
                main.validate();
                main.repaint();
            }
        }
    });

    JTsList dragDrop = new JTsList();
    dragDrop.setShowHeader(false);
    dragDrop.setInformation(new ITsList.InfoType[] { ITsList.InfoType.TsIdentifier, ITsList.InfoType.Data });
    dragDrop.setPreferredSize(new Dimension(200, 200));
    dragDrop.setTsAction(DemoTsActions.DO_NOTHING);

    JSplitPane left = NbComponents.newJSplitPane(JSplitPane.VERTICAL_SPLIT, NbComponents.newJScrollPane(tree),
            dragDrop);
    JSplitPane splitPane = NbComponents.newJSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, main);
    splitPane.getLeftComponent().setPreferredSize(new Dimension(200, 400));

    setLayout(new BorderLayout());
    add(splitPane, BorderLayout.CENTER);
}

From source file:edu.wpi.cs.wpisuitetng.modules.requirementsmanager.view.charts.StatView.java

/**
 * method to update the displayed chart based on the user's selection
 *//* w w w .  j a  v  a  2 s.  c  o m*/
public void updateChart() {

    JFreeChart chart = null;
    AbstractRequirementStatistics stats = null;

    // initialize the stats based on the type of data which the user has
    // selected
    switch (chartDataType) {

    case STATUS:
        stats = new StatusRequirementStatistics();
        break;

    case ITERATION:
        stats = new IterationRequirementStatistics();
        break;

    case ASSIGNEE:
        stats = new AssigneeRequirementStatistics();
        break;

    case ESTIMATES:
        stats = new EstimateRequirementStatistics();
        break;

    case EFFORT:
        stats = new ActualRequirementStatistics();
        break;
    case VELOCITY:
        stats = new VelocityIterationStatistics();
        break;
    case TASK:
        stats = new TaskRequirementStatistics();
        break;
    default:
        // if you encounter this default statement, it means that new
        // values
        // have been
        // added to the DataType enum, but nobody has modified this poor
        // little method

    }

    // build the chart based on the type of chart the user has selected
    switch (chartType) {

    case BAR: // TODO: determine if additional modifications need to be
              // made
              // to the plot
        chart = stats.buildBarChart();
        final CategoryPlot barPlot = (CategoryPlot) chart.getPlot();
        barPlot.setNoDataMessage("No data available");
        break;

    case PIE:
        chart = stats.buildPieChart();
        final PiePlot3D piePlot = (PiePlot3D) chart.getPlot();
        piePlot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
        piePlot.setNoDataMessage("No data available");
        piePlot.setCircular(true);
        piePlot.setLabelGap(0.02);
        piePlot.setForegroundAlpha(0.7f);
        final PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{0} = {1} ({2})");
        piePlot.setLabelGenerator(generator);
        break;

    case LINE:
        chart = stats.buildLineChart();
        final CategoryPlot linePlot = (CategoryPlot) chart.getPlot();
        linePlot.setNoDataMessage("No data available");

    default:
        // if you encounter this default statement, it means that new
        // values have been added to the ChartType enum, but nobody has
        // modified this poor little method
    }

    // add the newly generated chart to the panel
    final JSplitPane mainPane = (JSplitPane) getComponent(0);
    final ChartPanel chartPanel = (ChartPanel) mainPane.getLeftComponent();
    chartPanel.setChart(chart);

    return;

}

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

/**
 * Method converting the {@link WYSIWYGSplitPane} to LayoutML XML.
 *
 *
 * @see LayoutMLBlock/*ww w .  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();
}

From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java

/**
 * Adds a left and right component to the specified pane.
 * /*from w w  w  . j a v  a2  s  .c  o m*/
 * @param pane   The split pane to add the components to.
 * @param left   The left component to add.
 * @param right The right component to add.
 */
private void addComponents(JSplitPane pane, JComponent left, JComponent right) {
    Component c = pane.getLeftComponent();
    if (c != null)
        pane.remove(c);
    c = pane.getRightComponent();
    if (c != null)
        pane.remove(c);
    pane.setLeftComponent(left);
    pane.setRightComponent(right);
}