List of usage examples for javax.swing JSplitPane setRightComponent
@BeanProperty(bound = false, preferred = true, description = "The component to the right (or below) the divider.") public void setRightComponent(Component comp)
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 ava2s . c om 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(); }//www . j av a2s . com }; ((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 w w . j a 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:MainClass.java
public static void main(String args[]) throws Exception { 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 av a 2 s.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); HierarchyListener hierarchyListener = new HierarchyListener() { public void hierarchyChanged(HierarchyEvent e) { long flags = e.getChangeFlags(); if ((flags & HierarchyEvent.SHOWING_CHANGED) == HierarchyEvent.SHOWING_CHANGED) { splitPane.setDividerLocation(.75); } } }; splitPane.addHierarchyListener(hierarchyListener); vFrame.add(splitPane, BorderLayout.CENTER); vFrame.setSize(300, 150); vFrame.setVisible(true); }
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);//w w w . j a v a2s . c o 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: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:com.joey.software.Tools.AScanViewerTool.java
public void createJPanel() { JSplitPane graphSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT); graphSplit.setLeftComponent(previewPanel); graphSplit.setRightComponent(dataPanel); graphSplit.setOneTouchExpandable(true); graphSplit.setDividerLocation(400);/*from w ww .ja va 2s . com*/ JPanel graphHolder = new JPanel(new BorderLayout()); graphHolder.add(graphSplit, BorderLayout.CENTER); graphHolder.setBorder(BorderFactory.createTitledBorder("")); JPanel tool = new JPanel(new BorderLayout()); tool.add(saveCSVData, BorderLayout.SOUTH); tool.add(aScanType, BorderLayout.CENTER); JPanel leftPanel = new JPanel(new BorderLayout()); leftPanel.add(graphHolder, BorderLayout.CENTER); leftPanel.add(tool, BorderLayout.SOUTH); JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); split.setOneTouchExpandable(true); split.setRightComponent(imageViewPanel); split.setLeftComponent(leftPanel); split.setDividerLocation(600); JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(split, BorderLayout.CENTER); getContentPane().setLayout(new BorderLayout()); getContentPane().add(mainPanel); aScanType.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { imageViewPanel.setViewType(aScanType.getSelectedIndex()); } }); saveCSVData.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { File f = FileSelectionField.getUserFile(); f = FileOperations.renameFileType(f, "csv"); saveAScanData(f); } catch (Exception e1) { JOptionPane.showMessageDialog(null, "Error : " + e1.getLocalizedMessage(), "Error Saving Data", JOptionPane.ERROR_MESSAGE); e1.printStackTrace(); } } }); }
From source file:gui.TwopointPWDPanel.java
private JPanel createControls() { // Marker model (for ordered list of markers) markerModel = new PWDTableModel(); // Populate the marker table markerTable = new JTable(markerModel); markerTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); markerTable.getColumnModel().getColumn(1).setPreferredWidth(175); markerTable.getColumnModel().getColumn(2).setPreferredWidth(60); for (CMarker cm : order.getLinkageGroup().getMarkers()) { markerModel.addRow(new Object[] { cm.marker.getPrefix(), cm, cm.marker.getRatio() }); }/*from ww w .j a v a2 s . com*/ markerTable.getSelectionModel().addListSelectionListener(this); // Phase model (for scores of each ordered marker against the others) phaseModel = new PWDTableModel2(); phaseModel.setColumnIdentifiers(new Object[] { "Graph Code", "Marker Name", "Recom Freq", "LOD Score" }); phaseTable = new JTable(phaseModel); phaseTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); phaseTable.getSelectionModel().addListSelectionListener(this); rfqChart = new PWDChartPanel("Recombination Freq"); lodChart = new PWDChartPanel("LOD Score"); m1Label = new JLabel(""); m1Label.setFont(new Font("Monospaced", Font.PLAIN, 11)); m2Label = new JLabel(""); m2Label.setFont(new Font("Monospaced", Font.PLAIN, 11)); JScrollPane mSP = new JScrollPane(markerTable); mSP.setPreferredSize(new Dimension(300, 10)); JPanel p1 = new JPanel(new BorderLayout(5, 0)); p1.add(new JLabel("Ordered Markers:"), BorderLayout.NORTH); p1.add(mSP); JPanel p2 = new JPanel(new BorderLayout(5, 0)); p2.add(new JLabel("Scores:"), BorderLayout.NORTH); p2.add(new JScrollPane(phaseTable)); JPanel p3 = new JPanel(new GridLayout(2, 1, 2, 2)); p3.setBorder(BorderFactory.createLoweredBevelBorder()); p3.add(m1Label); p3.add(m2Label); JPanel p4 = new JPanel(new GridLayout(1, 2, 5, 5)); p4.add(rfqChart); p4.add(lodChart); JPanel p5 = new JPanel(new BorderLayout(5, 5)); p5.add(p3, BorderLayout.NORTH); p5.add(p4, BorderLayout.CENTER); JSplitPane splits = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splits.setResizeWeight(0.5); splits.setLeftComponent(p1); splits.setRightComponent(p2); JPanel p6 = new JPanel(new BorderLayout(5, 5)); p6.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); p6.add(splits); p6.add(p5, BorderLayout.SOUTH); return p6; }
From source file:gui.TwopointPWDPanelnonsnp.java
private JPanel createControls() { // Marker model (for ordered list of markers) markerModel = new PWDTableModel(); // Populate the marker table markerTable = new JTable(markerModel); markerTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); markerTable.getColumnModel().getColumn(0).setPreferredWidth(60); markerTable.getColumnModel().getColumn(1).setPreferredWidth(130); markerTable.getColumnModel().getColumn(2).setPreferredWidth(50);// ratio markerTable.getColumnModel().getColumn(3).setPreferredWidth(70);// geno markerTable.getColumnModel().getColumn(4).setPreferredWidth(50);// p1 markerTable.getColumnModel().getColumn(5).setPreferredWidth(50);// p2 for (CMarker cm : order.getLinkageGroup().getMarkers()) { markerModel.addRow(new Object[] { cm.marker.getPrefix(), cm, cm.marker.getRatio(), cm.marker.getRatioGenotypes(), "0000", "0000" }); }//from w w w . j a v a2 s . co m markerTable.getSelectionModel().addListSelectionListener(this); if (order.rows != null) { int row = 0; for (String[] data : order.rows) { for (int i = 0; i < 2; i++) { markerModel.setValueAt(data[i], row, i + 4); } row++; } } else { order.rows = getSelection(); } // Phase model (for scores of each ordered marker against the others) phaseModel = new PWDTableModel2(); phaseModel.setColumnIdentifiers(new Object[] { "Graph Code", "Marker Name", "Recom Freq", "LOD Score" }); phaseTable = new JTable(phaseModel); phaseTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); phaseTable.getSelectionModel().addListSelectionListener(this); rfqChart = new PWDChartPanel("Recombination Freq"); lodChart = new PWDChartPanel("LOD Score"); m1Label = new JLabel(""); m1Label.setFont(new Font("Monospaced", Font.PLAIN, 11)); m2Label = new JLabel(""); m2Label.setFont(new Font("Monospaced", Font.PLAIN, 11)); JScrollPane mSP = new JScrollPane(markerTable); mSP.setPreferredSize(new Dimension(300, 10)); JPanel p1 = new JPanel(new BorderLayout(5, 0)); p1.add(new JLabel("Ordered Markers:"), BorderLayout.NORTH); p1.add(mSP); JPanel p2 = new JPanel(new BorderLayout(5, 0)); p2.add(new JLabel("Scores:"), BorderLayout.NORTH); p2.add(new JScrollPane(phaseTable)); JPanel p3 = new JPanel(new GridLayout(2, 1, 2, 2)); p3.setBorder(BorderFactory.createLoweredBevelBorder()); p3.add(m1Label); p3.add(m2Label); JPanel p4 = new JPanel(new GridLayout(1, 2, 5, 5)); p4.add(rfqChart); p4.add(lodChart); JPanel p5 = new JPanel(new BorderLayout(5, 5)); p5.add(p3, BorderLayout.NORTH); p5.add(p4, BorderLayout.CENTER); JSplitPane splits = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splits.setResizeWeight(0.5); splits.setLeftComponent(p1); splits.setRightComponent(p2); JPanel p6 = new JPanel(new BorderLayout(5, 5)); p6.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); p6.add(splits); p6.add(p5, BorderLayout.SOUTH); return p6; }
From source file:fi.smaa.jsmaa.gui.JSMAAMainFrame.java
private void rebuildGUI() { JSplitPane splitPane = new JSplitPane(); splitPane.setResizeWeight(0.1);/*from www. j a v a 2 s . co m*/ splitPane.setDividerSize(2); splitPane.setDividerLocation(-1); rightPane = new JScrollPane(); rightPane.getVerticalScrollBar().setUnitIncrement(16); splitPane.setRightComponent(rightPane); JScrollPane leftScrollPane = new JScrollPane(); leftScrollPane.setViewportView(guiFactory.getTree()); splitPane.setLeftComponent(leftScrollPane); getContentPane().removeAll(); getContentPane().setLayout(new BorderLayout()); getContentPane().add("Center", splitPane); getContentPane().add("North", guiFactory.getTopToolBar()); getContentPane().add("South", guiFactory.getBottomToolBar()); setJMenuBar(guiFactory.getMenuBar()); guiFactory.getTree().addTreeSelectionListener(new LeftTreeSelectionListener()); pack(); }