List of usage examples for javax.swing JSplitPane setDividerSize
@BeanProperty(description = "The size of the divider.") public void setDividerSize(int newSize)
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 size = pane.getDividerSize(); size = 1;//from w w w . j a v a2 s. com pane.setDividerSize(size); }
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); splitPane1.setDividerLocation(0.5);/*from w w w. ja va 2 s .co m*/ 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); splitPane1.setDividerLocation(0.5);/*from w w w. j a v a 2 s .co m*/ 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:SplitSample.java
public SplitSample() { super("Simple Split Pane"); setSize(400, 400);//from w w w . j a v a 2 s . c o m getContentPane().setLayout(new BorderLayout()); JSplitPane spLeft = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JPanel(), new JPanel()); spLeft.setDividerSize(8); spLeft.setContinuousLayout(true); JSplitPane spRight = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JPanel(), new JPanel()); spRight.setDividerSize(8); spRight.setContinuousLayout(true); split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, spLeft, spRight); split.setContinuousLayout(false); split.setOneTouchExpandable(true); getContentPane().add(split, BorderLayout.CENTER); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:com.choicemaker.cm.modelmaker.gui.panels.AsymmetricThresholdVsAccuracyPlotPanel.java
private void layoutPanel() { setLayout(new BorderLayout()); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPane.setDividerSize(2); splitPane.setContinuousLayout(true); splitPane.setDividerLocation(0.5d);/*from w w w . jav a 2s. c o m*/ splitPane.setResizeWeight(0.5f); splitPane.setOneTouchExpandable(true); ChartPanel dP = new ChartPanel(dPlot, false, false, false, true, true); // dP.setHorizontalZoom(true); // dP.setVerticalZoom(true); splitPane.setTopComponent(dP); ChartPanel mP = new ChartPanel(mPlot, false, false, false, true, true); // mP.setHorizontalZoom(true); // mP.setVerticalZoom(true); splitPane.setBottomComponent(mP); add(splitPane, BorderLayout.CENTER); }
From source file:com.choicemaker.cm.modelmaker.gui.panels.HoldVsAccuracyPlotPanel.java
private void layoutPanel() { GridBagLayout layout = new GridBagLayout(); setLayout(layout);// ww w. ja va 2 s . com layout.columnWeights = new double[] { 1f, 0f }; layout.columnWidths = new int[] { 200, 300 }; GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(2, 2, 5, 10); //Row 0.......................................................... //histo c.gridy = 0; c.gridx = 0; c.gridwidth = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; ChartPanel p = new ChartPanel(chart, false, false, false, true, true); // p.setHorizontalZoom(true); // p.setVerticalZoom(true); add(p, c); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setDividerSize(2); splitPane.setContinuousLayout(true); splitPane.setDividerLocation(0.5d); splitPane.setResizeWeight(0.5f); splitPane.setOneTouchExpandable(true); splitPane.setTopComponent(accuracyPanel); splitPane.setBottomComponent(hrPanel); c.gridx = 1; c.gridheight = 1; add(splitPane, c); }
From source file:fi.smaa.jsmaa.gui.JSMAAMainFrame.java
private void rebuildGUI() { JSplitPane splitPane = new JSplitPane(); splitPane.setResizeWeight(0.1);//w ww .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(); }
From source file:com.qspin.qtaste.ui.MainPanel.java
public void genUI() { try {/*w w w . j a v a 2 s . co m*/ getContentPane().setLayout(new BorderLayout()); // prepare the top panel that contains the following panes: // - logo // - ConfigInfopanel // - Current Date/time JPanel topanel = new JPanel(new BorderLayout()); JPanel center = new JPanel(new GridBagLayout()); ImageIcon topLeftLogo = ResourceManager.getInstance().getImageIcon("main/qspin"); JLabel iconlabel = new JLabel(topLeftLogo); mHeaderPanel = new ConfigInfoPanel(this); mTestCasePanel = new TestCasePane(this); mTestCampaignPanel = new TestCampaignMainPanel(this); mHeaderPanel.init(); GridBagLineAdder centeradder = new GridBagLineAdder(center); JLabel sep = new JLabel(" "); sep.setFont(ResourceManager.getInstance().getSmallFont()); sep.setUI(new FillLabelUI(ResourceManager.getInstance().getLightColor())); centeradder.setWeight(1.0f, 0.0f); centeradder.add(mHeaderPanel); // prepare the right panels containg the main information: // the right pane is selected through the tabbed pane: // - Test cases: management of test cases and test suites // - Test campaign: management of test campaigns // - Interactive: ability to invoke QTaste verbs one by one mRightPanels = new JPanel(new CardLayout()); mRightPanels.add(mTestCasePanel, "Test Cases"); mRightPanels.add(mTestCampaignPanel, "Test Campaign"); final TestCaseInteractivePanel testInterractivePanel = new TestCaseInteractivePanel(); mRightPanels.add(testInterractivePanel, "Interactive"); mTreeTabsPanel = new JTabbedPane(JTabbedPane.BOTTOM); mTreeTabsPanel.setPreferredSize(new Dimension(TREE_TABS_WIDTH, HEIGHT)); TestCaseTree tct = new TestCaseTree(mTestCasePanel); JScrollPane sp2 = new JScrollPane(tct); mTreeTabsPanel.addTab("Test Cases", sp2); // add tree view for test campaign definition com.qspin.qtaste.ui.testcampaign.TestCaseTree mtct = new com.qspin.qtaste.ui.testcampaign.TestCaseTree( mTestCampaignPanel.getTreeTable()); JScrollPane sp3 = new JScrollPane(mtct); mTreeTabsPanel.addTab("Test Campaign", sp3); genMenu(tct); // add another tab contain used for Interactive mode TestAPIDocsTree jInteractive = new TestAPIDocsTree(testInterractivePanel); JScrollPane spInter = new JScrollPane(jInteractive); mTreeTabsPanel.addTab("Interactive", spInter); // init will do the link between the tree view and the pane testInterractivePanel.init(); // Define the listener to display the pane depending on the selected tab mTreeTabsPanel.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { String componentName = mTreeTabsPanel.getTitleAt(mTreeTabsPanel.getSelectedIndex()); CardLayout rcl = (CardLayout) mRightPanels.getLayout(); rcl.show(mRightPanels, componentName); } }); mTestCampaignPanel.addTestCampaignActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getID() == TestCampaignMainPanel.RUN_ID) { if (e.getActionCommand().equals(TestCampaignMainPanel.STARTED_CMD)) { // open the tab test cases SwingUtilities.invokeLater(new Runnable() { public void run() { mTreeTabsPanel.setSelectedIndex(0); mTestCasePanel.setSelectedTab(TestCasePane.RESULTS_INDEX); } }); // update the buttons mTestCasePanel.setExecutingTestCampaign(true, ((TestCampaignMainPanel) e.getSource()).getExecutionThread()); mTestCasePanel.updateButtons(true); } else if (e.getActionCommand().equals(TestCampaignMainPanel.STOPPED_CMD)) { mTestCasePanel.setExecutingTestCampaign(false, null); mTestCasePanel.updateButtons(); } } } }); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mTreeTabsPanel, mRightPanels); splitPane.setDividerSize(4); GUIConfiguration guiConfiguration = GUIConfiguration.getInstance(); int mainHorizontalSplitDividerLocation = guiConfiguration .getInt(MAIN_HORIZONTAL_SPLIT_DIVIDER_LOCATION_PROPERTY, 285); splitPane.setDividerLocation(mainHorizontalSplitDividerLocation); splitPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("dividerLocation")) { GUIConfiguration guiConfiguration = GUIConfiguration.getInstance(); if (evt.getSource() instanceof JSplitPane) { JSplitPane splitPane = (JSplitPane) evt.getSource(); guiConfiguration.setProperty(MAIN_HORIZONTAL_SPLIT_DIVIDER_LOCATION_PROPERTY, splitPane.getDividerLocation()); try { guiConfiguration.save(); } catch (ConfigurationException ex) { logger.error("Error while saving GUI configuration: " + ex.getMessage()); } } } } }); topanel.add(iconlabel, BorderLayout.WEST); topanel.add(center); getContentPane().add(topanel, BorderLayout.NORTH); getContentPane().add(splitPane); this.pack(); this.setExtendedState(Frame.MAXIMIZED_BOTH); if (mTestSuiteDir != null) { DirectoryTestSuite testSuite = DirectoryTestSuite.createDirectoryTestSuite(mTestSuiteDir); if (testSuite != null) { testSuite.setExecutionLoops(mNumberLoops, mLoopsInHour); setTestSuite(testSuite.getName()); mTestCasePanel.runTestSuite(testSuite, false); } } setVisible(true); //treeTabs.setMinimumSize(new Dimension(100, this.HEIGHT)); } catch (Exception e) { logger.fatal(e); e.printStackTrace(); TestEngine.shutdown(); System.exit(1); } }
From source file:test.integ.be.fedict.performance.util.PerformanceResultDialog.java
public PerformanceResultDialog(PerformanceResultsData data) { super((Frame) null, "Performance test results"); setSize(1000, 800);//from w ww . jav a 2s . 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:com.net2plan.gui.tools.GUINetworkDesign.java
@Override public void configure(JPanel contentPane) { this.currentNetPlan = new NetPlan(); BidiMap<NetworkLayer, Integer> mapLayer2VisualizationOrder = new DualHashBidiMap<>(); Map<NetworkLayer, Boolean> layerVisibilityMap = new HashMap<>(); for (NetworkLayer layer : currentNetPlan.getNetworkLayers()) { mapLayer2VisualizationOrder.put(layer, mapLayer2VisualizationOrder.size()); layerVisibilityMap.put(layer, true); }/*from w w w . ja va2 s . co m*/ this.vs = new VisualizationState(currentNetPlan, mapLayer2VisualizationOrder, layerVisibilityMap, MAXSIZEUNDOLISTPICK); topologyPanel = new TopologyPanel(this, JUNGCanvas.class); JPanel leftPane = new JPanel(new BorderLayout()); JPanel logSection = configureLeftBottomPanel(); if (logSection == null) { leftPane.add(topologyPanel, BorderLayout.CENTER); } else { JSplitPane splitPaneTopology = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPaneTopology.setTopComponent(topologyPanel); splitPaneTopology.setBottomComponent(logSection); splitPaneTopology.addPropertyChangeListener(new ProportionalResizeJSplitPaneListener()); splitPaneTopology.setBorder(new LineBorder(contentPane.getBackground())); splitPaneTopology.setOneTouchExpandable(true); splitPaneTopology.setDividerSize(7); leftPane.add(splitPaneTopology, BorderLayout.CENTER); } contentPane.add(leftPane, "grow"); viewEditTopTables = new ViewEditTopologyTablesPane(GUINetworkDesign.this, new BorderLayout()); reportPane = new ViewReportPane(GUINetworkDesign.this, JSplitPane.VERTICAL_SPLIT); setCurrentNetPlanDoNotUpdateVisualization(currentNetPlan); Pair<BidiMap<NetworkLayer, Integer>, Map<NetworkLayer, Boolean>> res = VisualizationState .generateCanvasDefaultVisualizationLayerInfo(getDesign()); vs.setCanvasLayerVisibilityAndOrder(getDesign(), res.getFirst(), res.getSecond()); /* Initialize the undo/redo manager, and set its initial design */ this.undoRedoManager = new UndoRedoManager(this, MAXSIZEUNDOLISTCHANGES); this.undoRedoManager.addNetPlanChange(); onlineSimulationPane = new OnlineSimulationPane(this); executionPane = new OfflineExecutionPanel(this); whatIfAnalysisPane = new WhatIfAnalysisPane(this); // Closing windows WindowUtils.clearFloatingWindows(); final JTabbedPane tabPane = new JTabbedPane(); tabPane.add(WindowController.WindowToTab.getTabName(WindowController.WindowToTab.network), viewEditTopTables); tabPane.add(WindowController.WindowToTab.getTabName(WindowController.WindowToTab.offline), executionPane); tabPane.add(WindowController.WindowToTab.getTabName(WindowController.WindowToTab.online), onlineSimulationPane); tabPane.add(WindowController.WindowToTab.getTabName(WindowController.WindowToTab.whatif), whatIfAnalysisPane); tabPane.add(WindowController.WindowToTab.getTabName(WindowController.WindowToTab.report), reportPane); // Installing customized mouse listener MouseListener[] ml = tabPane.getListeners(MouseListener.class); for (int i = 0; i < ml.length; i++) { tabPane.removeMouseListener(ml[i]); } // Left click works as usual, right click brings up a pop-up menu. tabPane.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { JTabbedPane tabPane = (JTabbedPane) e.getSource(); int tabIndex = tabPane.getUI().tabForCoordinate(tabPane, e.getX(), e.getY()); if (tabIndex >= 0 && tabPane.isEnabledAt(tabIndex)) { if (tabIndex == tabPane.getSelectedIndex()) { if (tabPane.isRequestFocusEnabled()) { tabPane.requestFocus(); tabPane.repaint(tabPane.getUI().getTabBounds(tabPane, tabIndex)); } } else { tabPane.setSelectedIndex(tabIndex); } if (!tabPane.isEnabled() || SwingUtilities.isRightMouseButton(e)) { final JPopupMenu popupMenu = new JPopupMenu(); final JMenuItem popWindow = new JMenuItem("Pop window out"); popWindow.addActionListener(e1 -> { final int selectedIndex = tabPane.getSelectedIndex(); final String tabName = tabPane.getTitleAt(selectedIndex); final JComponent selectedComponent = (JComponent) tabPane.getSelectedComponent(); // Pops up the selected tab. final WindowController.WindowToTab windowToTab = WindowController.WindowToTab .parseString(tabName); if (windowToTab != null) { switch (windowToTab) { case offline: WindowController.buildOfflineWindow(selectedComponent); WindowController.showOfflineWindow(true); break; case online: WindowController.buildOnlineWindow(selectedComponent); WindowController.showOnlineWindow(true); break; case whatif: WindowController.buildWhatifWindow(selectedComponent); WindowController.showWhatifWindow(true); break; case report: WindowController.buildReportWindow(selectedComponent); WindowController.showReportWindow(true); break; default: return; } } tabPane.setSelectedIndex(0); }); // Disabling the pop up button for the network state tab. if (WindowController.WindowToTab.parseString(tabPane .getTitleAt(tabPane.getSelectedIndex())) == WindowController.WindowToTab.network) { popWindow.setEnabled(false); } popupMenu.add(popWindow); popupMenu.show(e.getComponent(), e.getX(), e.getY()); } } } }); // Building windows WindowController.buildTableControlWindow(tabPane); WindowController.showTablesWindow(false); addAllKeyCombinationActions(); updateVisualizationAfterNewTopology(); }