Accessibilty and JPopupMenu

I am using JAWS 6 with JDK 1.4.2_06 and Access Bridge 1.2.
If I add Menuitems to a JMenu which is added to the menubar everything works as expected. One of the menu items is another JMenu, a sub-menu. When JAWS reads this it speaks "submenu" indicating that there is a sub-menu to the right of the current menu item. However, If I attached the exact same menuitems to a JPopupMenu,
JAWS never speaks "submenu" so the user has no iindication that there is a sub-menu to the right.
I've taken the attached code from "The JFC Swing Tutorial - Second Edition" and tweaked it slightly so the menubar and popup menu contain the same items.
It seems as if the accessibility api is expecting the first set of menu items to be attached to a menu parent.
If worked around this for now by adding another top level menu to the popupmenu to which I add the menuitems.
Is this a Java or JAWS bug ?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
* Like MenuDemo, but with popup menus added.
public class TextFieldDemo {
JTextArea output;
JScrollPane scrollPane;
String newline = "\n";
public JMenuBar createMenuBar() {
JMenuBar menuBar;
JMenu menu;
//Create the menu bar.
menuBar = new JMenuBar();
//Build the first menu.
menu = new JMenu("A Menu");
menu.setMnemonic(KeyEvent.VK_A);
menu.getAccessibleContext().setAccessibleDescription(
"The only menu in this program that has menu items");
JMenuItem[] mi = createAMenu();
for(int i=0; i < mi.length; ++i)
menu.add(mi);
menuBar.add(menu);
//Build second menu in the menu bar.
menu = new JMenu("Another Menu");
menu.setMnemonic(KeyEvent.VK_N);
menu.getAccessibleContext().setAccessibleDescription(
"This menu does nothing");
menuBar.add(menu);
return menuBar;
public Container createContentPane() {
//Create the content-pane-to-be.
JPanel contentPane = new JPanel(new BorderLayout());
contentPane.setOpaque(true);
//Create a scrolled text area.
output = new JTextArea(5, 30);
output.setEditable(false);
scrollPane = new JScrollPane(output);
//Add the text area to the content pane.
contentPane.add(scrollPane, BorderLayout.CENTER);
return contentPane;
public void createPopupMenu() {
JMenuItem menuItem;
//Create the popup menu.
JPopupMenu popup = new JPopupMenu();
JMenuItem[] mi = createAMenu();
for(int i=0; i < mi.length; ++i)
popup.add(mi[i]);
//Add listener to the text area so the popup menu can come up.
MouseListener popupListener = new PopupListener(popup);
output.addMouseListener(popupListener);
private static void createAndShowGUI() {
//Make sure we have nice window decorations.
JFrame.setDefaultLookAndFeelDecorated(true);
//Create and set up the window.
JFrame frame = new JFrame("TextFieldDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create/set menu bar and content pane.
TextFieldDemo demo = new TextFieldDemo();
frame.setJMenuBar(demo.createMenuBar());
frame.setContentPane(demo.createContentPane());
//Create and set up the popup menu.
demo.createPopupMenu();
//Display the window.
frame.setSize(450, 260);
frame.setVisible(true);
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
class PopupListener extends MouseAdapter {
JPopupMenu popup;
PopupListener(JPopupMenu popupMenu) {
popup = popupMenu;
public void mousePressed(MouseEvent e) {
maybeShowPopup(e);
public void mouseReleased(MouseEvent e) {
maybeShowPopup(e);
private void maybeShowPopup(MouseEvent e) {
if (e.isPopupTrigger()) {
popup.show(e.getComponent(),
e.getX(), e.getY());
private JMenuItem[] createAMenu()
JMenu submenu;
JMenuItem menuItem;
JRadioButtonMenuItem rbMenuItem;
JCheckBoxMenuItem cbMenuItem;
JMenuItem items[] = new JMenuItem[8];
//a group of JMenuItems
menuItem = new JMenuItem("A text-only menu item",
KeyEvent.VK_T);
//menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead
menuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_1, ActionEvent.ALT_MASK));
menuItem.getAccessibleContext().setAccessibleDescription(
"This doesn't really do anything");
items[0]=menuItem;
menuItem = new JMenuItem("Both text and icon");
menuItem.setMnemonic(KeyEvent.VK_B);
items[1]=menuItem;
menuItem = new JMenuItem("icon only");
menuItem.setMnemonic(KeyEvent.VK_D);
items[2]=menuItem;
//a group of radio button menu items
ButtonGroup group = new ButtonGroup();
rbMenuItem = new JRadioButtonMenuItem("A radio button menu item");
rbMenuItem.setSelected(true);
rbMenuItem.setMnemonic(KeyEvent.VK_R);
group.add(rbMenuItem);
items[3]=rbMenuItem;
rbMenuItem = new JRadioButtonMenuItem("Another one");
rbMenuItem.setMnemonic(KeyEvent.VK_O);
group.add(rbMenuItem);
items[4]=rbMenuItem;
//a group of check box menu items
cbMenuItem = new JCheckBoxMenuItem("A check box menu item");
cbMenuItem.setMnemonic(KeyEvent.VK_C);
items[5]=cbMenuItem;
cbMenuItem = new JCheckBoxMenuItem("Another one");
cbMenuItem.setMnemonic(KeyEvent.VK_H);
items[6]=cbMenuItem;
//a submenu
submenu = new JMenu("A submenu");
submenu.setMnemonic(KeyEvent.VK_S);
menuItem = new JMenuItem("An item in the submenu");
menuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_2, ActionEvent.ALT_MASK));
submenu.add(menuItem);
menuItem = new JMenuItem("Another item");
submenu.add(menuItem);
items[7]=submenu;
return(items);

Hi;
I want to add chekboxes to a poupup menu ,how can I do that. I already have a submenu with names of columns ton hide and show them using chekcboxes and i want that same menu as a popup when i click in the tableheader.
thanx

Similar Messages

  • Problem with InputVerifier and JPopupMenu

    Hello, I have a problem related to the usage of InputVerifier and JPopupMenu.
    Consider the following scenario:
    - A frame composed of two components: a JTextField and a JComboBox
    - An InputVerifier that was set in the JComboBox (and in its associated JTextComponent)
    - A JPopupMenu which is enabled by a right mouse click over the components of the frame.
    The verify() method of the InputVerifier class is executed every time the focus is on the JComboBox and is requested by other component.
    Suppose that the focus is on the JComboBox, and a right mouse click is executed over this components. In summary, we have:
    1) The method verify() of the InputVerifier associated to the JComboBox is executed
    2) The focus changes from the JTextComponent (associated to the JComboBox) to the JRootPane (associated to the JTextComponent (that is associated to the JPopupMenu)).
    Now suppose that, the user clicks in the JTextField component (note that the JPopupMenu is visible and has the focus). What happens is that the focus goes from the JRootPane -> JTextComponent (associated to the JComboBox) -> JTextField.
    Despite the focus flow through the JTextComponent, the Swing plattaform, when executing the runInputVerifier() in the JComponent context, get the JRootPane component as the focusOwner instead of the JTextComponent.
    In this way, the Swing platform tries to invoke the InputVerify of the JRootPane (that is set with "null"), and the JComboBox InputVerifier is not executed as expected.
    It works as if the focus is flowing from the JRootPane directly to the JTextField.
    However, if the user clicks on the JComboBox before clicking in the JTextField, the Swing platform executes the correct InputVerifier, i.e., the one associated to the JComboBox (actually, the one associated to the JTextComponent).
    Any thoughts to solve this problem?
    Thanks

    A plus information, I am using jdk1.5.0_22.

  • JMenuItem and JPopupMenu

    Is there an esay why round this issue?
    I've got a JMenuItem that I would like to add to MULTIPLE menu's.
    when I add the JMenuItem to a "new" JPopup it dissappears from the previous one.
    eg
    JPopupMenu menu1 = new JPopupMenu();
    JPopupMenu menu2 = new JPopupMenu();
    JMenuItem disappearingItem = new JMenuItem("I'll only appear once");
    menu1.add(disappearingItem);
    menu2.add(disappearingItem);I know I could "just" create a new JMenuItem that is the same, but this seems like a hassle. Why can't I have the same JMenuItem appearing in different menus?
    Thanks,
    Steve

    Hello,
    I think its to avoid incosistency.
    This is the responsible source-code from java.awt.Container:
    /* Reparent the component and tidy up the tree's state. */
             if (comp.parent != null) {
              comp.parent.remove(comp);
                        if (index > ncomponents) {
                            throw new IllegalArgumentException("illegal component position");
                }Ragards,
    Tim

  • Netbeans and JPopupMenu

    Im having a problem creating a JPopupMenu,
    Im using the netbeans GUI builder, I've added the popup menu to the Jframe, and can get it to display itself when right clicked, however i cannot get it to hold any components.
    I tried adding a menu item to it, first by dragging and dropping, which did not work, then by right clicking and adding from pallete, which did work.
    However, the menu item is not diplayed.
    I tried adding various other containers too, but they are not displayed either, any ideas what im doing wrong?
    Thanks,
    James

    Yes quite, netbeans is absolutley fine, frankly, the java website suggests using it for gridbag... Some people just like to feel 1337.
    Curiously its working now, kinda.
    There seems to be a bug of somesort that causes the palette to empty, at which point i have to recreate the project and it comes back, since then however, the popupmenu seems to work, although the offset is a bit wonky
    jPopupMenu1.setLocation(evt.getX(), evt.getY());
                jPopupMenu1.setEnabled(true);
                jPopupMenu1.setVisible(true); that should put the menu where the mouse was at the time, however it seems to be off slightly, any ideas why?

  • JCheckBox and JPopupMenu

    I have a JPopupMenu containing several checkboxes within some submenus. Everytime I select one check box, the popup menu closes and I have to do it all over again. Is there any way to allow multiple selections in a JPopupMenu?
    Thanks!

    I have it set up so when I select a specific checkbox a popup menu appears right next to it. A dialog would be nice, but I have put too much time into this to change it now. Any thoughts about how to keep the popup menu open while selections are being made? Thanks for replying so quick!

  • Problem with  JTree and JPopupMenu

    Hi,
    I'm using a JPopupMenu with a JPanel in it. In the panel
    I want to have a JTree. I can build the tree without
    problems but when I try to "go down" in the tree it
    vanishes. This happens only the first time that I
    access a node. When I initialize the menu a second
    time the node I just pressed works fine.
    What is the problem????
    Here is a sample of my code.
    popUpMenu = new JPopupMenu();
    thePanel = new JPanel();
    thePanel .setLayout(new GridBagLayout());
    popUpMenu .add(thePanel );
    DefaultMutableTreeNode top = new DefaultMutableTreeNode("The top");
    DefaultMutableTreeNode secondNode = null;
    DefaultMutableTreeNode firstNode = null;
    firstNode = new DefaultMutableTreeNode("One node");
    top.add(firstNode);
    secondNode= new DefaultMutableTreeNode("One node");
    firstNode.add(secondNode);
    buildConstraints(gbc, 1, 0, 1, 5, 5, 5, 5, 2, 1); //My contraintsmethod
    JTree tree = new JTree(top);
    thePanel .add(tree, gbc);

    Mate, why are you putting a JPanel in a JPopupMenu? I'd be interested to look at a screenshot of this.
    Mitch

  • JTable And JPopupMenu

    Hello, In a JTable i want when the user press the right button of the mouse to chose an action on JPopupMenu it automaticly select the row where the Press The Right Button.

    In your MouseListener you use table.getRowAtPoint(...) to get the row, then you can use table.setRowSelectionInverval(...) to select the row.

  • How can I distinguish a JMenuItem , JPopupMenu and TopLevelMenu?

    I used the following methods to get the component who (a menu)gains the focus:
    JComponent com = JFrmame.getFocusOwner();
    or
    MenuSelectionManager menuMgr = MenuSelectionManager.defaultManager();
    MenuElement[] menuPath = menuMgr.getSelectedPath();
    if(menuPath != 0) {
    JComponent comp = Array.get(menuPath, menuPath.length-1); // this is the item with the focus
    then I need to use getAction() to get the menuItem's action. But how can I filter JMenuItem and JPopUpMenu from TopLevelMenu (JMenuBar item) ?
    Thanks!

    The instanceof may provide the simplest solution, since JPopupMenu, JMenuBar and JMenuItem don't have any kind of ancestor relationship with each other.if (comp instanceof JPopupMenu) {
        // Popup
    } else if (comp instanceof JMenuItem) {
        // Item
    } else if (comp instanceof JMenuBar) {
        // Bar
    } else ...?Hope this helps,
    -Troy

  • I need to shut my zoom off on my Iphone 5, it is to large and can't use the phone.

    I have a iphone 5  from a person.  Been learning how to use it by myself.  I went to accessibilty and clicked on Zoom and was experimenting with it and got the screen to large and can't get it back to normal, now I can't use the phone because it is magnified so much.  Tried to connect to help but couldn"t see the message that Apple sent to me on my phone.  Don't have all the specs because the  party was out of state from where she lived therefore I have any more info.  Please help.

    To turn off Zoom double-tap the screen with three fingers.

  • JpopupMenu doesn't popup in Java6

    I have a window set up as a drop target for receiving urls and files. When files or urls are dropped, a popup menu is generated based on what has been dropped and then the menu is shown.
    In Java 1.4 this all worked fine when the Drop Target window extended JWindow, but not now in J6. The only way I can get this to work is to extend JFrame, but then I get an extra window showing in the Windows taskbar which I don't want. I've did try extending JDialog but this fails to show the popup menu also.
    Can anyone help?
    Thanks
    KC

    I'd create a SSCCE to demonstrate your problem.
    There are too many classes involved to 'guestimate' what could be causing your problem.
    ... and JPopupMenu works fine for me, and I bet everyone else, so there has to be a problem with your code.
    Maybe you should just completely recode the particular area that's giving you problems? People always try to 'adapt' their code... I've always had better luck just using the new tools from the ground up.

  • How can I turn off noise cancellation in the iPhone 5C?

    I'm having trouble finding the noise cancellation on this iPhone. I know you're supposed to go into settings, then general, under accessibilty, and it's supposed to be the last option under hearing but it's not there. I'm not sure if I can find it somewhere else or not. I have found it on the iPhone 5S just not on the 5C. It is interfering with my FaceTIme conversations and I'd like to be able to turn it off.

    I'm not certain if the 5C has the noise cancellation. If you look at the back of the phone near the camera, do you see a small hole there? I'm wondering since you do not locate the switch in Settings. Also, I'm curious as to how it is interferring with your FaceTime calls. I'm not doubting your word, I would just like to know how it is doing that.

  • Highlight current form field with css

    Anyone know how to highlight the current text box a user is
    in - using css
    Im thinking of accessibilty and the benefit it could have for
    people with visual acuity problems
    Thanks

    "Glowing text fields" - here:
    http://sourtea.com/articles.php
    Shane H
    [email protected]
    http://www.avenuedesigners.com
    =============================================
    Web Dev Articles, Photography, and more:
    http://sourtea.com
    =============================================
    Proud GAWDS Member
    http://www.gawds.org/showmember.php?memberid=1495
    Delivering accessible websites to all ...
    =============================================
    "quiero mas" <[email protected]> wrote in message
    news:edqjq5$t22$[email protected]..
    > Anyone know how to highlight the current text box a user
    is in - using css
    > Im thinking of accessibilty and the benefit it could
    have for people with
    > visual acuity problems
    >
    > Thanks

  • How Do I Enable Closed Captions in iTunes 11?

    In iTunes 10 I had enabled Preferences>Playback>Show closed captioning when available. This check box has been removed from iTunes 11. How do I enable closed captioning in iTunes 11?
    Thanks in advance,
    Steve  = : ^ )

    Thanks. This represents a change in conceptualisation from Apple. Previously, closed captions were part of Accessibilty and it was assumed that anyone usings captions would want them on 24/7. It still works this way on iOS devices. On the Apple TV, e.g., closed captions are enabled for the device, via Settings > General > Accessibility > Closed Captions + SDH. Once enabled, captions will be displayed for any content that has them.
    Subtitles on the other hand (and subtitles may be in the same language as the audio, they're not just 'foreign') must be enabled or disabled per item of content via the Subtitles menu, which is arrived at by holding the centre button on the remote.
    This was the way it used to work in iTunes also. Rolling the Closed Captions into the subtitles menu is new, though I guess it makes sense.
    Steve  = : ^ )

  • Highlight text in TextField

    I am creating an autocomplete feature for a school project using JAVA. I have created a TextField with a keyListener to lister for keypresses. After the keypress, I search a list for possible matches; stopping on the first match which is then st to the TextField. I have one problem I am trying to fix. I would like to highlight all the text after the caret position. However, when you highlight the text it moves the caret position to the end of the selection. If I set it back to the position th user is typing it deselects my selected text.
    How can I highlight text after teh caret position in a TextField?

    hi,
    try to search the forum and web by the words autocompleting JComboBox, a lot of hints will appear. As you probably know, the JComboBox consists of the JTextField, JButton and JPopupMenu, so autocompletition will be nearly the same.
    This site si very good, I think:
    http://www.orbital-computer.de/JComboBox/
    Good luck, hope I help you
    L.P.

  • Preview the contents of my ComboBoxes at once

    I need to implement a "preview the content of my comboBoxes" feature.
    Technically, I would like to show all the ComboPopups of the ComboBoxes of my app, at the same time.
    At the moment, I have a small example to prototype this comboBox tweaking :
    http://pastebin.com/r7jEFUjL
    In this code, I use my own PopupFactory. It creates Popups that hide() only if a given boolean is set to true.
    (the checkBox at the top of the prototype helps you control that boolean).
    If you click the comboBoxes of the prototype, their comboPopup will appear and not disappear.
    But, from that moment, the comboBoxes will behave erratically.
    If you switch the boolean to false, the popups will not come back to normal behaviour.
    And you will get some dirty zones under the comboBoxes instead of the correct repaint().
    After some code digging, it seems that popups are really not meant to be in multiple at the same time in Swing.
    Can anyone with good knowledge of PopupFactory, BasicComboBoxUI and JpopupMenu help me find a way to achieve
    my "preview the content of my comboBoxes" feature?
    Edited by: 809615 on 10 nov. 2010 12:33

    You can try to scale the contents to browser width which would be same for all screens.
    For example : Create a rectangle make it 100% browser width and then fill image.
    When user will view the page it would be same for screen size as the fill will be browser width.
    Thanks,
    Sanjit

Maybe you are looking for

  • Unable to Copy File From Terminal Server to Client Share

    Hi For years client have been able to copy files from our Windows 2003 Terminal Server to their local workstation using: copy myfile \\tsclient\mydrive\myfolder However we upgraded to Windows 2012 Server R2 and now Windows 7 Pro clients cannot copy f

  • SAP MMC not showing SID after sap gui install and reboot of the server

    Hi,  after SAPGUI 7.10 install on our server and rebooting of the same,  SAP MMC says  u201CMMC could not create the snap-inu201D. We are desperately trying to find a solution.  We did the following:  Uninstalled the gui. 1) Uninstalled the SAPMMC sn

  • Looking for Sytem 6.x

    I recently was given a Mac SE by a friend who said I could have it if I got it working. I tried booting up and discovered that the system software on the HDD is either gone or corrupted -- I need a boot disc of the 800k variety, but I have no way of

  • Windows 8.1 configure app listings.

    The Start page has a downward pointing arrow which reveals list fo installed apps.   Is it possible to define my own headings and then move apps to the list I feel appropriate?    Fences software offers this sort of facility but on the desktop rather

  • JDev 9.0.3.1035 New Project Wizard Error #2

    I tried to run the File ~ Projects ~ Project from existing war(.war) file Wizard on JDev 9.0.3.1035 on win2000. On Step 2 of 2 it asks for the WAR File and and the Root Directory for the Web Module. When I browse to the .war file, It doesn't let me s