?
Solved

question about JSplitPane event

Posted on 2004-11-24
3
Medium Priority
?
340 Views
Last Modified: 2011-08-18
my program looks as follow. if i move the divider, how can i catch the event?

public class MyTest extends JFrame {

  private javax.swing.JPanel jContentPane = null;

  private javax.swing.JSplitPane jSplitPane = null;
  public static void main(String[] args) {
      new MyTest().show();
  }

  public MyTest() {
    super();
    initialize();
  }

  private void initialize() {
    this.setContentPane(getJContentPane());
    this.setSize(500, 399);
    this.setContentPane(getJContentPane());
    this.setTitle("Test");
}

  private javax.swing.JPanel getJContentPane() {
    if (jContentPane == null) {
      jContentPane = new javax.swing.JPanel();
      jContentPane.setLayout(null);
      jContentPane.add(getJSplitPane(),null);
    }
    return jContentPane;
  }

  private javax.swing.JSplitPane getJSplitPane() {
    if(jSplitPane == null) {
    jSplitPane = new javax.swing.JSplitPane();
    jSplitPane.setBounds(6, 26, 410, 182);
    }
    return jSplitPane;
  }
}
0
Comment
Question by:chenwei
  • 3
3 Comments
 
LVL 37

Accepted Solution

by:
zzynx earned 80 total points
ID: 12664605
Here you have it for 20 points.
Because it's you ;°)

/*
 * MyTest.java
 *
 */

import javax.swing.*;
import java.awt.*;
import java.beans.*;

public class MyTest extends JFrame {

  private javax.swing.JPanel jContentPane = null;

  private javax.swing.JSplitPane jSplitPane = null;
  public static void main(String[] args) {
     MyTest f = new MyTest();
     f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     f.show();
  }

  public MyTest() {
    super();
    initialize();
  }

  private void initialize() {
    this.setContentPane(getJContentPane());
    this.setSize(500, 399);
    this.setContentPane(getJContentPane());
    this.setTitle("Test");
}

  private javax.swing.JPanel getJContentPane() {
    if (jContentPane == null) {
      jContentPane = new javax.swing.JPanel();
      jContentPane.setLayout(null);
      jContentPane.add(getJSplitPane(),null);
    }
    return jContentPane;
  }

  private javax.swing.JSplitPane getJSplitPane() {
    if(jSplitPane == null) {
        jSplitPane = new javax.swing.JSplitPane();
        jSplitPane.setBounds(6, 26, 410, 182);
        jSplitPane.addPropertyChangeListener(
            "dividerLocation", new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent e) {
                    Number value = (Number) e.getNewValue();
                    System.out.println("New location: " + value.intValue());
                }
            });
    }
    return jSplitPane;
  }
}
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12664808
Thanks
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12664816
What about the other Q?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses
Course of the Month16 days, 6 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question