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:org.notebook.gui.MainFrame.java

public void initGui() {
    setLayout(new BorderLayout());
    menu = new MenuToolbar(events);
    this.getRootPane().setJMenuBar(menu.getMenuBar());

    //editor = new DocumentEditor();
    //menu.addExtraToolBar(editor.getToolBar());

    //JScrollPane leftTree = new JScrollPane(tree);
    Dimension minSize = new Dimension(150, 400);

    mainPanel = new SimplePrintPanel();
    events.registerAction(mainPanel.getEventsHandler());
    _panel = new JScrollPane(mainPanel);
    _panel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

    JSplitPane splitPanel;
    splitPanel = new JSplitPane();
    splitPanel.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
    //splitPanel.setAutoscrolls(true);
    splitPanel.setDividerLocation(0.35);
    splitPanel.setOneTouchExpandable(true);
    splitPanel.setLeftComponent(getNavigationBar());
    splitPanel.setRightComponent(_panel);

    statusBar = new StatusBar();
    mainPanel.bar = statusBar;//from  w  ww  .  j  a  v  a2  s  .  com

    Container contentPane = getContentPane();
    contentPane.add(menu.getToolBar(), BorderLayout.NORTH);

    contentPane.add(splitPanel, BorderLayout.CENTER);
    //contentPane.add(_panel, BorderLayout.CENTER);

    contentPane.add(statusBar, BorderLayout.SOUTH);

    //controller = createPrivilegedProxy(new DefaultBookController(this));

    //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setIconImage(appIcon16());

    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    final MainFrame mainFrame = this;

    addWindowListener(new WindowAdapter() {
        //?
        public void windowClosing(WindowEvent e) {
            events.fireEvent(MenuToolbar.EXIT, mainFrame);
        }

        //???
        public void windowOpened(WindowEvent e) {
            events.fireEvent(MenuToolbar.LOADED, mainFrame);
        }
    });

    //????????
    events.fireEvent(MenuToolbar.GUI_INITED, this);

    events.registerAction(this);

    pack();
    setSize(670, 548);

}

From source file:org.omegat.gui.scripting.ScriptingWindow.java

private void initWindowLayout() {
    // set default size and position
    frame.setBounds(50, 80, 1150, 650);//from  w ww  .ja va  2  s  .  c  o  m
    StaticUIUtils.persistGeometry(frame, Preferences.SCRIPTWINDOW_GEOMETRY_PREFIX);

    frame.getContentPane().setLayout(new BorderLayout(0, 0));

    m_scriptList = new JList<>();
    JScrollPane scrollPaneList = new JScrollPane(m_scriptList);

    m_scriptList.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent evt) {
            if (!evt.getValueIsAdjusting()) {
                onListSelectionChanged();
            }
        }
    });

    m_scriptList.addMouseMotionListener(new MouseMotionAdapter() {

        @Override
        public void mouseMoved(MouseEvent e) {
            ListModel<ScriptItem> lm = m_scriptList.getModel();
            int index = m_scriptList.locationToIndex(e.getPoint());
            if (index > -1) {
                m_scriptList.setToolTipText(lm.getElementAt(index).getFile().getName());
            }
        }

    });

    m_txtResult = new JEditorPane();
    JScrollPane scrollPaneResults = new JScrollPane(m_txtResult);

    //m_txtScriptEditor = new StandardScriptEditor();
    m_txtScriptEditor = getScriptEditor();

    m_txtScriptEditor.initLayout(this);

    JSplitPane splitPane1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, m_txtScriptEditor.getPanel(),
            scrollPaneResults);
    splitPane1.setOneTouchExpandable(true);
    splitPane1.setDividerLocation(430);
    Dimension minimumSize1 = new Dimension(100, 50);
    //scrollPaneEditor.setMinimumSize(minimumSize1);
    scrollPaneResults.setMinimumSize(minimumSize1);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scrollPaneList, splitPane1);
    splitPane.setOneTouchExpandable(true);
    splitPane.setDividerLocation(250);

    Dimension minimumSize = new Dimension(100, 50);
    scrollPaneList.setMinimumSize(minimumSize);
    scrollPaneResults.setMinimumSize(minimumSize);

    frame.getContentPane().add(splitPane, BorderLayout.CENTER);

    JPanel panelSouth = new JPanel();
    FlowLayout fl_panelSouth = (FlowLayout) panelSouth.getLayout();
    fl_panelSouth.setAlignment(FlowLayout.LEFT);
    frame.getContentPane().add(panelSouth, BorderLayout.SOUTH);
    setupRunButtons(panelSouth);

    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    frame.setJMenuBar(createMenuBar());
}

