本文整理汇总了Java中javax.accessibility.AccessibleState类的典型用法代码示例。如果您正苦于以下问题:Java AccessibleState类的具体用法?Java AccessibleState怎么用?Java AccessibleState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AccessibleState类属于javax.accessibility包,在下文中一共展示了AccessibleState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAccessibleStateSet
import javax.accessibility.AccessibleState; //导入依赖的package包/类
/**
* Returns a state set describing this component's state.
*
* @return a new state set
* @see AccessibleState
*/
public AccessibleStateSet getAccessibleStateSet()
{
AccessibleStateSet s = new AccessibleStateSet();
if (Component.this.isEnabled())
s.add(AccessibleState.ENABLED);
if (isFocusable())
s.add(AccessibleState.FOCUSABLE);
if (isFocusOwner())
s.add(AccessibleState.FOCUSED);
// Note: While the java.awt.Component has an 'opaque' property, it
// seems that it is not added to the accessible state set here, even
// if this property is true. However, it is handled for
// javax.swing.JComponent, so we add it there.
if (Component.this.isShowing())
s.add(AccessibleState.SHOWING);
if (Component.this.isVisible())
s.add(AccessibleState.VISIBLE);
return s;
}
示例2: removeAccessibleSelection
import javax.accessibility.AccessibleState; //导入依赖的package包/类
/**
* Removes the specified selected item in the object from the
* object's selection.
*
* @param i - the specified item to remove
*/
public void removeAccessibleSelection(int i)
{
if (mod != null)
{
Object child = mod.getChild(tp.getLastPathComponent(), i);
if (child != null)
{
if (!states.contains(AccessibleState.MULTISELECTABLE))
clearAccessibleSelection();
if (selectionList.contains(child))
{
selectionList.remove(child);
tree.removeSelectionPath(tp.pathByAddingChild(child));
}
}
}
}
示例3: selectAllAccessibleSelection
import javax.accessibility.AccessibleState; //导入依赖的package包/类
/**
* Causes every selected item in the object to be selected if the object
* supports multiple selections.
*/
public void selectAllAccessibleSelection()
{
Object parent = tp.getLastPathComponent();
if (mod != null)
{
for (int i = 0; i < mod.getChildCount(parent); i++)
{
Object child = mod.getChild(parent, i);
if (child != null)
{
if (!states.contains(AccessibleState.MULTISELECTABLE))
clearAccessibleSelection();
if (selectionList.contains(child))
{
selectionList.add(child);
tree.addSelectionPath(tp.pathByAddingChild(child));
}
}
}
}
}
示例4: getAccessibleStateSet
import javax.accessibility.AccessibleState; //导入依赖的package包/类
/**
* Returns the accessible state set of this accessible table cell.
*
* @return the accessible state set of this accessible table cell
*/
public AccessibleStateSet getAccessibleStateSet()
{
AccessibleStateSet state = new AccessibleStateSet();
// Figure out the SHOWING state.
Rectangle visibleRect = getVisibleRect();
Rectangle cellRect = getCellRect(row, column, false);
if (visibleRect.intersects(cellRect))
state.add(AccessibleState.SHOWING);
// Figure out SELECTED state.
if (isCellSelected(row, column))
state.add(AccessibleState.SELECTED);
// Figure out ACTIVE state.
if (row == getSelectedRow() && column == getSelectedColumn())
state.add(AccessibleState.ACTIVE);
// TRANSIENT seems to be always set in the RI.
state.add(AccessibleState.TRANSIENT);
// TODO: Any other state to handle here?
return state;
}
示例5: getAccessibleStateSet
import javax.accessibility.AccessibleState; //导入依赖的package包/类
/**
* Returns the accessible state set of this list item.
*
* @return the accessible state set of this list item
*/
public AccessibleStateSet getAccessibleStateSet()
{
AccessibleStateSet states = new AccessibleStateSet();
if (isVisible())
states.add(AccessibleState.VISIBLE);
if (isShowing())
states.add(AccessibleState.SHOWING);
if (isFocusTraversable())
states.add(AccessibleState.FOCUSABLE);
// TODO: How should the active state be handled? The API docs
// suggest that this state is set on the activated list child,
// that is the one that is drawn with a box. However, I don't know how
// to implement this.
// TODO: We set the selectable state here because list children are
// selectable. Is there a way to disable single children?
if (parent.isEnabled())
states.add(AccessibleState.SELECTABLE);
if (parent.isSelectedIndex(listIndex))
states.add(AccessibleState.SELECTED);
// TODO: Handle more states here?
return states;
}
示例6: removeAccessibleSelection
import javax.accessibility.AccessibleState; //导入依赖的package包/类
/**
* Removes the specified selected item in the object from the
* object's selection.
*
* @param i - the specified item to remove
*/
public void removeAccessibleSelection(int i)
{
if (mod != null)
{
Object child = mod.getChild(tp.getLastPathComponent(), i);
if (child != null)
{
if (!states.contains(AccessibleState.MULTISELECTABLE))
clearAccessibleSelection();
if (selectionList.contains(child))
{
selectionList.remove(child);
tree.removeSelectionPath(tp.pathByAddingChild(child));
}
}
}
}
示例7: selectAllAccessibleSelection
import javax.accessibility.AccessibleState; //导入依赖的package包/类
/**
* Causes every selected item in the object to be selected if the object
* supports multiple selections.
*/
public void selectAllAccessibleSelection()
{
Object parent = tp.getLastPathComponent();
if (mod != null)
{
for (int i = 0; i < mod.getChildCount(parent); i++)
{
Object child = mod.getChild(parent, i);
if (child != null)
{
if (!states.contains(AccessibleState.MULTISELECTABLE))
clearAccessibleSelection();
if (selectionList.contains(child))
{
selectionList.add(child);
tree.addSelectionPath(tp.pathByAddingChild(child));
}
}
}
}
}
示例8: getAccessibleStateSet
import javax.accessibility.AccessibleState; //导入依赖的package包/类
/**
* Returns the accessible state set of this list item.
*
* @return the accessible state set of this list item
*/
public AccessibleStateSet getAccessibleStateSet()
{
AccessibleStateSet states = new AccessibleStateSet();
if (isVisible())
states.add(AccessibleState.VISIBLE);
if (isShowing())
states.add(AccessibleState.SHOWING);
if (isFocusTraversable())
states.add(AccessibleState.FOCUSABLE);
// TODO: How should the active state be handled? The API docs
// suggest that this state is set on the activated list child,
// that is the one that is drawn with a box. However, I don't know how
// to implement this.
// TODO: We set the selectable state here because list children are
// selectable. Is there a way to disable single children?
if (parent.isEnabled())
states.add(AccessibleState.SELECTABLE);
if (parent.isSelectedIndex(listIndex))
states.add(AccessibleState.SELECTED);
// TODO: Handle more states here?
return states;
}
示例9: fireAccessibleStateChange
import javax.accessibility.AccessibleState; //导入依赖的package包/类
private void fireAccessibleStateChange(AccessibleState state, boolean value) {
if (behaviour.isLightweight()) {
return;
}
AccessibleContext ac = getAccessibleContext();
if (ac != null) {
AccessibleState oldValue = null;
AccessibleState newValue = null;
if (value) {
newValue = state;
} else {
oldValue = state;
}
ac.firePropertyChange(AccessibleContext.ACCESSIBLE_STATE_PROPERTY, oldValue,
newValue);
}
}
示例10: getAccessibleStateSet
import javax.accessibility.AccessibleState; //导入依赖的package包/类
@Override
public AccessibleStateSet getAccessibleStateSet() {
toolkit.lockAWT();
try {
AccessibleStateSet set = super.getAccessibleStateSet();
if (isFocused()) {
set.add(AccessibleState.ACTIVE);
}
if (isResizable()) {
set.add(AccessibleState.RESIZABLE);
}
return set;
} finally {
toolkit.unlockAWT();
}
}
示例11: getAccessibleStateSet
import javax.accessibility.AccessibleState; //导入依赖的package包/类
@Override
public AccessibleStateSet getAccessibleStateSet() {
toolkit.lockAWT();
try {
AccessibleStateSet aStateSet = super.getAccessibleStateSet();
AccessibleState aState = null;
switch (getOrientation()) {
case VERTICAL:
aState = AccessibleState.VERTICAL;
break;
case HORIZONTAL:
aState = AccessibleState.HORIZONTAL;
break;
}
if (aState != null) {
aStateSet.add(aState);
}
return aStateSet;
} finally {
toolkit.unlockAWT();
}
}
示例12: testGetAccessibleStateSet
import javax.accessibility.AccessibleState; //导入依赖的package包/类
public final void testGetAccessibleStateSet() {
AccessibleStateSet aStateSet = ac.getAccessibleStateSet();
assertFalse("accessible dialog is active",
aStateSet.contains(AccessibleState.ACTIVE));
assertTrue("accessible dialog is resizable",
aStateSet.contains(AccessibleState.RESIZABLE));
assertFalse("accessible dialog is NOT modal",
aStateSet.contains(AccessibleState.MODAL));
dialog.setResizable(false);
aStateSet = ac.getAccessibleStateSet();
assertFalse("accessible dialog is NOT resizable",
aStateSet.contains(AccessibleState.RESIZABLE));
dialog.setModal(true);
aStateSet = ac.getAccessibleStateSet();
assertTrue("accessible dialog is modal",
aStateSet.contains(AccessibleState.MODAL));
}
示例13: testAddPropertyChangeListener
import javax.accessibility.AccessibleState; //导入依赖的package包/类
public final void testAddPropertyChangeListener() {
String propName = AccessibleContext.ACCESSIBLE_STATE_PROPERTY;
canvas.getAccessibleContext().addPropertyChangeListener(propListener);
assertNull(lastPropEvent);
Frame f = new Frame();
f.add(canvas);
canvas.setFocusable(true); //!
f.setVisible(true);
waitForEvent();
// focus events:
assertNotNull(lastPropEvent);
assertEquals(propName, lastPropEvent.getPropertyName());
assertEquals(AccessibleState.FOCUSED, lastPropEvent.getNewValue());
assertNull(lastPropEvent.getOldValue());
// component events:
lastPropEvent = null;
canvas.setVisible(false);
waitForEvent();
assertNotNull(lastPropEvent);
assertEquals(propName, lastPropEvent.getPropertyName());
assertEquals(AccessibleState.VISIBLE, lastPropEvent.getOldValue());
assertNull(lastPropEvent.getNewValue());
f.dispose();
}
示例14: testGetAccessibleStateSet
import javax.accessibility.AccessibleState; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public final void testGetAccessibleStateSet() {
frame.show();
window.setFocusable(true);
window.setVisible(true);
waitFocus();
assertTrue(window.isFocusOwner());
AccessibleStateSet aStateSet = ac.getAccessibleStateSet();
assertTrue("accessible window is active",
aStateSet.contains(AccessibleState.ACTIVE));
assertTrue("accessible window is showing",
aStateSet.contains(AccessibleState.SHOWING));
assertTrue("accessible window is focusable",
aStateSet.contains(AccessibleState.FOCUSABLE));
assertTrue("accessible window is focused",
aStateSet.contains(AccessibleState.FOCUSED));
assertFalse("accessible window is NOT resizable",
aStateSet.contains(AccessibleState.RESIZABLE));
assertTrue(frame.isActive());
aStateSet = frame.getAccessibleContext().getAccessibleStateSet();
assertFalse("accessible frame is NOT active",
aStateSet.contains(AccessibleState.ACTIVE));
}
示例15: getAccessibleStateSet
import javax.accessibility.AccessibleState; //导入依赖的package包/类
public AccessibleStateSet getAccessibleStateSet() {
AccessibleStateSet result = new AccessibleStateSet();
if (isEnabled()) {
result.add(AccessibleState.ENABLED);
}
if (isFocusable()) {
result.add(AccessibleState.FOCUSABLE);
}
if (isVisible()) {
result.add(AccessibleState.VISIBLE);
}
if (isOpaque()) {
result.add(AccessibleState.OPAQUE);
}
if (getOrientation() == HORIZONTAL) {
result.add(AccessibleState.HORIZONTAL);
} else {
result.add(AccessibleState.VERTICAL);
}
return result;
}