Example usage for javax.swing JSplitPane setDividerLocation

List of usage examples for javax.swing JSplitPane setDividerLocation

Introduction

In this page you can find the example usage for javax.swing JSplitPane setDividerLocation.

Prototype

@BeanProperty(description = "The location of the divider.")
public void setDividerLocation(int location) 

Source Link

Document

Sets the location of the divider.

Usage

From source file:hr.fer.zemris.vhdllab.platform.support.SimplisticEclipseBasedApplicationPage.java

@Override
protected JComponent createControl() {
    projectExplorerPane = new JPanel(new BorderLayout());
    editorsPane = new JPanel(new BorderLayout());
    viewsTabbedPane = new JTabbedPane(JTabbedPane.TOP, JTabbedPane.WRAP_TAB_LAYOUT);
    viewsTabbedPane.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            // if we're adding a component, ignore change of active
            // component
            if (!addingView && getViewsTabbedPane().getSelectedIndex() >= 0) {
                setActiveComponent(getComponent(getViewsTabbedPane().getSelectedIndex()));
            }/* www  .j  ava 2 s.  c om*/
        }
    });

    final double horizontalLocation = 0.15;
    final double verticalLocation = 0.75;
    final JSplitPane horizontalPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, projectExplorerPane,
            editorsPane);
    horizontalPane.setDividerLocation(horizontalLocation);
    final JSplitPane verticalPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, horizontalPane, viewsTabbedPane);
    verticalPane.setDividerLocation(verticalLocation);

    JPanel maximizedPanel = new JPanel(new BorderLayout());
    maximizedPanel.add(verticalPane, BorderLayout.CENTER);
    JPanel control = new JPanel(new BorderLayout());
    control.add(maximizedPanel, BorderLayout.CENTER);
    control.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            horizontalPane.setDividerLocation(horizontalLocation);
            verticalPane.setDividerLocation(verticalLocation);
        }
    });

    this.getPageDescriptor().buildInitialLayout(this);

    if (viewsTabbedPane.getTabCount() > 0) {
        viewsTabbedPane.setSelectedIndex(0);
    }

    Logger.getRootLogger().addAppender(new AppenderSkeleton() {
        @Override
        public boolean requiresLayout() {
            return false;
        }

        @Override
        public void close() {
        }

        @SuppressWarnings("synthetic-access")
        @Override
        protected void append(LoggingEvent event) {
            if (event.getLevel().equals(Level.INFO)) {
                Object message = event.getMessage();
                if (message != null) {
                    getActiveWindow().getStatusBar().setMessage(message.toString());
                }
            }
        }
    });
    return control;
}

From source file:TopLevelTransferHandlerDemo.java

public TopLevelTransferHandlerDemo() {
    super("TopLevelTransferHandlerDemo");
    setJMenuBar(createDummyMenuBar());/* w w w  . j  a  va  2  s  .  c o  m*/
    getContentPane().add(createDummyToolBar(), BorderLayout.NORTH);

    JSplitPane sp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, list, dp);
    sp.setDividerLocation(120);
    getContentPane().add(sp);
    //new Doc("sample.txt");
    //new Doc("sample.txt");
    //new Doc("sample.txt");

    list.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    list.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }

            Doc val = (Doc) list.getSelectedValue();
            if (val != null) {
                val.select();
            }
        }
    });

    final TransferHandler th = list.getTransferHandler();

    nullItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            if (nullItem.isSelected()) {
                list.setTransferHandler(null);
            } else {
                list.setTransferHandler(th);
            }
        }
    });
    thItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            if (thItem.isSelected()) {
                setTransferHandler(handler);
            } else {
                setTransferHandler(null);
            }
        }
    });
    dp.setTransferHandler(handler);
}

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/*from w  w w .java  2 s  .  co  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:com.choicemaker.cm.modelmaker.gui.panels.HoldVsAccuracyPlotPanel.java

private void layoutPanel() {
    GridBagLayout layout = new GridBagLayout();
    setLayout(layout);/*  w w  w. j a  v  a 2 s  .co  m*/
    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:org.moeaframework.examples.gp.regression.SymbolicRegressionGUI.java

/**
 * Layout the components on the GUI./*  w  w w  .j a  v  a2 s.c  om*/
 */
protected void layoutComponents() {
    container.setMinimumSize(new Dimension(300, 300));

    JScrollPane detailsPane = new JScrollPane(details);
    detailsPane.setMinimumSize(new Dimension(150, 150));

    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, container, detailsPane);
    splitPane.setResizeWeight(0.5);
    splitPane.setDividerLocation(0.4);

    JPanel buttonPane = new JPanel(new FlowLayout(FlowLayout.CENTER));
    buttonPane.add(close);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(splitPane, BorderLayout.CENTER);
    getContentPane().add(buttonPane, BorderLayout.SOUTH);
}

From source file:fi.smaa.jsmaa.gui.JSMAAMainFrame.java