From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java

/**
 * Initializes and returns a split pane, either vertical or horizontal 
 * depending on the passed parameter./* www  .  j a  v a  2s .c  o  m*/
 * 
 * @param orientation The orientation of the split pane.
 * @return See above.
 */
private JSplitPane initSplitPane(int orientation) {
    int type;
    switch (orientation) {
    case JSplitPane.HORIZONTAL_SPLIT:
    case JSplitPane.VERTICAL_SPLIT:
        type = orientation;
        break;
    default:
        type = JSplitPane.HORIZONTAL_SPLIT;
    }
    JSplitPane pane = new JSplitPane(type);
    pane.setOneTouchExpandable(true);
    pane.setContinuousLayout(true);
    pane.setDividerLocation(-1);
    pane.setResizeWeight(0.0);
    return pane;
}

From source file:org.pentaho.reporting.engine.classic.core.modules.gui.base.PreviewPane.java

private void refreshReportController(final ReportController newReportController) {
    for (int i = 0; i < outerReportControllerHolder.getComponentCount(); i++) {
        final Component maybeSplitPane = outerReportControllerHolder.getComponent(i);
        if (maybeSplitPane instanceof JSplitPane) {
            final JSplitPane splitPane = (JSplitPane) maybeSplitPane;
            reportControllerSliderSize = splitPane.getDividerLocation();
            break;
        }/*from  ww w.j  av  a2 s  .co  m*/
    }

    if (newReportController == null) {
        if (reportControllerComponent != null) {
            // thats relatively easy.
            outerReportControllerHolder.removeAll();
            outerReportControllerHolder.add(toolbarHolder, BorderLayout.NORTH);
            outerReportControllerHolder.add(reportPaneScrollPane, BorderLayout.CENTER);
            reportControllerComponent = null;
            reportControllerInner = false;
            reportControllerLocation = null;
        }
    } else {
        final JComponent rcp = newReportController.getControlPanel();
        if (rcp == null) {
            if (reportControllerComponent != null) {
                outerReportControllerHolder.removeAll();
                outerReportControllerHolder.add(toolbarHolder, BorderLayout.NORTH);
                outerReportControllerHolder.add(reportPaneScrollPane, BorderLayout.CENTER);
                reportControllerComponent = null;
                reportControllerInner = false;
                reportControllerLocation = null;
            }
        } else if (reportControllerComponent != rcp
                || reportControllerInner != newReportController.isInnerComponent()
                || ObjectUtilities.equal(reportControllerLocation,
                        newReportController.getControllerLocation()) == false) {
            // if either the controller component or its position (inner vs outer)
            // and border-position has changed, then refresh ..
            this.reportControllerLocation = newReportController.getControllerLocation();
            this.reportControllerInner = newReportController.isInnerComponent();
            this.reportControllerComponent = newReportController.getControlPanel();

            outerReportControllerHolder.removeAll();
            if (reportControllerInner) {
                final JSplitPane innerHolder = new JSplitPane();
                innerHolder.setOpaque(false);
                if (BorderLayout.SOUTH.equals(reportControllerLocation)) {
                    innerHolder.setOrientation(JSplitPane.VERTICAL_SPLIT);
                    innerHolder.setTopComponent(reportPaneScrollPane);
                    innerHolder.setBottomComponent(reportControllerComponent);
                } else if (BorderLayout.EAST.equals(reportControllerLocation)) {
                    innerHolder.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
                    innerHolder.setLeftComponent(reportPaneScrollPane);
                    innerHolder.setRightComponent(reportControllerComponent);
                } else if (BorderLayout.WEST.equals(reportControllerLocation)) {
                    innerHolder.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
                    innerHolder.setRightComponent(reportPaneScrollPane);
                    innerHolder.setLeftComponent(reportControllerComponent);
                } else {
                    innerHolder.setOrientation(JSplitPane.VERTICAL_SPLIT);
                    innerHolder.setBottomComponent(reportPaneScrollPane);
                    innerHolder.setTopComponent(reportControllerComponent);
                }

                if (reportControllerSliderSize > 0) {
                    innerHolder.setDividerLocation(reportControllerSliderSize);
                }
                outerReportControllerHolder.add(toolbarHolder, BorderLayout.NORTH);
                outerReportControllerHolder.add(innerHolder, BorderLayout.CENTER);
            } else {
                final JPanel reportPaneHolder = new JPanel();
                reportPaneHolder.setOpaque(false);
                reportPaneHolder.setLayout(new BorderLayout());
                reportPaneHolder.add(toolbarHolder, BorderLayout.NORTH);
                reportPaneHolder.add(reportPaneScrollPane, BorderLayout.CENTER);

                final JSplitPane innerHolder = new JSplitPane();
                if (BorderLayout.SOUTH.equals(reportControllerLocation)) {
                    innerHolder.setOrientation(JSplitPane.VERTICAL_SPLIT);
                    innerHolder.setTopComponent(reportPaneHolder);
                    innerHolder.setBottomComponent(reportControllerComponent);
                } else if (BorderLayout.EAST.equals(reportControllerLocation)) {
                    innerHolder.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
                    innerHolder.setLeftComponent(reportPaneHolder);
                    innerHolder.setRightComponent(reportControllerComponent);
                } else if (BorderLayout.WEST.equals(reportControllerLocation)) {
                    innerHolder.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
                    innerHolder.setRightComponent(reportPaneHolder);
                    innerHolder.setLeftComponent(reportControllerComponent);
                } else {
                    innerHolder.setOrientation(JSplitPane.VERTICAL_SPLIT);
                    innerHolder.setBottomComponent(reportPaneHolder);
                    innerHolder.setTopComponent(reportControllerComponent);
                }
                if (reportControllerSliderSize > 0) {
                    innerHolder.setDividerLocation(reportControllerSliderSize);
                }
                outerReportControllerHolder.add(innerHolder, BorderLayout.CENTER);
            }
        }
    }
}

