List of usage examples for javax.swing JSplitPane setDividerLocation
@BeanProperty(description = "The location of the divider.") public void setDividerLocation(int location)
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("SplitPaneFrame"); JLabel leftImage = new JLabel(new ImageIcon("a.gif")); Component left = new JScrollPane(leftImage); JLabel rightImage = new JLabel(new ImageIcon("b.gif")); Component right = new JScrollPane(rightImage); JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, right); split.setDividerLocation(100); frame.getContentPane().add(split);/*from www. j av a 2s. com*/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { int HORIZSPLIT = JSplitPane.HORIZONTAL_SPLIT; int VERTSPLIT = JSplitPane.VERTICAL_SPLIT; boolean continuousLayout = true; JLabel label1 = new JLabel("a"); JLabel label2 = new JLabel("b"); JLabel label3 = new JLabel("c"); JSplitPane splitPane1 = new JSplitPane(VERTSPLIT, continuousLayout, label1, label2); splitPane1.setOneTouchExpandable(true); splitPane1.setDividerSize(2);/*from w ww.j a v a2s . co m*/ splitPane1.setDividerLocation(0.5); JSplitPane splitPane2 = new JSplitPane(HORIZSPLIT, splitPane1, label3); splitPane2.setOneTouchExpandable(true); splitPane2.setDividerLocation(0.4); splitPane2.setDividerSize(2); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(splitPane2); frame.pack(); frame.setVisible(true); }
From source file:NestedJSplitPane.java
public static void main(String[] a) { int HORIZSPLIT = JSplitPane.HORIZONTAL_SPLIT; int VERTSPLIT = JSplitPane.VERTICAL_SPLIT; boolean continuousLayout = true; JLabel label1 = new JLabel("a"); JLabel label2 = new JLabel("b"); JLabel label3 = new JLabel("c"); JSplitPane splitPane1 = new JSplitPane(VERTSPLIT, continuousLayout, label1, label2); splitPane1.setOneTouchExpandable(true); splitPane1.setDividerSize(2);/*from w ww . j av a 2 s. c om*/ splitPane1.setDividerLocation(0.5); JSplitPane splitPane2 = new JSplitPane(HORIZSPLIT, splitPane1, label3); splitPane2.setOneTouchExpandable(true); splitPane2.setDividerLocation(0.4); splitPane2.setDividerSize(2); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(splitPane2); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Use TextAction"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JTextArea leftArea = new JTextArea(); final JTextArea rightArea = new JTextArea(); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(leftArea), new JScrollPane(rightArea)); splitPane.setDividerLocation(.5); JMenuBar menuBar = new JMenuBar(); frame.setJMenuBar(menuBar);//from w w w . ja v a 2 s. c o m JMenu menu = new JMenu("Options"); menuBar.add(menu); JMenuItem menuItem; Action readAction = leftArea.getActionMap().get(DefaultEditorKit.readOnlyAction); menuItem = menu.add(readAction); menuItem.setText("Make read-only"); Action writeAction = leftArea.getActionMap().get(DefaultEditorKit.writableAction); menuItem = menu.add(writeAction); menuItem.setText("Make writable"); menu.addSeparator(); Action cutAction = leftArea.getActionMap().get(DefaultEditorKit.cutAction); menuItem = menu.add(cutAction); menuItem.setText("Cut"); Action copyAction = leftArea.getActionMap().get(DefaultEditorKit.copyAction); menuItem = menu.add(copyAction); menuItem.setText("Copy"); Action pasteAction = leftArea.getActionMap().get(DefaultEditorKit.pasteAction); menuItem = menu.add(pasteAction); menuItem.setText("Paste"); frame.add(splitPane, BorderLayout.CENTER); frame.setSize(400, 250); 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"); JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftComponent, rightComponent); int loc = pane.getDividerLocation(); loc = (int) ((pane.getBounds().getWidth() - pane.getDividerSize()) / 2); pane.setDividerLocation(loc); double propLoc = .5D; pane.setDividerLocation(propLoc);/*from w w w . j a v a2 s . com*/ }
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);//w w w . jav a 2s. co m horizontalFrame.setVisible(true); splitPane.setDividerLocation(0.5); }
From source file:ws.moor.bt.grapher.Grapher.java
public static void main(String[] args) throws IOException { if (args.length != 1) { System.err.println("Please specify a tab-separated values file"); System.exit(1);/*from ww w . j av a 2 s.co m*/ } File file = new File(args[0]); final CSVMapCollector collector = new CSVMapCollector( new CSVSkipFilter(new CSVInputStream(new FileInputStream(file)), 0 * 1000)); JFrame window = new JFrame("Grapher"); window.setSize(1100, 800); window.setLayout(new BorderLayout()); final ChartPanel chartPanel = new ChartPanel(null); List<String> possibleNames = collector.getAvailableStreams(); Collections.sort(possibleNames); TreeNode root = convertToTree(possibleNames); final JTree tree = new JTree(root); tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { List<String> names = new ArrayList<String>(); final TreePath[] paths = tree.getSelectionModel().getSelectionPaths(); if (paths == null) { chartPanel.setChart(null); return; } for (TreePath path : paths) { Object lastPath = path.getLastPathComponent(); if (lastPath instanceof DefaultMutableTreeNode) { Object value = ((DefaultMutableTreeNode) lastPath).getUserObject(); if (value instanceof NodeValue) { names.add(value.toString()); } } } chartPanel.setChart(createChart(collector, names.toArray(new String[names.size()]))); } }); Font font = tree.getFont(); tree.setFont(font.deriveFont(10.0f)); JScrollPane scrollPane = new JScrollPane(tree); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPane.setLeftComponent(scrollPane); splitPane.setRightComponent(chartPanel); splitPane.setDividerLocation(200); window.setContentPane(splitPane); window.setVisible(true); }
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 ww . ja v 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: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 w w w . ja v a 2s .co m*/ }; ((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:ExpandableSplit.java
public static void main(String args[]) { String title = (args.length == 0 ? "Expandable Split" : args[0]); JFrame vFrame = new JFrame(title); vFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComponent leftButton = new JButton("Top"); JComponent rightButton = new JButton("Bottom"); 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 w ww. j av a 2 s .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); }