private void rebuildGUI() {
    JSplitPane splitPane = new JSplitPane();
    splitPane.setResizeWeight(0.1);/*ww w  .  j  a  v a 2 s.c om*/
    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:eu.cassandra.platform.gui.GUI.java

public GUI() {
    //redirectSystemStreams();
    a = new ListenInstallationComboBox();
    installationCombo.setPreferredSize(new Dimension(300, 20));

    startButton.addActionListener(new ListenStartButton());
    exitButton.addActionListener(new ListenExitButton());
    projectFileField.addMouseListener(new ListenProjectFileField());

    logTextAreaScrollPane.setPreferredSize(new Dimension(400, 500));

    projectFileField.setPreferredSize(new Dimension(600, 20));
    //      projectFileField.setText(new File(Params.SIM_PROPS).getAbsolutePath());
    projectFileField.setText("");
    projectFileField.setEditable(false);

    f.setJMenuBar(menuBar);/* w  ww .j a  va2s.c  om*/

    menuFile.add(menuItemQuit);
    menuHelp.add(menuItemAbout);
    menuBar.add(menuFile);
    menuBar.add(menuHelp);

    statsTextArea.setFont(new Font("Tahoma", Font.BOLD, 12));

    TimeSeries series = new TimeSeries("");
    dataset = new TimeSeriesCollection(series);
    JFreeChart chart = createChart("Consumption", dataset);
    ChartPanel chartPanel = new ChartPanel(chart);
    graphScrollPane = new JScrollPane(chartPanel);

    buttonPanel.add(projectFileField);
    buttonPanel.add(startButton);
    buttonPanel.add(holdButton);
    buttonPanel.add(installationCombo);
    buttonPanel.add(exitButton);

    statsTextArea.setText("Statistics:\n");
    logTextArea.setText("Logs:\n");

    JSplitPane textAreaSplitPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT);

    textAreaSplitPanel.setDividerLocation((int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2));
    textAreaSplitPanel.add(statsTextAreaScrollPane, JSplitPane.TOP);
    textAreaSplitPanel.add(logTextAreaScrollPane, JSplitPane.BOTTOM);

    JSplitPane mainSplitPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    mainSplitPanel.add(graphScrollPane, JSplitPane.LEFT);
    mainSplitPanel.add(textAreaSplitPanel, JSplitPane.RIGHT);
    mainSplitPanel.setDividerLocation((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 1.5));

    f.getContentPane().setLayout(new BorderLayout());
    f.getContentPane().add(mainSplitPanel, BorderLayout.CENTER);
    f.getContentPane().add(buttonScrollPane, BorderLayout.SOUTH);

    f.addWindowListener(new ListenCloseWdw());
    menuItemQuit.addActionListener(new ListenMenuQuit());
}

From source file:DragFileDemo.java

public DragFileDemo() {
    super(new BorderLayout());

    fc = new JFileChooser();
    ;/*from  w w w  . j a  v  a  2s.co  m*/
    fc.setMultiSelectionEnabled(true);
    fc.setDragEnabled(true);
    fc.setControlButtonsAreShown(false);
    JPanel fcPanel = new JPanel(new BorderLayout());
    fcPanel.add(fc, BorderLayout.CENTER);

    clear = new JButton("Clear All");
    clear.addActionListener(this);
    JPanel buttonPanel = new JPanel(new BorderLayout());
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    buttonPanel.add(clear, BorderLayout.LINE_END);

    JPanel upperPanel = new JPanel(new BorderLayout());
    upperPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    upperPanel.add(fcPanel, BorderLayout.CENTER);
    upperPanel.add(buttonPanel, BorderLayout.PAGE_END);

    //The TabbedPaneController manages the panel that
    //contains the tabbed pane. When there are no files
    //the panel contains a plain text area. Then, as
    //files are dropped onto the area, the tabbed panel
    //replaces the file area.
    JTabbedPane tabbedPane = new JTabbedPane();
    JPanel tabPanel = new JPanel(new BorderLayout());
    tabPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    tpc = new TabbedPaneController(tabbedPane, tabPanel);

    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, upperPanel, tabPanel);
    splitPane.setDividerLocation(400);
    splitPane.setPreferredSize(new Dimension(530, 650));
    add(splitPane, BorderLayout.CENTER);
}

From source file:hermes.browser.actions.AbstractFIXBrowserDocumentComponent.java

protected void init() {
    headerScrollPane.setViewportView(getHeaderComponent());

    bottomPanel.add(new FilterablePanel(), BorderLayout.NORTH);
    bottomPanel.add(getStatusPanel(), BorderLayout.SOUTH);

    getTopPanel().setLayout(new BorderLayout());

    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);

    splitPane.setDividerLocation(200);
    splitPane.setOneTouchExpandable(false);
    splitPane.setContinuousLayout(false);
    splitPane.add(headerScrollPane, "top");
    splitPane.add(messageTabbedPane, "bottom");

    messageTabbedPane.setTabPlacement(JTabbedPane.BOTTOM);

    getTopPanel().add(splitPane, BorderLayout.CENTER);
    getTopPanel().add(getBottomComponent(), BorderLayout.SOUTH);

    HermesBrowser.getBrowser().addDocumentComponent(this);

    addDocumentComponentListener(this);

    updateTableRows(true);//from  w w w . j  a  v  a2s  . c  om
}

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  va  2  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);

    //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);
}