From source file:org.pentaho.reporting.engine.classic.demo.util.CompoundDemoFrame.java

protected Container createDefaultContentPane() {

    demoContent = new JPanel();
    demoContent.setLayout(new BorderLayout());
    demoContent.setMinimumSize(new Dimension(100, 100));
    demoContent.add(getNoHandlerInfoPane(), BorderLayout.CENTER);

    JPanel placeHolder = new JPanel();
    placeHolder.setMinimumSize(new Dimension(300, 0));
    placeHolder.setPreferredSize(new Dimension(300, 0));
    placeHolder.setMaximumSize(new Dimension(300, 0));

    JPanel rootContent = new JPanel();
    rootContent.setLayout(new BorderLayout());
    rootContent.add(demoContent, BorderLayout.CENTER);
    rootContent.add(placeHolder, BorderLayout.NORTH);

    final DemoSelectorTreeNode root = new DemoSelectorTreeNode(null, demoSelector);
    final DefaultTreeModel model = new DefaultTreeModel(root);
    final JTree demoTree = new JTree(model);
    demoTree.addTreeSelectionListener(new TreeSelectionHandler());

    JSplitPane rootSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(demoTree),
            rootContent);//from w  ww  .j  a  v  a  2 s  . c o m
    rootSplitPane.setContinuousLayout(true);
    rootSplitPane.setDividerLocation(200);
    rootSplitPane.setOneTouchExpandable(true);
    return rootSplitPane;
}

From source file:org.pentaho.reporting.engine.classic.demo.util.CompoundDemoFrame.java

protected JComponent createDefaultDemoPane(final InternalDemoHandler demoHandler) {
    final JPanel content = new JPanel(new BorderLayout());
    content.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    final URL url = demoHandler.getDemoDescriptionSource();
    final JComponent scroll = createDescriptionTextPane(url);

    final JButton previewButton = new JButton(getPreviewAction());

    final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setTopComponent(scroll);//from  www  .j  a v a 2  s. c  o m
    splitPane.setBottomComponent(demoHandler.getPresentationComponent());
    splitPane.setDividerLocation(200);
    splitPane.setOneTouchExpandable(true);
    content.add(splitPane, BorderLayout.CENTER);
    content.add(previewButton, BorderLayout.SOUTH);
    return content;
}

