-
Bug
-
Resolution: Fixed
-
P4
-
1.4.2, 5.0
-
tiger
-
generic
-
generic
-
Verified
Name: iaR10016 Date: 04/22/2003
Filed By : J2SE-SQA [###@###.###
JDK : JDK1.5.0-b04, JDK1.4.2-b20, JDK1.4.1, JDK1.4.0
Platform[s] : all
Choice comonent popup menu has unexpected size sometimes.
The following test example creates a frame with Choice list and "deleteAll" button.
"deleteAll" button clicking calls Choice.removeAll() method for the tested choice.
Please, compile and run the test and do the following steps:
- Click "deleteAll" button.
- Click the choice. Empty popup menu appers. It does not contain any items now (this is OK!),
but it has unexpectedly big height.
--------- test.java ---------
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class test extends JFrame {
public test() {
super("Choice test");
final Choice aChoice = new Choice();
for (int i=0; i<10; i++) aChoice.add((new Integer(i)).toString());
getContentPane().add(aChoice,BorderLayout.CENTER);
Button aButton = new Button("removeAll");
aButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { aChoice.removeAll(); }
});
getContentPane().add(aButton,BorderLayout.NORTH);
}
public static void main(String[] args) {
JFrame frame = new test();
frame.setSize(new Dimension(100,100));
frame.setVisible(true);
}
}
-----------------------------
Please, note that if items were removed one-by-one using Choice.remove(int) method
the popup menu height becomes less correspondingly and the following example
works fine:
--------- test1.java ---------
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class test1 extends JFrame {
public test1() {
super("Choice test 1");
final Choice aChoice = new Choice();
for (int i=0; i<10; i++) aChoice.add((new Integer(i)).toString());
getContentPane().add(aChoice,BorderLayout.CENTER);
Button aButton = new Button("remove");
aButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
for (int i=0; i<10; i++) aChoice.remove(0);
}
});
getContentPane().add(aButton,BorderLayout.NORTH);
}
public static void main(String[] args) {
JFrame frame = new test1();
frame.setSize(new Dimension(100,100));
frame.setVisible(true);
}
}
-----------------------------
Also please note that in both these examples popup menu is too wide:
it is expected that popup menu will have the same width as the Choice component
or will correspond to the item strings length.
This bug affects JCK1.4a api/java_awt/interactive/ChoiceTests.html#ChoiceTests runtime
interactive test.
Specific machine info:
======================
Hostname: linux-19
OS: RedHat Linux 7.3
======================================================================
- relates to
-
JDK-4881602 Choice popup menu has incorrect width sometimes
- Closed