当前位置: 首页>>代码示例>>Java>>正文


Java AccessibleContext类代码示例

本文整理汇总了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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:DescriptionComponent.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:QuietEditorPane.java

示例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());

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ResultPanelTree.java

示例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);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:CompletionJList.java

示例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);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:CompletionJList.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:ProfilerWindow.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:TopComponent.java

示例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!");
            }
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:AccessibleIndexInParentTest.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:AbstractOutputTab.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:CAccessibleText.java

示例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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:CAccessibleText.java

示例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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:CAccessibleText.java

示例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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:CAccessibleText.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:CAccessibleText.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:CodeFoldingSideBar.java


注:本文中的javax.accessibility.AccessibleContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。