-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
1.2.2
-
x86
-
linux
Name: kaC94536 Date: 01/21/2000
Component JSplitPane does not redraw its panel correctly after SetDividerSize(int) invocation.
Frame window of the following test contains a JSplitPane component with text area at the top and
buttons area in the bottom. First time divider size is set to 40 pixels.
If you click on button "10", method JSplitPane.SetDividerSize(10) will be invoked.
If you click on button "40", method JSplitPane.SetDividerSize(40) will be invoked.
After clicking on "10" you can see that left and right sides of divider is shown
incorrectly. Then if you resize frame window or click on divider, panel redraws correctly.
--------------------test.java---------------------------------------------
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class test extends JFrame {
JSplitPane sp;
public test() {
super("JSplitPane.setDividerSize(int) test");
JPanel buttonPanel = new ButtonDemo(this);
sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JTextArea(), buttonPanel);
sp.setDividerLocation(100);
sp.setPreferredSize(new Dimension(500, 300));
sp.setDividerSize(40);
getContentPane().add(sp,BorderLayout.CENTER);
}
public static void main(String[] args) {
JFrame frame = new test();
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.pack();
frame.setVisible(true);
}
}
class ButtonDemo extends JPanel implements ActionListener {
JButton b1, b2;
test t;
public ButtonDemo(test tt) {
t = tt;
b1 = new JButton("10");
b1.setVerticalTextPosition(AbstractButton.CENTER);
b1.setHorizontalTextPosition(AbstractButton.LEFT);
b1.setToolTipText("Set divider size to 10");
b1.setActionCommand("10");
b1.setText("10");
b1.addActionListener(this);
add(b1);
b2 = new JButton("40");
b2.setVerticalTextPosition(AbstractButton.BOTTOM);
b2.setHorizontalTextPosition(AbstractButton.CENTER);
b2.setToolTipText("Set divider size to 40");
b2.setActionCommand("40");
b2.addActionListener(this);
add(b2);
}
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("10")) {
t.sp.setDividerSize(10);
}
else {
t.sp.setDividerSize(40);
}
}
}
======================================================================
======================================================================