From source file:org.pentaho.reporting.ui.datasources.kettle.KettleDataSourceDialog.java

protected Component createContentPane() {
    final JPanel previewAndParameterPanel = createTransformParameterPanel();
    final JPanel queryListPanel = createQueryListPanel();

    final JPanel mainPanel = new JPanel(new GridBagLayout());
    mainPanel.setBorder(new EmptyBorder(5, 5, 0, 5));
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;//from   w  w w .j  av  a  2 s .co m
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.WEST;
    mainPanel.add(new JLabel(Messages.getString("KettleDataSourceDialog.QueryName")), gbc);

    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.weightx = 1;
    mainPanel.add(nameTextField, gbc);

    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 3;
    gbc.gridwidth = 3;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 1;
    gbc.weighty = 1;
    gbc.anchor = GridBagConstraints.WEST;
    mainPanel.add(createDatasourcePanel(), gbc);

    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.gridwidth = 3;
    gbc.anchor = GridBagConstraints.WEST;
    mainPanel.add(previewAndParameterPanel, gbc);

    final JSplitPane panel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    panel.setLeftComponent(queryListPanel);
    panel.setRightComponent(mainPanel);
    panel.setDividerLocation(250);
    return panel;
}

From source file:org.pentaho.ui.xul.swing.SwingElement.java

public void layout() {
    super.layout();
    double totalFlex = 0.0;

    if (isVisible() == false) {
        resetContainer();/*from   w  w w . j av  a  2  s  .  c  om*/
        return;
    }

    for (Element comp : getChildNodes()) {
        // if (comp.getManagedObject() == null) {
        // continue;
        // }
        if (((XulComponent) comp).getFlex() > 0) {
            flexLayout = true;
            totalFlex += ((XulComponent) comp).getFlex();
        }
    }

    double currentFlexTotal = 0.0;

    Align alignment = (getAlign() != null) ? Align.valueOf(this.getAlign().toUpperCase()) : null;

    for (int i = 0; i < getChildNodes().size(); i++) {
        XulComponent comp = (XulComponent) getChildNodes().get(i);
        gc.fill = GridBagConstraints.BOTH;

        if (comp instanceof XulSplitter) {
            JPanel prevContainer = container;
            container = new ScrollablePanel(new GridBagLayout());
            container.setOpaque(false);

            final JSplitPane splitter = new JSplitPane(
                    (this.getOrientation() == Orient.VERTICAL) ? JSplitPane.VERTICAL_SPLIT
                            : JSplitPane.HORIZONTAL_SPLIT,
                    prevContainer, container);
            splitter.setContinuousLayout(true);

            final double splitterSize = currentFlexTotal / totalFlex;
            splitter.setResizeWeight(splitterSize);
            if (totalFlex > 0) {
                splitter.addComponentListener(new ComponentListener() {
                    public void componentHidden(ComponentEvent arg0) {
                    }

                    public void componentMoved(ComponentEvent arg0) {
                    }

                    public void componentShown(ComponentEvent arg0) {
                    }

                    public void componentResized(ComponentEvent arg0) {
                        splitter.setDividerLocation(splitterSize);
                        splitter.removeComponentListener(this);
                    }

                });

            }

            if (!flexLayout) {
                if (this.getOrientation() == Orient.VERTICAL) { // VBox and such
                    gc.weighty = 1.0;
                } else {
                    gc.weightx = 1.0;
                }

                prevContainer.add(Box.createGlue(), gc);
            }
            setManagedObject(splitter);
        }

        Object maybeComponent = comp.getManagedObject();
        if (maybeComponent == null || !(maybeComponent instanceof Component)) {
            continue;
        }
        if (this.getOrientation() == Orient.VERTICAL) { // VBox and such
            gc.gridheight = comp.getFlex() + 1;
            gc.gridwidth = GridBagConstraints.REMAINDER;
            gc.weighty = (totalFlex == 0) ? 0 : (comp.getFlex() / totalFlex);
        } else {
            gc.gridwidth = comp.getFlex() + 1;
            gc.gridheight = GridBagConstraints.REMAINDER;
            gc.weightx = (totalFlex == 0) ? 0 : (comp.getFlex() / totalFlex);
        }

        currentFlexTotal += comp.getFlex();

        if (this.getOrientation() == Orient.VERTICAL) { // VBox and such
            if (alignment != null) {
                gc.fill = GridBagConstraints.NONE;
                switch (alignment) {
                case START:
                    gc.anchor = GridBagConstraints.WEST;
                    break;
                case CENTER:
                    gc.anchor = GridBagConstraints.CENTER;
                    break;
                case END:
                    gc.anchor = GridBagConstraints.EAST;
                    break;
                }
            }

        } else {
            if (alignment != null) {
                gc.fill = GridBagConstraints.NONE;
                switch (alignment) {
                case START:
                    gc.anchor = GridBagConstraints.NORTH;
                    break;
                case CENTER:
                    gc.anchor = GridBagConstraints.CENTER;
                    break;
                case END:
                    gc.anchor = GridBagConstraints.SOUTH;
                    break;
                }
            }
        }

        Component component = (Component) maybeComponent;

        if (comp.getWidth() > 0 || comp.getHeight() > 0) {
            Dimension minSize = component.getMinimumSize();
            Dimension prefSize = component.getPreferredSize();

            if (comp.getWidth() > 0) {
                minSize.width = comp.getWidth();
                prefSize.width = comp.getWidth();
            }
            if (comp.getHeight() > 0) {
                minSize.height = comp.getHeight();
                prefSize.height = comp.getHeight();
            }
            component.setMinimumSize(minSize);
            component.setPreferredSize(prefSize);
        }

        container.add(component, gc);

        if (i + 1 == getChildNodes().size() && !flexLayout) {
            if (this.getOrientation() == Orient.VERTICAL) { // VBox and such
                gc.weighty = 1.0;

            } else {
                gc.weightx = 1.0;

            }
            container.add(Box.createGlue(), gc);
        }
    }

}

