Example usage for javax.swing JSplitPane LAST_DIVIDER_LOCATION_PROPERTY

List of usage examples for javax.swing JSplitPane LAST_DIVIDER_LOCATION_PROPERTY

Introduction

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

Prototype

String LAST_DIVIDER_LOCATION_PROPERTY

To view the source code for javax.swing JSplitPane LAST_DIVIDER_LOCATION_PROPERTY.

Click Source Link

Document

Bound property for lastLocation.

Usage

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    JFrame frame = new JFrame("Property Split");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);

    splitPane.setTopComponent(new JLabel("www.java2s.com"));

    splitPane.setBottomComponent(new JLabel("www.java2s.com"));

    PropertyChangeListener propertyChangeListener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent changeEvent) {
            JSplitPane sourceSplitPane = (JSplitPane) changeEvent.getSource();
            String propertyName = changeEvent.getPropertyName();
            if (propertyName.equals(JSplitPane.LAST_DIVIDER_LOCATION_PROPERTY)) {
                int current = sourceSplitPane.getDividerLocation();
                System.out.println("Current: " + current);
                Integer last = (Integer) changeEvent.getNewValue();
                System.out.println("Last: " + last);
                Integer priorLast = (Integer) changeEvent.getOldValue();
                System.out.println("Prior last: " + priorLast);
            }// ww  w.  jav a  2s  .c  o  m
        }
    };

    // Attach listener
    splitPane.addPropertyChangeListener(propertyChangeListener);

    frame.add(splitPane, BorderLayout.CENTER);
    frame.setSize(300, 150);
    frame.setVisible(true);
}

From source file:PropertySplitPane.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Property Split");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setContinuousLayout(true);
    splitPane.setOneTouchExpandable(true);

    JComponent topComponent = new JButton("A");
    splitPane.setTopComponent(topComponent);

    JComponent bottomComponent = new JButton("B");
    splitPane.setBottomComponent(bottomComponent);

    PropertyChangeListener propertyChangeListener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent changeEvent) {
            JSplitPane sourceSplitPane = (JSplitPane) changeEvent.getSource();
            String propertyName = changeEvent.getPropertyName();
            if (propertyName.equals(JSplitPane.LAST_DIVIDER_LOCATION_PROPERTY)) {
                int current = sourceSplitPane.getDividerLocation();
                System.out.println("Current: " + current);
                Integer last = (Integer) changeEvent.getNewValue();
                System.out.println("Last: " + last);
                Integer priorLast = (Integer) changeEvent.getOldValue();
                System.out.println("Prior last: " + priorLast);
            }//from  www. j a va2 s . co  m
        }
    };

    splitPane.addPropertyChangeListener(propertyChangeListener);

    frame.add(splitPane, BorderLayout.CENTER);
    frame.setSize(300, 150);
    frame.setVisible(true);
}

From source file:com.sec.ose.osi.ui.frm.main.identification.codematch.JPanCodeMatchMain.java

/**
 * This method initializes jPanel1   /*from  ww  w.  j av  a  2 s  .c o m*/
 *    
 * @return javax.swing.JPanel   
 */
public JSplitPane getJSplitPaneSourceCode() {
    if (jSplitPaneSourceCode == null) {
        GridBagConstraints gridBagConstraints14 = new GridBagConstraints();
        gridBagConstraints14.fill = GridBagConstraints.BOTH;
        gridBagConstraints14.weighty = 1.0;
        gridBagConstraints14.weightx = 1.0;
        GridBagConstraints gridBagConstraints17 = new GridBagConstraints();
        gridBagConstraints17.fill = GridBagConstraints.BOTH;
        gridBagConstraints17.weighty = 1.0;
        gridBagConstraints17.weightx = 1.0;
        jSplitPaneSourceCode = new JSplitPane();
        jSplitPaneSourceCode.setBorder(BorderFactory.createTitledBorder(null, "Source Code",
                TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
                new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
        jSplitPaneSourceCode.setDividerSize(5);
        jSplitPaneSourceCode.setLeftComponent(getJPanMatchedSourceViewLeft());
        jSplitPaneSourceCode.setRightComponent(getJPanMatchedSourceViewRight());

        PropertyChangeListener propertyChangeListener = new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent changeEvent) {
                String propertyName = changeEvent.getPropertyName();
                if (propertyName.equals(JSplitPane.LAST_DIVIDER_LOCATION_PROPERTY)) {
                    if (getSimilarSnippets() != null) {
                        setNavigator();
                    }
                }
            }
        };

        jSplitPaneSourceCode.addPropertyChangeListener(propertyChangeListener);
    }
    return jSplitPaneSourceCode;
}

From source file:view.MainWindow.java

private void jSplitPane1PropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_jSplitPane1PropertyChange
    String propertyName = evt.getPropertyName();
    if (propertyName.equals(JSplitPane.LAST_DIVIDER_LOCATION_PROPERTY)) {
        workspacePanel.fixTempSignaturePosition(false);
    }/*w w  w .ja  v a 2s . c o  m*/
}