本文整理匯總了Java中javax.accessibility.AccessibleContext類的典型用法代碼示例。如果您正苦於以下問題:Java AccessibleContext類的具體用法?Java AccessibleContext怎麽用?Java AccessibleContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AccessibleContext類屬於javax.accessibility包,在下文中一共展示了AccessibleContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getAccessibleContext
import javax.accessibility.AccessibleContext; //導入依賴的package包/類
@Override
public AccessibleContext getAccessibleContext() {
if( null == accessibleContext ) {
accessibleContext = new AccessibleJComponent() {
@Override
public AccessibleRole getAccessibleRole() {
return AccessibleRole.SWING_COMPONENT;
}
};
accessibleContext.setAccessibleName( NbBundle.getMessage(DescriptionComponent.class, "ACS_Description") );
accessibleContext.setAccessibleDescription( NbBundle.getMessage(DescriptionComponent.class, "ACSD_Description") );
}
return accessibleContext;
}
示例2: getAccessibleContext
import javax.accessibility.AccessibleContext; //導入依賴的package包/類
public AccessibleContext getAccessibleContext() {
AccessibleContext ctx = super.getAccessibleContext();
if (ctx != null) {
// Lazily set the accessible name and desc
// since JEditorPane.AccessibleJEditorPane resp. AccessibleJTextComponent
// attaches document listener which prevents cloned JEPs from being GCed.
ctx.setAccessibleName(
NbBundle.getMessage(CloneableEditor.class, "ACS_CloneableEditor_QuietEditorPane", this.getName())
);
ctx.setAccessibleDescription(
NbBundle.getMessage(
CloneableEditor.class, "ACSD_CloneableEditor_QuietEditorPane",
this.getName()
)
);
}
return ctx;
}
示例3: initAccessibility
import javax.accessibility.AccessibleContext; //導入依賴的package包/類
@NbBundle.Messages({"ACSN_HorizontalScrollbar=Horizontal scrollbar of the results panel",
"ACSN_VerticalScrollbar=Vertical scrollbar of the results panel"})
private void initAccessibility() {
AccessibleContext accessCtx;
accessCtx = getAccessibleContext();
accessCtx.setAccessibleName(Bundle.ACSN_ResultPanelTree());
accessCtx.setAccessibleDescription(Bundle.ACSD_ResultPanelTree());
accessCtx = treeView.getHorizontalScrollBar().getAccessibleContext();
accessCtx.setAccessibleName(Bundle.ACSN_HorizontalScrollbar());
accessCtx = treeView.getVerticalScrollBar().getAccessibleContext();
accessCtx.setAccessibleName(Bundle.ACSN_VerticalScrollbar());
}
示例4: setVisible
import javax.accessibility.AccessibleContext; //導入依賴的package包/類
@Override
public void setVisible(boolean aFlag) {
super.setVisible(aFlag);
if (isVisible()) {
SwingUtilities.invokeLater(new Runnable() {
@Override public void run() {
updateAccessible();
}
});
} else {
AccessibleContext editorAC = editorComponent.getAccessibleContext();
if (accessibleLabel != null) {
editorAC.firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY, accessibleLabel, null);
editorAC.firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, accessibleLabel, null);
}
if (accessibleFakeLabel != null) {
editorAC.firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, accessibleFakeLabel, null);
}
}
}
示例5: updateAccessible
import javax.accessibility.AccessibleContext; //導入依賴的package包/類
private void updateAccessible() {
AccessibleContext editorAC = editorComponent.getAccessibleContext();
if (accessibleFakeLabel == null) {
accessibleFakeLabel = new JLabel(""); //NOI18N
editorAC.firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, null, accessibleFakeLabel);
}
JLabel orig = accessibleLabel;
editorAC.firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY, accessibleLabel, accessibleFakeLabel);
Object selectedValue = getSelectedValue();
String accName = null;
if (selectedValue instanceof Accessible) {
AccessibleContext ac = ((Accessible) selectedValue).getAccessibleContext();
if (ac != null) {
accName = ac.getAccessibleName();
}
}
if (accName == null && selectedValue != null) {
accName = selectedValue.toString();
}
if (accName != null) {
accessibleLabel = new JLabel(LocaleSupport.getString("ACSN_CompletionView_SelectedItem") + accName); //NOI18N
editorAC.firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, null, accessibleLabel);
editorAC.firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY, accessibleFakeLabel, accessibleLabel);
if (orig != null) {
editorAC.firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, orig, null);
}
}
}
示例6: getAccessibleContext
import javax.accessibility.AccessibleContext; //導入依賴的package包/類
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new JComponent.AccessibleJComponent() {
public AccessibleRole getAccessibleRole() {
return AccessibleRole.PANEL;
}
public String getAccessibleName() {
return Bundle.ProfilerWindow_accessName(getDisplayName());
}
public String getAccessibleDescription() {
ProfilerFeature selected = featuresView == null ? null :
featuresView.getSelectedFeature();
return selected == null ? WelcomePanel.CAPTION :
(selected.getName() + " " + selected.getDescription()); // NOI18N
}
};
}
return accessibleContext;
}
示例7: getAccessibleContext
import javax.accessibility.AccessibleContext; //導入依賴的package包/類
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new JComponent.AccessibleJComponent() {
public AccessibleRole getAccessibleRole() {
return AccessibleRole.PANEL;
}
public String getAccessibleName() {
if (accessibleName != null) {
return accessibleName;
}
return getName();
}
/* Fix for 19344: Null accessible decription of all TopComponents on JDK1.4 */
public String getToolTipText() {
return TopComponent.this.getToolTipText();
}
};
}
return accessibleContext;
}
示例8: test
import javax.accessibility.AccessibleContext; //導入依賴的package包/類
private static void test() {
int N = 5;
JTabbedPane tabbedPane = new JTabbedPane();
for (int i = 0; i < N; i++) {
tabbedPane.addTab("Title: " + i, new JLabel("Component: " + i));
}
for (int i = 0; i < tabbedPane.getTabCount(); i++) {
Component child = tabbedPane.getComponentAt(i);
AccessibleContext ac = child.getAccessibleContext();
if (ac == null) {
throw new RuntimeException("Accessible Context is null!");
}
int index = ac.getAccessibleIndexInParent();
Accessible parent = ac.getAccessibleParent();
if (parent.getAccessibleContext().getAccessibleChild(index) != child) {
throw new RuntimeException("Wrong getAccessibleIndexInParent!");
}
}
}
示例9: getAccessibleContext
import javax.accessibility.AccessibleContext; //導入依賴的package包/類
@Override
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJComponent() {
@Override
public AccessibleRole getAccessibleRole() {
// is it really a panel?
return AccessibleRole.PANEL;
}
@Override
public String getAccessibleName() {
if (accessibleName != null) {
return accessibleName;
}
return getName();
}
};
}
return accessibleContext;
}
示例10: setSelectedText
import javax.accessibility.AccessibleContext; //導入依賴的package包/類
static void setSelectedText(final Accessible a, final Component c, final String newText) {
if (a == null) return;
CAccessibility.invokeLater(new Runnable() {
public void run() {
final AccessibleContext ac = a.getAccessibleContext();
if (ac == null) return;
final AccessibleEditableText aet = ac.getAccessibleEditableText();
if (aet == null) return;
final int selectionStart = aet.getSelectionStart();
final int selectionEnd = aet.getSelectionEnd();
aet.replaceText(selectionStart, selectionEnd, newText);
}
}, c);
}
示例11: setSelectedTextRange
import javax.accessibility.AccessibleContext; //導入依賴的package包/類
static void setSelectedTextRange(final Accessible a, final Component c, final int startIndex, final int endIndex) {
if (a == null) return;
CAccessibility.invokeLater(new Runnable() {
public void run() {
final AccessibleContext ac = a.getAccessibleContext();
if (ac == null) return;
final AccessibleEditableText aet = ac.getAccessibleEditableText();
if (aet == null) return;
final boolean validRange = (startIndex >= 0) && (endIndex >= startIndex) && (endIndex <= aet.getCharCount());
if (!validRange) return;
aet.selectText(startIndex, endIndex);
}
}, c);
}
示例12: getCharacterIndexAtPosition
import javax.accessibility.AccessibleContext; //導入依賴的package包/類
static int getCharacterIndexAtPosition(final Accessible a, final Component c, final int x, final int y) {
if (a == null) return 0;
return CAccessibility.invokeAndWait(new Callable<Integer>() {
public Integer call() throws Exception {
final AccessibleContext ac = a.getAccessibleContext();
if (ac == null) return null;
final AccessibleText at = ac.getAccessibleText();
if (at == null) return null;
// (x, y) passed in as java screen coords - (0, 0) at upper-left corner of screen.
// Convert to java component-local coords
final Point componentLocation = ac.getAccessibleComponent().getLocationOnScreen();
final int localX = x - (int)componentLocation.getX();
final int localY = y - (int)componentLocation.getY();
return at.getIndexAtPoint(new Point(localX, localY));
}
}, c);
}
示例13: getSelectedTextRange
import javax.accessibility.AccessibleContext; //導入依賴的package包/類
static int[] getSelectedTextRange(final Accessible a, final Component c) {
if (a == null) return new int[2];
return CAccessibility.invokeAndWait(new Callable<int[]>() {
public int[] call() {
final AccessibleContext ac = a.getAccessibleContext();
if (ac == null) return new int[2];
final AccessibleText at = ac.getAccessibleText();
if (at == null) return new int[2];
final int[] ret = new int[2];
ret[0] = at.getSelectionStart();
ret[1] = at.getSelectionEnd();
return ret;
}
}, c);
}
示例14: getSelectedText
import javax.accessibility.AccessibleContext; //導入依賴的package包/類
static String getSelectedText(final Accessible a, final Component c) {
if (a == null) return null;
return CAccessibility.invokeAndWait(new Callable<String>() {
public String call() throws Exception {
final AccessibleContext ac = a.getAccessibleContext();
if (ac == null) return null;
final AccessibleText at = ac.getAccessibleText();
if (at == null) return null;
return at.getSelectedText();
}
}, c);
}
示例15: getAccessibleContext
import javax.accessibility.AccessibleContext; //導入依賴的package包/類
@Override
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJComponent() {
public @Override AccessibleRole getAccessibleRole() {
return AccessibleRole.PANEL;
}
};
accessibleContext.setAccessibleName(NbBundle.getMessage(CodeFoldingSideBar.class, "ACSN_CodeFoldingSideBar")); //NOI18N
accessibleContext.setAccessibleDescription(NbBundle.getMessage(CodeFoldingSideBar.class, "ACSD_CodeFoldingSideBar")); //NOI18N
}
return accessibleContext;
}