List of usage examples for javax.swing JSplitPane JSplitPane
@ConstructorProperties({ "orientation" }) public JSplitPane(int newOrientation)
JSplitPane
configured with the specified orientation. 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);/*ww w. ja v a 2s . c om*/ 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:Main.java
public static void main(String[] argv) { DefaultTableModel model = new DefaultTableModel(); JTable table1 = new JTable(model); JTable table2 = new JTable(model); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPane.add(new JScrollPane(table1)); splitPane.add(new JScrollPane(table2)); table1.getColumnModel().removeColumn(table1.getColumnModel().getColumn(0)); }
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);//from w w w . j a v a2 s . co m 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.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); }//from 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:Main.java
public static void main(String[] a) { JFrame horizontalFrame = new JFrame(); horizontalFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComponent leftButton = new JButton("Left"); JComponent rightButton = new JButton("Right"); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setLeftComponent(leftButton); splitPane.setRightComponent(rightButton); horizontalFrame.add(splitPane, BorderLayout.CENTER); horizontalFrame.setSize(150, 150);//from w ww . j a v a2 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);/*from w ww . j ava 2 s . c om*/ horizontalFrame.setVisible(true); splitPane.setDividerLocation(0.5); }
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);/*from w w w .j a v a2 s. c om*/ horizontalFrame.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. ja va 2s .c o m*/ } }; splitPane.addPropertyChangeListener(propertyChangeListener); frame.add(splitPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:VerticalSplit.java
public static void main(String args[]) { JFrame vFrame = new JFrame("Vertical Split"); vFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComponent leftButton = new JButton("Left"); JComponent rightButton = new JButton("Right"); final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setOneTouchExpandable(true); splitPane.setLeftComponent(leftButton); splitPane.setRightComponent(rightButton); ActionListener oneActionListener = new ActionListener() { public void actionPerformed(ActionEvent event) { splitPane.resetToPreferredSizes(); }//from www .j a va 2s . c om }; ((JButton) rightButton).addActionListener(oneActionListener); ActionListener anotherActionListener = new ActionListener() { public void actionPerformed(ActionEvent event) { splitPane.setDividerLocation(10); splitPane.setContinuousLayout(true); } }; ((JButton) leftButton).addActionListener(anotherActionListener); vFrame.getContentPane().add(splitPane, BorderLayout.CENTER); vFrame.setSize(300, 150); vFrame.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. java2s. 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); }