From source file:org.richie.codeGen.ui.CodeGenMainUI.java

private void initlize() {
    setTitle("??");
    setBounds(120, 80, 1024, 550);//from  w  w w  . java2s  .c  om
    setDefaultCloseOperation(3);
    setLayout(new BorderLayout(5, 5));
    // ?MenuBar
    initMenuBar();
    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, getWestPanel(), getCenterPanel());
    split.setContinuousLayout(false);
    split.setOneTouchExpandable(true);
    split.setDividerLocation(150);
    add(split, BorderLayout.CENTER);
    //?pdm
    openLastPdmFile();
    addCloseListener();
    this.setIconImage(new ImageIcon(ClassLoader.getSystemResource("resources/images/logo.jpg")).getImage());
}

From source file:org.sintef.thingml.ThingMLFrame.java

public ThingMLFrame(String args[]) {
    int i = 0;//from w  w  w .  j  av  a 2  s.  com
    for (String s : args) {
        if (i > 0) {
            argsFlat += "=";
        }
        argsFlat += s;
    }

    if (argsFlat.contains("-open=")) {
        File filePath = new File(argsFlat.substring(argsFlat.indexOf("=") + 1));
        filePanel = new FilePanel(editor, this, filePath.getParentFile());

        String content = "";
        try {
            final InputStream input = new FileInputStream(filePath);
            final java.util.List<String> packLines = IOUtils.readLines(input);
            for (String line : packLines) {
                content += line + "\n";
            }
            input.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        editor.loadText(content, null);
    } else {
        filePanel = new FilePanel(editor, this, null);
    }

    setTitle("ThingML Editor");
    this.setLayout(new BorderLayout());

    filePanel.setPreferredSize(new Dimension(300, 300));
    filePanel.setSize(300, 300);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, filePanel, editor);
    splitPane.setContinuousLayout(true);
    splitPane.setDividerSize(6);
    splitPane.setDividerLocation(200);
    splitPane.setResizeWeight(0.0);
    splitPane.setBorder(null);

    add(splitPane, BorderLayout.CENTER);
}