List of usage examples for javax.swing JSplitPane getRightComponent
public Component getRightComponent()
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 w ww .j ava 2 s . co m 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:org.nuclos.client.layout.wysiwyg.LayoutMLGenerator.java
/** * Method converting the {@link WYSIWYGSplitPane} to LayoutML XML. * * * @see LayoutMLBlock/* w w w. ja v a 2s . c om*/ * @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 a 2 s.c om*/ * @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); }