class. It provides an implementation of the
Java Accessibility API appropriate to menu bar user-interface
elements.
Method from javax.swing.JMenuBar$AccessibleJMenuBar Detail: |
public void addAccessibleSelection(int i) {
// first close up any open menu
int j = getSelectionModel().getSelectedIndex();
if (i == j) {
return;
}
if (j >= 0 && j < getMenuCount()) {
JMenu menu = getMenu(j);
if (menu != null) {
MenuSelectionManager.defaultManager().setSelectedPath(null);
// menu.setPopupMenuVisible(false);
}
}
// now popup the new menu
getSelectionModel().setSelectedIndex(i);
JMenu menu = getMenu(i);
if (menu != null) {
MenuElement me[] = new MenuElement[3];
me[0] = JMenuBar.this;
me[1] = menu;
me[2] = menu.getPopupMenu();
MenuSelectionManager.defaultManager().setSelectedPath(me);
// menu.setPopupMenuVisible(true);
}
}
Selects the nth menu in the menu bar, forcing it to
pop up. If another menu is popped up, this will force
it to close. If the nth menu is already selected, this
method has no effect. |
public void clearAccessibleSelection() {
int i = getSelectionModel().getSelectedIndex();
if (i >= 0 && i < getMenuCount()) {
JMenu menu = getMenu(i);
if (menu != null) {
MenuSelectionManager.defaultManager().setSelectedPath(null);
// menu.setPopupMenuVisible(false);
}
}
getSelectionModel().setSelectedIndex(-1);
}
Clears the selection in the object, so that nothing in the
object is selected. This will close any open menu. |
public AccessibleRole getAccessibleRole() {
return AccessibleRole.MENU_BAR;
}
Get the role of this object. |
public AccessibleSelection getAccessibleSelection() {
return this;
}
Get the AccessibleSelection associated with this object. In the
implementation of the Java Accessibility API for this class,
return this object, which is responsible for implementing the
AccessibleSelection interface on behalf of itself. |
public Accessible getAccessibleSelection(int i) {
if (isSelected()) {
if (i != 0) { // single selection model for JMenuBar
return null;
}
int j = getSelectionModel().getSelectedIndex();
if (getComponentAtIndex(j) instanceof Accessible) {
return (Accessible) getComponentAtIndex(j);
}
}
return null;
}
Returns the currently selected menu if one is selected,
otherwise null. |
public int getAccessibleSelectionCount() {
if (isSelected()) {
return 1;
} else {
return 0;
}
}
Returns 1 if a menu is currently selected in this menu bar. |
public AccessibleStateSet getAccessibleStateSet() {
AccessibleStateSet states = super.getAccessibleStateSet();
return states;
}
Get the accessible state set of this object. |
public boolean isAccessibleChildSelected(int i) {
return (i == getSelectionModel().getSelectedIndex());
}
Returns true if the current child of this object is selected. |
public void removeAccessibleSelection(int i) {
if (i >= 0 && i < getMenuCount()) {
JMenu menu = getMenu(i);
if (menu != null) {
MenuSelectionManager.defaultManager().setSelectedPath(null);
// menu.setPopupMenuVisible(false);
}
getSelectionModel().setSelectedIndex(-1);
}
}
Removes the nth selected item in the object from the object's
selection. If the nth item isn't currently selected, this
method has no effect. Otherwise, it closes the popup menu. |
public void selectAllAccessibleSelection() {
}
Normally causes every selected item in the object to be selected
if the object supports multiple selections. This method
makes no sense in a menu bar, and so does nothing. |