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:gui.accessories.BattleSimFx.java
@Override public void init() { tableModel = new SampleTableModel(); // create javafx panel for charts chartFxPanel = new JFXPanel(); chartFxPanel.setPreferredSize(new Dimension(PANEL_WIDTH_INT, PANEL_HEIGHT_INT)); //JTable// w w w . ja v a 2s. com JTable table = new JTable(tableModel); table.setAutoCreateRowSorter(true); table.setGridColor(Color.DARK_GRAY); BattleSimFx.DecimalFormatRenderer renderer = new BattleSimFx.DecimalFormatRenderer(); renderer.setHorizontalAlignment(JLabel.RIGHT); for (int i = 0; i < table.getColumnCount(); i++) { table.getColumnModel().getColumn(i).setCellRenderer(renderer); } JScrollPane tablePanel = new JScrollPane(table); tablePanel.setPreferredSize(new Dimension(PANEL_WIDTH_INT, TABLE_PANEL_HEIGHT_INT)); JPanel chartTablePanel = new JPanel(); chartTablePanel.setLayout(new BorderLayout()); //Split pane that holds both chart and table JSplitPane jsplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); jsplitPane.setTopComponent(chartTablePanel); jsplitPane.setBottomComponent(tablePanel); jsplitPane.setDividerLocation(410); chartTablePanel.add(chartFxPanel, BorderLayout.CENTER); // add(tablePanel, BorderLayout.CENTER); add(jsplitPane, BorderLayout.CENTER); // create JavaFX scene Platform.runLater(new Runnable() { @Override public void run() { createScene(); } }); }
From source file:components.TreeDemo.java
public TreeDemo() { super(new GridLayout(1, 0)); //Create the nodes. DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series"); createNodes(top);/*from ww w . j a v a 2s . c o m*/ //Create a tree that allows one selection at a time. tree = new JTree(top); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); //Listen for when the selection changes. tree.addTreeSelectionListener(this); if (playWithLineStyle) { System.out.println("line style = " + lineStyle); tree.putClientProperty("JTree.lineStyle", lineStyle); } //Create the scroll pane and add the tree to it. JScrollPane treeView = new JScrollPane(tree); //Create the HTML viewing pane. htmlPane = new JEditorPane(); htmlPane.setEditable(false); initHelp(); JScrollPane htmlView = new JScrollPane(htmlPane); //Add the scroll panes to a split pane. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(treeView); splitPane.setBottomComponent(htmlView); Dimension minimumSize = new Dimension(100, 50); htmlView.setMinimumSize(minimumSize); treeView.setMinimumSize(minimumSize); splitPane.setDividerLocation(100); splitPane.setPreferredSize(new Dimension(500, 300)); //Add the split pane to this panel. add(splitPane); }
From source file:SampleTableModel.java
@Override public void init() { tableModel = new SampleTableModel(); // create javafx panel for charts chartFxPanel = new JFXPanel(); chartFxPanel.setPreferredSize(new Dimension(PANEL_WIDTH_INT, PANEL_HEIGHT_INT)); //JTable// w ww.j a va 2s . c o m JTable table = new JTable(tableModel); table.setAutoCreateRowSorter(true); table.setGridColor(Color.DARK_GRAY); SwingInterop.DecimalFormatRenderer renderer = new SwingInterop.DecimalFormatRenderer(); renderer.setHorizontalAlignment(JLabel.RIGHT); for (int i = 0; i < table.getColumnCount(); i++) { table.getColumnModel().getColumn(i).setCellRenderer(renderer); } JScrollPane tablePanel = new JScrollPane(table); tablePanel.setPreferredSize(new Dimension(PANEL_WIDTH_INT, TABLE_PANEL_HEIGHT_INT)); JPanel chartTablePanel = new JPanel(); chartTablePanel.setLayout(new BorderLayout()); //Split pane that holds both chart and table JSplitPane jsplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); jsplitPane.setTopComponent(chartTablePanel); jsplitPane.setBottomComponent(tablePanel); jsplitPane.setDividerLocation(410); chartTablePanel.add(chartFxPanel, BorderLayout.CENTER); // add(tablePanel, BorderLayout.CENTER); add(jsplitPane, BorderLayout.CENTER); // create JavaFX scene Platform.runLater(new Runnable() { @Override public void run() { createScene(); } }); }
From source file:TreeIconDemo.java
public TreeIconDemo() { super(new GridLayout(1, 0)); // Create the nodes. DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series"); createNodes(top);/*from w ww.j av a2 s . c o m*/ // Create a tree that allows one selection at a time. tree = new JTree(top); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); // Set the icon for leaf nodes. ImageIcon leafIcon = createImageIcon("images/middle.gif"); if (leafIcon != null) { DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer(); renderer.setLeafIcon(leafIcon); tree.setCellRenderer(renderer); } else { System.err.println("Leaf icon missing; using default."); } // Listen for when the selection changes. tree.addTreeSelectionListener(this); // Create the scroll pane and add the tree to it. JScrollPane treeView = new JScrollPane(tree); // Create the HTML viewing pane. htmlPane = new JEditorPane(); htmlPane.setEditable(false); initHelp(); JScrollPane htmlView = new JScrollPane(htmlPane); // Add the scroll panes to a split pane. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(treeView); splitPane.setBottomComponent(htmlView); Dimension minimumSize = new Dimension(100, 50); htmlView.setMinimumSize(minimumSize); treeView.setMinimumSize(minimumSize); splitPane.setDividerLocation(100); // XXX: ignored in some releases // of Swing. bug 4101306 // workaround for bug 4101306: // treeView.setPreferredSize(new Dimension(100, 100)); splitPane.setPreferredSize(new Dimension(500, 300)); // Add the split pane to this panel. add(splitPane); }
From source file:TreeDemo.java
public TreeDemo() { super(new GridLayout(1, 0)); //Create the nodes. DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series"); createNodes(top);// w w w .j a va 2s . co m //Create a tree that allows one selection at a time. tree = new JTree(top); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); //Listen for when the selection changes. tree.addTreeSelectionListener(this); if (playWithLineStyle) { System.out.println("line style = " + lineStyle); tree.putClientProperty("JTree.lineStyle", lineStyle); } //Create the scroll pane and add the tree to it. JScrollPane treeView = new JScrollPane(tree); //Create the HTML viewing pane. htmlPane = new JEditorPane(); htmlPane.setEditable(false); initHelp(); JScrollPane htmlView = new JScrollPane(htmlPane); //Add the scroll panes to a split pane. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(treeView); splitPane.setBottomComponent(htmlView); Dimension minimumSize = new Dimension(100, 50); htmlView.setMinimumSize(minimumSize); treeView.setMinimumSize(minimumSize); splitPane.setDividerLocation(100); //XXX: ignored in some releases //of Swing. bug 4101306 //workaround for bug 4101306: //treeView.setPreferredSize(new Dimension(100, 100)); splitPane.setPreferredSize(new Dimension(500, 300)); //Add the split pane to this panel. add(splitPane); }
From source file:components.TreeIconDemo.java
public TreeIconDemo() { super(new GridLayout(1, 0)); //Create the nodes. DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series"); createNodes(top);/*www . ja v a2s. c o m*/ //Create a tree that allows one selection at a time. tree = new JTree(top); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); //Set the icon for leaf nodes. ImageIcon leafIcon = createImageIcon("images/middle.gif"); if (leafIcon != null) { DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer(); renderer.setLeafIcon(leafIcon); tree.setCellRenderer(renderer); } else { System.err.println("Leaf icon missing; using default."); } //Listen for when the selection changes. tree.addTreeSelectionListener(this); //Create the scroll pane and add the tree to it. JScrollPane treeView = new JScrollPane(tree); //Create the HTML viewing pane. htmlPane = new JEditorPane(); htmlPane.setEditable(false); initHelp(); JScrollPane htmlView = new JScrollPane(htmlPane); //Add the scroll panes to a split pane. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(treeView); splitPane.setBottomComponent(htmlView); Dimension minimumSize = new Dimension(100, 50); htmlView.setMinimumSize(minimumSize); treeView.setMinimumSize(minimumSize); splitPane.setDividerLocation(100); //XXX: ignored in some releases //of Swing. bug 4101306 //workaround for bug 4101306: //treeView.setPreferredSize(new Dimension(100, 100)); splitPane.setPreferredSize(new Dimension(500, 300)); //Add the split pane to this panel. add(splitPane); }
From source file:TreeIconDemo2.java
public TreeIconDemo2() { super(new GridLayout(1, 0)); //Create the nodes. DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series"); createNodes(top);/*from w w w . j a v a 2s .c om*/ //Create a tree that allows one selection at a time. tree = new JTree(top); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); //Enable tool tips. ToolTipManager.sharedInstance().registerComponent(tree); //Set the icon for leaf nodes. ImageIcon tutorialIcon = createImageIcon("images/middle.gif"); if (tutorialIcon != null) { tree.setCellRenderer(new MyRenderer(tutorialIcon)); } else { System.err.println("Tutorial icon missing; using default."); } //Listen for when the selection changes. tree.addTreeSelectionListener(this); //Create the scroll pane and add the tree to it. JScrollPane treeView = new JScrollPane(tree); //Create the HTML viewing pane. htmlPane = new JEditorPane(); htmlPane.setEditable(false); initHelp(); JScrollPane htmlView = new JScrollPane(htmlPane); //Add the scroll panes to a split pane. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(treeView); splitPane.setBottomComponent(htmlView); Dimension minimumSize = new Dimension(100, 50); htmlView.setMinimumSize(minimumSize); treeView.setMinimumSize(minimumSize); splitPane.setDividerLocation(100); //XXX: ignored in some releases //of Swing. bug 4101306 //workaround for bug 4101306: //treeView.setPreferredSize(new Dimension(100, 100)); splitPane.setPreferredSize(new Dimension(500, 300)); //Add the split pane to this panel. add(splitPane); }
From source file:i18nplugin.TranslatorEditor.java
private void createGui() { setLayout(new FormLayout("fill:min:grow", "fill:min:grow, pref")); CellConstraints cc = new CellConstraints(); // Top// w w w. j a v a2 s. c o m PanelBuilder topPanel = new PanelBuilder(new FormLayout("fill:10dlu:grow", "pref, 5dlu, fill:pref:grow")); topPanel.setBorder(Borders.DLU4_BORDER); topPanel.addSeparator(mLocalizer.msg("original", "Original text"), cc.xy(1, 1)); mOriginal = new JTextArea(); mOriginal.setWrapStyleWord(false); mOriginal.setEditable(false); topPanel.add(new JScrollPane(mOriginal), cc.xy(1, 3)); // Bottom PanelBuilder bottomPanel = new PanelBuilder( new FormLayout("fill:10dlu:grow", "pref, 5dlu, fill:pref:grow")); bottomPanel.setBorder(Borders.DLU4_BORDER); bottomPanel.addSeparator(mLocalizer.msg("translation", "Translation"), cc.xy(1, 1)); mTranslation = new JTextArea(); mTranslation.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { updateState(); } public void insertUpdate(DocumentEvent e) { updateState(); } public void removeUpdate(DocumentEvent e) { updateState(); } }); mOriginal.setBackground(mTranslation.getBackground()); mOriginal.setForeground(mTranslation.getForeground()); bottomPanel.add(new JScrollPane(mTranslation), cc.xy(1, 3)); // Splitpane final JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split.setBorder(null); split.setTopComponent(topPanel.getPanel()); split.setBottomComponent(bottomPanel.getPanel()); SwingUtilities.invokeLater(new Runnable() { public void run() { split.setDividerLocation(0.5); } }); add(split, cc.xy(1, 1)); // translation state PanelBuilder panel = new PanelBuilder(new FormLayout("pref, 2dlu, fill:10dlu:grow", "pref, 3dlu, pref")); panel.setBorder(Borders.DLU4_BORDER); panel.addSeparator(mLocalizer.msg("state", "State"), cc.xyw(1, 1, 3)); mIcon = new JLabel(); panel.add(mIcon, cc.xy(1, 3)); mState = new JLabel("-"); panel.add(mState, cc.xy(3, 3)); add(panel.getPanel(), cc.xy(1, 2)); }
From source file:test.integ.be.fedict.performance.util.PerformanceResultDialog.java
public PerformanceResultDialog(PerformanceResultsData data) { super((Frame) null, "Performance test results"); setSize(1000, 800);/* w w w .java2 s . c o m*/ JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); JMenuItem savePerformanceMenuItem = new JMenuItem("Save Performance"); fileMenu.add(savePerformanceMenuItem); savePerformanceMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Save as PNG..."); int result = fileChooser.showSaveDialog(PerformanceResultDialog.this); if (JFileChooser.APPROVE_OPTION == result) { File file = fileChooser.getSelectedFile(); try { ChartUtilities.saveChartAsPNG(file, performanceChart, 1024, 768); } catch (IOException e) { JOptionPane.showMessageDialog(null, "error saving to file: " + e.getMessage()); } } } }); JMenuItem saveMemoryMenuItem = new JMenuItem("Save Memory"); fileMenu.add(saveMemoryMenuItem); saveMemoryMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Save as PNG..."); int result = fileChooser.showSaveDialog(PerformanceResultDialog.this); if (JFileChooser.APPROVE_OPTION == result) { File file = fileChooser.getSelectedFile(); try { ChartUtilities.saveChartAsPNG(file, memoryChart, 1024, 768); } catch (IOException e) { JOptionPane.showMessageDialog(null, "error saving to file: " + e.getMessage()); } } } }); // memory chart memoryChart = getMemoryChart(data.getIntervalSize(), data.getMemory()); // performance chart performanceChart = getPerformanceChart(data.getIntervalSize(), data.getPerformance(), data.getExpectedRevokedCount()); Container container = getContentPane(); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); if (null != performanceChart) { splitPane.setTopComponent(new ChartPanel(performanceChart)); } if (null != memoryChart) { splitPane.setBottomComponent(new ChartPanel(memoryChart)); } splitPane.setDividerLocation(getHeight() / 2); splitPane.setDividerSize(1); container.add(splitPane); setVisible(true); }
From source file:Main.java
public Main() { setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(400, 400);/*from w ww .ja v a 2 s. c om*/ JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split.setDividerLocation(200); add(split); JPanel panel1 = new JPanel(); panel1.setLayout(new BorderLayout()); panel1.add(new JLabel("top panel"), BorderLayout.NORTH); JPanel myDrawPanel = new JPanel(); myDrawPanel.setPreferredSize(new Dimension(100, 100)); myDrawPanel.add(new JLabel("draw panel here!")); panel1.add(new JScrollPane(myDrawPanel), BorderLayout.CENTER); split.setTopComponent(panel1); JPanel panel2 = new JPanel(); panel2.add(new JLabel("bottom panel")); split.setBottomComponent(panel2); setVisible(true); }