-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.1, 1.1.4, 1.1.8_003, 1.3.0
-
x86
-
windows_95, windows_nt
Create a Java Application, say Foo, whose frame contains two components:
MyButton button = new MyButton("ok");
MyChoice choice = new MyChoice();
choice.addItem("item");
add(button); add(choice);
Classes MyButton and MyChoice are extended from Button/Choice, and associate with PopupMenu. For
example,
public class MyButton extends Button implements ActionListener
{
PopupMenu popup;
public MyButton(String str)
{ super(str);
popup = new PopupMenu();
MenuItem mi = new MenuItem("disable");
mi.addActionListener(this);
popup.add(mi);
mi = new MenuItem("hide");
mi.addActionListener(this);
popup.add(mi);
add(popup);
enableEvents(AWTEvent.MOUSE_EVENT_MASK);
}
public void processMouseEvent(MouseEvent e)
{
if (e.isPopupTrigger())
popup.show(e.getComponent(), e.getX(), e.getY());
}
public void actionPerformed(ActionEvent e)
{
String command = e.getActionCommand();
}
}
After compiling the above classes, Foo.class works ^D^Das expected on Salaris platform.
But, it fails to behave on WinNT 4.0.
company - Xerox , email - ###@###.###
======================================================================
diC59631 1997-11-21
Here's another with a test for choice
I extended the Choice class to support a popup menu
when the right mouse button is clicked. When the
popup is brought up, the menu item labels shows
values from the choice list. However, it seems
the correct menu item are behind the popup, the
labels are just wrong.
Here's a simplified version called TestChoice
that demonstrates the problem:
package COM.ftintl.test;
import java.awt.Choice;
import java.awt.PopupMenu;
import java.awt.MenuItem;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class TestChoice extends Choice {
private PopupActionListener actionListener;
private PopupMenu popup;
public TestChoice() {
super();
initialize();
}
private void initialize() {
addTestChoiceListeners();
populate();
actionListener = new PopupActionListener();
popup = new PopupMenu();
MenuItem desc = new MenuItem("Description");
MenuItem code = new MenuItem("Code");
MenuItem both = new MenuItem("Code and Description");
popup.add(desc);
desc.addActionListener(actionListener);
popup.add(code);
code.addActionListener(actionListener);
popup.add(both);
both.addActionListener(actionListener);
add(popup);
}
private void addTestChoiceListeners() {
addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
showPopup(e);
}
public void mouseClicked(MouseEvent e) {
showPopup(e);
}
public void mouseReleased(MouseEvent e) {
showPopup(e);
}
});
}
void showPopup(MouseEvent e) {
if (e.isPopupTrigger()) {
popup.show(this, e.getX(), e.getY());
}
}
private void populate() {
addItem("AFGHANI");
addItem("ALBANIAN LEK");
addItem("ALGERIAN DINAR");
addItem("ARGENTINE AUSTRAL");
addItem("ARUBAN GUILDER");
addItem("AUSTRALIAN DOLLAR");
addItem("AUSTRIAN SCHILLIN");
addItem("BAHAMIAN DOLLAR");
addItem("BAHRAINI DINAR");
addItem("BANGLADESH TAKA");
addItem("BARBADOS DOLLAR");
addItem("BELIZE DOLLAR");
addItem("BERMUDIAN DOLLAR");
addItem("BOLIVIAN BOLIVIAN");
addItem("BOTSWANA PULA");
addItem("BRAZILIAN CRUZEIR");
addItem("BRUNEI DOLLAR");
addItem("BULGARIAN LEV");
addItem("BURMA KYAT");
addItem("BURUNDI FRANC");
addItem("BRITISH POUND");
addItem("CANADIAN DOLLAR");
addItem("GERMAN MARK");
addItem("FRENCH FRANC");
addItem("MEXICAN PESO");
addItem("US DOLLAR");
}
class PopupActionListener implements ActionListener {
public void actionPerformed(ActionEvent event) {
//something to do
}
}
}
And here's the applet class to test it:
package COM.ftintl.test;
import java.awt.*;
import java.applet.*;
public class BugReport extends Applet {
public void init() {
// Call parents init method.
super.init();
}
public void addNotify() {
// Call parents addNotify method.
super.addNotify();
setLayout(null);
resize(406,209);
choice1 = new TestChoice();
add(choice1);
choice1.reshape(24,57,348,21);
//}}
}
//{{DECLARE_CONTROLS
COM.ftintl.test.TestChoice choice1;
//}}
}
MyButton button = new MyButton("ok");
MyChoice choice = new MyChoice();
choice.addItem("item");
add(button); add(choice);
Classes MyButton and MyChoice are extended from Button/Choice, and associate with PopupMenu. For
example,
public class MyButton extends Button implements ActionListener
{
PopupMenu popup;
public MyButton(String str)
{ super(str);
popup = new PopupMenu();
MenuItem mi = new MenuItem("disable");
mi.addActionListener(this);
popup.add(mi);
mi = new MenuItem("hide");
mi.addActionListener(this);
popup.add(mi);
add(popup);
enableEvents(AWTEvent.MOUSE_EVENT_MASK);
}
public void processMouseEvent(MouseEvent e)
{
if (e.isPopupTrigger())
popup.show(e.getComponent(), e.getX(), e.getY());
}
public void actionPerformed(ActionEvent e)
{
String command = e.getActionCommand();
}
}
After compiling the above classes, Foo.class works ^D^Das expected on Salaris platform.
But, it fails to behave on WinNT 4.0.
company - Xerox , email - ###@###.###
======================================================================
diC59631 1997-11-21
Here's another with a test for choice
I extended the Choice class to support a popup menu
when the right mouse button is clicked. When the
popup is brought up, the menu item labels shows
values from the choice list. However, it seems
the correct menu item are behind the popup, the
labels are just wrong.
Here's a simplified version called TestChoice
that demonstrates the problem:
package COM.ftintl.test;
import java.awt.Choice;
import java.awt.PopupMenu;
import java.awt.MenuItem;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class TestChoice extends Choice {
private PopupActionListener actionListener;
private PopupMenu popup;
public TestChoice() {
super();
initialize();
}
private void initialize() {
addTestChoiceListeners();
populate();
actionListener = new PopupActionListener();
popup = new PopupMenu();
MenuItem desc = new MenuItem("Description");
MenuItem code = new MenuItem("Code");
MenuItem both = new MenuItem("Code and Description");
popup.add(desc);
desc.addActionListener(actionListener);
popup.add(code);
code.addActionListener(actionListener);
popup.add(both);
both.addActionListener(actionListener);
add(popup);
}
private void addTestChoiceListeners() {
addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
showPopup(e);
}
public void mouseClicked(MouseEvent e) {
showPopup(e);
}
public void mouseReleased(MouseEvent e) {
showPopup(e);
}
});
}
void showPopup(MouseEvent e) {
if (e.isPopupTrigger()) {
popup.show(this, e.getX(), e.getY());
}
}
private void populate() {
addItem("AFGHANI");
addItem("ALBANIAN LEK");
addItem("ALGERIAN DINAR");
addItem("ARGENTINE AUSTRAL");
addItem("ARUBAN GUILDER");
addItem("AUSTRALIAN DOLLAR");
addItem("AUSTRIAN SCHILLIN");
addItem("BAHAMIAN DOLLAR");
addItem("BAHRAINI DINAR");
addItem("BANGLADESH TAKA");
addItem("BARBADOS DOLLAR");
addItem("BELIZE DOLLAR");
addItem("BERMUDIAN DOLLAR");
addItem("BOLIVIAN BOLIVIAN");
addItem("BOTSWANA PULA");
addItem("BRAZILIAN CRUZEIR");
addItem("BRUNEI DOLLAR");
addItem("BULGARIAN LEV");
addItem("BURMA KYAT");
addItem("BURUNDI FRANC");
addItem("BRITISH POUND");
addItem("CANADIAN DOLLAR");
addItem("GERMAN MARK");
addItem("FRENCH FRANC");
addItem("MEXICAN PESO");
addItem("US DOLLAR");
}
class PopupActionListener implements ActionListener {
public void actionPerformed(ActionEvent event) {
//something to do
}
}
}
And here's the applet class to test it:
package COM.ftintl.test;
import java.awt.*;
import java.applet.*;
public class BugReport extends Applet {
public void init() {
// Call parents init method.
super.init();
}
public void addNotify() {
// Call parents addNotify method.
super.addNotify();
setLayout(null);
resize(406,209);
choice1 = new TestChoice();
add(choice1);
choice1.reshape(24,57,348,21);
//}}
}
//{{DECLARE_CONTROLS
COM.ftintl.test.TestChoice choice1;
//}}
}
- duplicates
-
JDK-4181790 Popup menu displayed incorrect entries on Win32 on 1.1.6, 1.2
-
- Closed
-