-
Bug
-
Resolution: Not an Issue
-
P2
-
None
-
6
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.6.0-beta2"
Java(TM) SE Runtime Environment (build 1.6.0-beta2-b86)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b86, mixed mode, sharing)
java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)
Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows XP with SP2
A DESCRIPTION OF THE PROBLEM :
JPopupMenu strange behavior when run in different JRE versions.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
I am a computer engineering undergraduate at Chulalongkon University, Bangkok, Thailand, and I am studying J2SE in “Programming Methodology” course. Recently, I‘ve learned some GUI basics. During this time I consult JFC/Swing Trail in “The Java Tutorial” at lot. All examples in the tutorial requires me to install JavaSE 6.0, so I have to install it on my computer which it already has JDK 1.5.0 update 7 installed. When I did my homework, I have to submit them in an executable jar file. The problem is that JPopupMenu didn’t show up when I execute jar using JRE 6.0 Beta 2, but it did show up perfectly in the way I want when I execute the same jar using JRE 5.0 update 7. See my attached source code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Popup menu should show up in java 6 in the same way as java 5.
ACTUAL -
It didn't show up in java 6 at all.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
There are no error messages.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
@SuppressWarnings("serial")
public class Main extends JFrame {
...
public Main() {
super("Lab9 Swing+Event");
setSize(400, 300);
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
setLocation(200, 100);
setVisible(true);
constructPopupMenuAndPopupMenuEventListeners();
addFrameEventListeners();
}
private void constructPopupMenuAndPopupMenuEventListeners() {
popupmenu = new JPopupMenu();
menuItemRed = new JMenuItem("Red");
menuItemGreen = new JMenuItem("Green");
menuItemBlue = new JMenuItem("Blue");
popupmenu.add(menuItemRed);
popupmenu.add(menuItemGreen);
popupmenu.add(menuItemBlue);
this.add(popupmenu);
color = Color.RED;
menuItemRed.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
color = Color.RED;
repaint();
}
});
menuItemGreen.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
color = Color.GREEN;
repaint();
}
});
menuItemBlue.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
color = Color.BLUE;
repaint();
}
});
}
private void addFrameEventListeners() {
this.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
int button = e.getButton();
if (button == MouseEvent.BUTTON3) {
popupmenu.show(e.getComponent(), e.getX(), e.getY());
}
}
});
...
}
...
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Execute jar using JRE 5.0 update 7 instead.
Release Regression From : 5.0u8
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.
java version "1.6.0-beta2"
Java(TM) SE Runtime Environment (build 1.6.0-beta2-b86)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b86, mixed mode, sharing)
java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)
Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows XP with SP2
A DESCRIPTION OF THE PROBLEM :
JPopupMenu strange behavior when run in different JRE versions.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
I am a computer engineering undergraduate at Chulalongkon University, Bangkok, Thailand, and I am studying J2SE in “Programming Methodology” course. Recently, I‘ve learned some GUI basics. During this time I consult JFC/Swing Trail in “The Java Tutorial” at lot. All examples in the tutorial requires me to install JavaSE 6.0, so I have to install it on my computer which it already has JDK 1.5.0 update 7 installed. When I did my homework, I have to submit them in an executable jar file. The problem is that JPopupMenu didn’t show up when I execute jar using JRE 6.0 Beta 2, but it did show up perfectly in the way I want when I execute the same jar using JRE 5.0 update 7. See my attached source code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Popup menu should show up in java 6 in the same way as java 5.
ACTUAL -
It didn't show up in java 6 at all.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
There are no error messages.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
@SuppressWarnings("serial")
public class Main extends JFrame {
...
public Main() {
super("Lab9 Swing+Event");
setSize(400, 300);
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
setLocation(200, 100);
setVisible(true);
constructPopupMenuAndPopupMenuEventListeners();
addFrameEventListeners();
}
private void constructPopupMenuAndPopupMenuEventListeners() {
popupmenu = new JPopupMenu();
menuItemRed = new JMenuItem("Red");
menuItemGreen = new JMenuItem("Green");
menuItemBlue = new JMenuItem("Blue");
popupmenu.add(menuItemRed);
popupmenu.add(menuItemGreen);
popupmenu.add(menuItemBlue);
this.add(popupmenu);
color = Color.RED;
menuItemRed.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
color = Color.RED;
repaint();
}
});
menuItemGreen.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
color = Color.GREEN;
repaint();
}
});
menuItemBlue.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
color = Color.BLUE;
repaint();
}
});
}
private void addFrameEventListeners() {
this.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
int button = e.getButton();
if (button == MouseEvent.BUTTON3) {
popupmenu.show(e.getComponent(), e.getX(), e.getY());
}
}
});
...
}
...
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Execute jar using JRE 5.0 update 7 instead.
Release Regression From : 5.0u8
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.