List of usage examples for javax.swing JSplitPane setTopComponent
@BeanProperty(bound = false, description = "The component above, or to the left of the divider.") public void setTopComponent(Component comp)
From source file:JSplitPaneVerticalSetTopBottom.java
public static void main(String[] a) { JFrame horizontalFrame = new JFrame(); horizontalFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComponent topButton = new JButton("Left"); JComponent bottomButton = new JButton("Right"); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(topButton); splitPane.setBottomComponent(bottomButton); horizontalFrame.add(splitPane, BorderLayout.CENTER); horizontalFrame.setSize(150, 150);// w ww .j a va 2 s .c o m horizontalFrame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame horizontalFrame = new JFrame(); horizontalFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComponent topButton = new JButton("Left"); JComponent bottomButton = new JButton("Right"); final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(topButton); splitPane.setBottomComponent(bottomButton); horizontalFrame.add(splitPane, BorderLayout.CENTER); horizontalFrame.setSize(150, 150);//www . j av a2 s. com horizontalFrame.setVisible(true); splitPane.setDividerLocation(0.5); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { JFrame frame = new JFrame("Property Split"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(new JLabel("www.java2s.com")); splitPane.setBottomComponent(new JLabel("www.java2s.com")); PropertyChangeListener propertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent changeEvent) { JSplitPane sourceSplitPane = (JSplitPane) changeEvent.getSource(); String propertyName = changeEvent.getPropertyName(); if (propertyName.equals(JSplitPane.LAST_DIVIDER_LOCATION_PROPERTY)) { int current = sourceSplitPane.getDividerLocation(); System.out.println("Current: " + current); Integer last = (Integer) changeEvent.getNewValue(); System.out.println("Last: " + last); Integer priorLast = (Integer) changeEvent.getOldValue(); System.out.println("Prior last: " + priorLast); }// w w w .j a v a 2s . c o m } }; // Attach listener splitPane.addPropertyChangeListener(propertyChangeListener); frame.add(splitPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { JFrame frame = new JFrame("Property Split"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setResizeWeight(1.0);//from w w w . j av a 2s .c o m splitPane.setTopComponent(new JLabel("www.java2s.com")); splitPane.setBottomComponent(new JLabel("www.java2s.com")); frame.add(splitPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:ResizeSplit.java
public static void main(String args[]) { String title = "Resize Split"; final JFrame vFrame = new JFrame(title); vFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton topButton = new JButton("Top"); JButton bottomButton = new JButton("Bottom"); final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(topButton); splitPane.setBottomComponent(bottomButton); ActionListener oneActionListener = new ActionListener() { public void actionPerformed(ActionEvent event) { splitPane.setResizeWeight(1.0); vFrame.setSize(300, 250);/*ww w . j a va 2s . c om*/ vFrame.validate(); } }; bottomButton.addActionListener(oneActionListener); ActionListener anotherActionListener = new ActionListener() { public void actionPerformed(ActionEvent event) { splitPane.setResizeWeight(0.5); vFrame.setSize(300, 250); vFrame.validate(); } }; topButton.addActionListener(anotherActionListener); vFrame.getContentPane().add(splitPane, BorderLayout.CENTER); vFrame.setSize(300, 150); vFrame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Property Split"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setContinuousLayout(true); splitPane.setOneTouchExpandable(true); JComponent topComponent = new JButton("A"); splitPane.setTopComponent(topComponent); JComponent bottomComponent = new JButton("B"); splitPane.setBottomComponent(bottomComponent); frame.add(splitPane, BorderLayout.CENTER); frame.setSize(300, 150);/* ww w . ja va2s . c o m*/ frame.setVisible(true); }
From source file:PropertySplitPane.java
public static void main(String args[]) { JFrame frame = new JFrame("Property Split"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setContinuousLayout(true); splitPane.setOneTouchExpandable(true); JComponent topComponent = new JButton("A"); splitPane.setTopComponent(topComponent); JComponent bottomComponent = new JButton("B"); splitPane.setBottomComponent(bottomComponent); PropertyChangeListener propertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent changeEvent) { JSplitPane sourceSplitPane = (JSplitPane) changeEvent.getSource(); String propertyName = changeEvent.getPropertyName(); if (propertyName.equals(JSplitPane.LAST_DIVIDER_LOCATION_PROPERTY)) { int current = sourceSplitPane.getDividerLocation(); System.out.println("Current: " + current); Integer last = (Integer) changeEvent.getNewValue(); System.out.println("Last: " + last); Integer priorLast = (Integer) changeEvent.getOldValue(); System.out.println("Prior last: " + priorLast); }/*w w w . j a v a2 s. com*/ } }; splitPane.addPropertyChangeListener(propertyChangeListener); frame.add(splitPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
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:JSplitPaneVerticalSetTopBottom.java
public static void main(String[] a) { JFrame horizontalFrame = new JFrame(); horizontalFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComponent topButton = new JButton("Left"); JComponent bottomButton = new JButton("Right"); final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); HierarchyListener hierarchyListener = new HierarchyListener() { public void hierarchyChanged(HierarchyEvent e) { long flags = e.getChangeFlags(); System.out.println(e.getSource()); if ((flags & HierarchyEvent.SHOWING_CHANGED) == HierarchyEvent.SHOWING_CHANGED) { splitPane.setDividerLocation(.75); }/*from w w w .j av a 2 s .co m*/ } }; splitPane.addHierarchyListener(hierarchyListener); splitPane.setTopComponent(topButton); splitPane.setBottomComponent(bottomButton); horizontalFrame.add(splitPane, BorderLayout.CENTER); horizontalFrame.setSize(150, 150); horizontalFrame.setVisible(true); }
From source file:com.intuit.tank.tools.debugger.PanelBuilder.java
static Component createRightPanel(final AgentDebuggerFrame frame) { JPanel ret = new JPanel(new BorderLayout()); ret.add(BorderLayout.NORTH, new InfoHeaderPanel(frame)); JSplitPane pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true); pane.setTopComponent(new VariablesPanel(frame)); pane.setBottomComponent(frame.getRequestResponsePanel()); pane.setDividerLocation(250);/*from ww w .j a v a 2s . c o m*/ pane.setResizeWeight(0.25D); ret.add(BorderLayout.CENTER, pane); return ret; }