[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-classpath] [bug #13683] Swing: JMenu - setSelected behavior
From: |
Robert Schuster |
Subject: |
[bug-classpath] [bug #13683] Swing: JMenu - setSelected behavior |
Date: |
Fri, 8 Jul 2005 00:57:47 +0000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.7.8) Gecko/20050514 |
URL:
<http://savannah.gnu.org/bugs/?func=detailitem&item_id=13683>
Summary: Swing: JMenu - setSelected behavior
Project: classpath
Submitted by: rschuster
Submitted on: Fri 07/08/2005 at 00:57
Category: classpath
Severity: 3 - Normal
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Platform Version: None
_______________________________________________________
Details:
Call JMenu.setSelected(true):
JDK:
- JMenu will appear as selected (highlighted background) regardless of whether
the menu is enabled or not. (Popup window will *not* show up)
Classpath 0.16:
- JMenu will appear selected and the popup is opened only when the menu is
enabled
- nothing happens when the menu is disabled.
Test code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Test {
public static void main(String[] args) throws Exception {
final JFrame f = new JFrame("License choser");
Container cp = f.getContentPane();
cp.setLayout(new FlowLayout());
final JMenuBar bar = new JMenuBar();
final JCheckBox switcher = new JCheckBox("enable menu", true);
final JButton selecter = new JButton("select GNU");
cp.add(switcher);
cp.add(selecter);
final JMenu gnu = new JMenu("GNU");
gnu.setMnemonic(KeyEvent.VK_G);
gnu.add(new JMenuItem("GPL"));
gnu.add(new JMenuItem("LGPL"));
gnu.add(new JMenuItem("GFDL"));
final JMenu asf = new JMenu("ASF");
asf.setMnemonic(KeyEvent.VK_A);
asf.add(new JMenuItem("ASL 2.0"));
asf.add(new JMenuItem("ASL 1.0"));
final JMenu bsd = new JMenu("BSD");
bsd.setMnemonic(KeyEvent.VK_B);
bsd.add(new JMenuItem("mod. BSDL"));
bsd.add(new JMenuItem("MIT X11"));
bar.add(asf);
bar.add(bsd);
bar.add(gnu);
f.setJMenuBar(bar);
switcher.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
boolean t = switcher.isSelected();
gnu.setEnabled(t);
asf.setEnabled(t);
bsd.setEnabled(t);
System.out.println("JMenu is set to " + (t ?
"on" : "off"));
}
});
selecter.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
gnu.setSelected(true);
}
});
f.pack();
f.show();
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
f.dispose();
System.exit(0);
}
});
}
}
You will see 3 menus in the bar.
With enabled menus (checked checkbox) click on "select GNU". On JDK this will
hightlight the GNU menu. On Classpath it will highlight the menu AND open the
popup window.
With an unchecked checkbox, click "select GNU". On JDK this will highlight the
"GNU" menu - on Classpath nothing happens.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?func=detailitem&item_id=13683>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [bug-classpath] [bug #13683] Swing: JMenu - setSelected behavior,
Robert Schuster <=