Java Code Examples for javax.accessibility.AccessibleContext#setAccessibleDescription()

The following examples show how to use javax.accessibility.AccessibleContext#setAccessibleDescription() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BasicAbstractResultsPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void initAccessibility() {
    ResourceBundle bundle = NbBundle.getBundle(ResultView.class);

    AccessibleContext accessCtx;
    OutlineView outlineView = resultsOutlineSupport.getOutlineView();

    accessCtx = outlineView.getHorizontalScrollBar().getAccessibleContext();
    accessCtx.setAccessibleName(
            bundle.getString("ACSN_HorizontalScrollbar"));          //NOI18N

    accessCtx = outlineView.getVerticalScrollBar().getAccessibleContext();
    accessCtx.setAccessibleName(
            bundle.getString("ACSN_VerticalScrollbar"));            //NOI18N

    accessCtx = outlineView.getAccessibleContext();
    accessCtx.setAccessibleName(
            bundle.getString("ACSN_ResultTree"));                   //NOI18N
    accessCtx.setAccessibleDescription(
            bundle.getString("ACSD_ResultTree"));                   //NOI18N
}
 
Example 2
Source File: QuietEditorPane.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: CustomizerGeneral.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Creates new form CustomizerGeneral */
public CustomizerGeneral(CustomizerDataSupport custData) {
    this.custData = custData;        
    initComponents();

    JTextField serverPortTextField = ((JSpinner.NumberEditor) serverPortSpinner.getEditor()).getTextField();
    AccessibleContext ac = serverPortTextField.getAccessibleContext();
    ac.setAccessibleName(NbBundle.getMessage(CustomizerGeneral.class, "ASCN_ServerPort"));
    ac.setAccessibleDescription(NbBundle.getMessage(CustomizerGeneral.class, "ASCD_ServerPort"));
    
    JTextField shutdownPortTextField = ((JSpinner.NumberEditor) shutdownPortSpinner.getEditor()).getTextField();
    ac = shutdownPortTextField.getAccessibleContext();
    ac.setAccessibleName(NbBundle.getMessage(CustomizerGeneral.class, "ASCN_ShutdownPort"));
    ac.setAccessibleDescription(NbBundle.getMessage(CustomizerGeneral.class, "ASCD_ShutdownPort"));
    
    // work-around for jspinner incorrect fonts
    Font font = usernameTextField.getFont();
    serverPortSpinner.setFont(font);
    shutdownPortSpinner.setFont(font);
}
 
Example 4
Source File: ResultPanelTree.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@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());

}
 
Example 5
Source File: SwingUtils.java    From swift-explorer with Apache License 2.0 6 votes vote down vote up
public static <T extends Component> T setAccessibleContext (T comp, String name)
{
	if (comp == null)
		return comp;
	AccessibleContext ac = comp.getAccessibleContext() ;
	if (ac == null)
		return comp ;
	String text = null ;
	if (name != null && !name.isEmpty())
		text = name ;
	else if (comp instanceof AbstractButton) 
		text = ((AbstractButton)comp).getText() ;
	else
		text = comp.getName();
	if (text != null)
	{
		ac.setAccessibleName(text);
		ac.setAccessibleDescription(text) ;
	}
	return comp ;
}
 
Example 6
Source File: GuiUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a specified set of checkboxes.
 * The checkboxes are specified by unique identifiers.
 * The identifiers are given by this class's constants <code>CHK_xxx</code>.
 * <p>
 * The array of strings passed as the argument may also contain
 * <code>null</code> items. In such a case, the resulting array
 * of check-boxes will contain <code>null</code>s on the corresponding
 * possitions.
 *
 * @param  ids  identifiers of the checkboxes to be created
 * @return  array of checkboxes corresponding to the array of identifiers
 *          passed as the argument
 */
public static JCheckBox[] createCheckBoxes(String[] ids) {
    JCheckBox[] chkBoxes = new JCheckBox[ids.length];
    
    if (chkBoxes.length == 0) {
        return chkBoxes;
    }
    
    ResourceBundle bundle = NbBundle.getBundle(GuiUtils.class);
    for (int i = 0; i < ids.length; i++) {
        String id = ids[i];
        
        if (id == null) {
            chkBoxes[i] = null;
            continue;
        }
        
        JCheckBox chkBox = new JCheckBox();
        String baseName = "CommonTestsCfgOfCreate.chk" + id;              //NOI18N
        AccessibleContext accessCtx = chkBox.getAccessibleContext();
        Mnemonics.setLocalizedText(
                chkBox,
                bundle.getString(baseName + ".text"));              //NOI18N
        chkBox.setToolTipText(
                bundle.getString(baseName + ".toolTip"));           //NOI18N
        accessCtx.setAccessibleName(
                bundle.getString(baseName + ".AN"));                //NOI18N
        accessCtx.setAccessibleDescription(
                bundle.getString(baseName + ".AD"));                //NOI18N
        
        chkBoxes[i] = chkBox;
    }
    return chkBoxes;
}
 
Example 7
Source File: CustomizerStartup.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Creates new form CustomizerStartup */
public CustomizerStartup(CustomizerDataSupport custData, File catalinaHome) {
    this.custData = custData;
    this.catalinaHome = catalinaHome;
    
    initComponents();
    if (Utilities.isWindows()) {
        // force shutdown not supported on Windows
        jCheckBox4.setEnabled(false);
    } else {
        // shared memory debugging transport supported only on Windows
        jRadioButton1.setEnabled(false);
        jTextField4.setEnabled(false);
    }
    
    updateCustomScriptComponents();
    
    JTextField jSpinner1TextField = ((JSpinner.NumberEditor)jSpinner1.getEditor()).getTextField();        
    
    AccessibleContext ac = jSpinner1TextField.getAccessibleContext();
    ac.setAccessibleName(NbBundle.getMessage(CustomizerStartup.class, "ACSN_SocketPortNum"));
    ac.setAccessibleDescription(NbBundle.getMessage(CustomizerStartup.class, "ACSD_SocketPortNum"));
    
    // work-around for jspinner incorrect fonts
    Font font = jTextField1.getFont();
    jSpinner1TextField.setFont(font);
    
    /*
     * mnemonics generated in the guarded block do not work
     * because of change of the model after mnemonic setting
     * remove the workaround after completion of issue 111094
     */
    org.openide.awt.Mnemonics.setLocalizedText(jCheckBox1, org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "TXT_CustomScript")); // NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(jCheckBox4, org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "TXT_ForceShutdown")); // NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(jRadioButton1, org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "TXT_SharedMemName")); // NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(jRadioButton2, org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "TXT_SocketPort")); // NOI18N
}
 
Example 8
Source File: ResultPanelOutput.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance of ResultPanelOutput
 */
ResultPanelOutput(ResultDisplayHandler displayHandler) {
    super();
    if (LOG) {
        System.out.println("ResultPanelOutput.<init>");
    }
    
    textPane = new JEditorPane();
    textPane.setFont(new Font("monospaced", Font.PLAIN, getFont().getSize()));
    textPane.setEditorKit(new OutputEditorKit());
    textPane.setEditable(false);
    textPane.getCaret().setVisible(true);
    textPane.getCaret().setBlinkRate(0);
    textPane.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    setViewportView(textPane);

    /*
     * On GTK L&F, background of the text pane is gray, even though it is
     * white on a JTextArea. The following is a hack to fix it:
     */
    Color background = UIManager.getColor("TextPane.background");   //NOI18N
    if (background != null) {
        textPane.setBackground(background);
    }

    doc = textPane.getDocument();

    AccessibleContext ac = textPane.getAccessibleContext();
    ac.setAccessibleName(NbBundle.getMessage(getClass(),
                                            "ACSN_OutputTextPane"));//NOI18N
    ac.setAccessibleDescription(NbBundle.getMessage(getClass(),
                                            "ACSD_OutputTextPane"));//NOI18N
    
    this.displayHandler = displayHandler;
}
 
Example 9
Source File: ResultTreeView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages({"ACSN_ResultPanelTree=Information about passed and failed tests",
"ACSD_ResultPanelTree=Displays in a tree structure information about passed, failed and erroneous tests"})
private void initAccessibility() {
    AccessibleContext accContext = tree.getAccessibleContext();
    accContext.setAccessibleName(Bundle.ACSN_ResultPanelTree());
    accContext.setAccessibleDescription(Bundle.ACSD_ResultPanelTree());
}
 
Example 10
Source File: ResultWindow.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Creates a new instance of ResultWindow */
@NbBundle.Messages({"TITLE_TEST_RESULTS=Test Results",
    "ACSN_TestResults=Test Results",
    "ACSD_TestResults=Displays information about passed and failed tests and output generated by them"})
public ResultWindow() {
    super();
    setFocusable(true);
    setLayout(new BorderLayout());

    setName(ID);
    setDisplayName(Bundle.TITLE_TEST_RESULTS());
    setIcon(ImageUtilities.loadImage( "org/netbeans/modules/gsf/testrunner/ui/resources/testResults.png", true));//NOI18N
     
    AccessibleContext accContext = getAccessibleContext();
    accContext.setAccessibleName(Bundle.ACSN_TestResults());
    accContext.setAccessibleDescription(Bundle.ACSD_TestResults());

    pop = new JPopupMenu();
    pop.add(new Close());
    pop.add(new CloseAll());
    pop.add(new CloseAllButCurrent());
    popL = new PopupListener();
    closeL = new CloseListener();

    tabPane = TabbedPaneFactory.createCloseButtonTabbedPane();
    tabPane.setMinimumSize(new Dimension(0, 0));
    tabPane.addMouseListener(popL);
    tabPane.addPropertyChangeListener(closeL);
    add(tabPane);
}
 
Example 11
Source File: PropertyPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void initAccessibility() {
    this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(getClass(), "ACS_PropertyPanel"));                
    AccessibleContext context;
    context = keyText.getAccessibleContext();
    context.setAccessibleName(NbBundle.getMessage(getClass(), "ACSN_CTL_KeyText"));
    context.setAccessibleDescription(NbBundle.getMessage(getClass(), "ACSD_CTL_KeyText"));
    context = valueText.getAccessibleContext();
    context.setAccessibleName(NbBundle.getMessage(getClass(), "ACSN_CTL_ValueText"));
    context.setAccessibleDescription(NbBundle.getMessage(getClass(), "ACSD_CTL_ValueText"));
    context = commentText.getAccessibleContext();
    context.setAccessibleName(NbBundle.getMessage(getClass(), "ACSN_CTL_CommentText"));
    context.setAccessibleDescription(NbBundle.getMessage(getClass(), "ACSD_CTL_CommentText"));
}
 
Example 12
Source File: ChoseProjectTypeStep.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NotNull
private JComponent createGallery() {
  myProjectTypeGallery = new ASGallery<ModuleGalleryEntry>(
    JBList.createDefaultListModel(),
    image -> image == null ? null : image.getIcon() == null ? null : image.getIcon(),
    label -> label == null ? message("android.wizard.gallery.item.none") : label.getName(), DEFAULT_GALLERY_THUMBNAIL_SIZE,
    null
  ) {

    @Override
    public Dimension getPreferredScrollableViewportSize() {
      // The default implementation assigns a height as tall as the screen.
      // When calling setVisibleRowCount(2), the underlying implementation is buggy, and  will have a gap on the right and when the user
      // resizes, it enters on an adjustment loop at some widths (can't decide to fit 3 or for elements, and loops between the two)
      Dimension cellSize = computeCellSize();
      int heightInsets = getInsets().top + getInsets().bottom;
      int widthInsets = getInsets().left + getInsets().right;
      // Don't want to show an exact number of rows, since then it's not obvious there's another row available.
      return new Dimension(cellSize.width * 5 + widthInsets, (int)(cellSize.height * 1.2) + heightInsets);
    }
  };

  myProjectTypeGallery.setBorder(BorderFactory.createLineBorder(JBColor.border()));
  AccessibleContext accessibleContext = myProjectTypeGallery.getAccessibleContext();
  if (accessibleContext != null) {
    accessibleContext.setAccessibleDescription(getTitle());
  }
  return new JBScrollPane(myProjectTypeGallery);
}
 
Example 13
Source File: ChoseProjectTypeStep.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NotNull
private JComponent createGallery() {
  myProjectTypeGallery = new ASGallery<ModuleGalleryEntry>(
    JBList.createDefaultListModel(),
    image -> image == null ? null : image.getIcon() == null ? null : image.getIcon(),
    label -> label == null ? message("android.wizard.gallery.item.none") : label.getName(), DEFAULT_GALLERY_THUMBNAIL_SIZE,
    null
  ) {

    @Override
    public Dimension getPreferredScrollableViewportSize() {
      // The default implementation assigns a height as tall as the screen.
      // When calling setVisibleRowCount(2), the underlying implementation is buggy, and  will have a gap on the right and when the user
      // resizes, it enters on an adjustment loop at some widths (can't decide to fit 3 or for elements, and loops between the two)
      Dimension cellSize = computeCellSize();
      int heightInsets = getInsets().top + getInsets().bottom;
      int widthInsets = getInsets().left + getInsets().right;
      // Don't want to show an exact number of rows, since then it's not obvious there's another row available.
      return new Dimension(cellSize.width * 5 + widthInsets, (int)(cellSize.height * 1.2) + heightInsets);
    }
  };

  myProjectTypeGallery.setBorder(BorderFactory.createLineBorder(JBColor.border()));
  AccessibleContext accessibleContext = myProjectTypeGallery.getAccessibleContext();
  if (accessibleContext != null) {
    accessibleContext.setAccessibleDescription(getTitle());
  }
  return new JBScrollPane(myProjectTypeGallery);
}
 
Example 14
Source File: BeanTablePanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void initComponents() {
	jScrollPane1 = new javax.swing.JScrollPane();
	southPanel = new javax.swing.JPanel();
	buttonPanel = new javax.swing.JPanel();
	addButton = new javax.swing.JButton();
	editButton = new javax.swing.JButton();
	removeButton = new javax.swing.JButton();
	rightPanel = new javax.swing.JPanel();

	setLayout(new java.awt.BorderLayout());
	add(jScrollPane1, java.awt.BorderLayout.CENTER);
	southPanel.setLayout(new java.awt.BorderLayout());

       String buttonText = bundle.getString("LBL_New");
       int mnemonicIndex = buttonText.indexOf(bundle.getString("MNC_New").charAt(0));
       if(mnemonicIndex < 0) {
           mnemonicIndex = 0;
       }
       addButton.setText(buttonText); //NOI18N
       addButton.setDisplayedMnemonicIndex(mnemonicIndex);
       AccessibleContext accessibleContext = addButton.getAccessibleContext();
	accessibleContext.setAccessibleName(bundle.getString("ACSN_New"));	// NOI18N
	accessibleContext.setAccessibleDescription(bundle.getString("ACSD_New"));	// NOI18N
	buttonPanel.add(addButton);

       buttonText = bundle.getString("LBL_Edit");
       mnemonicIndex = buttonText.indexOf(bundle.getString("MNC_Edit").charAt(0));
       if(mnemonicIndex < 0) {
           mnemonicIndex = 0;
       }
       editButton.setText(buttonText); //NOI18N
       editButton.setDisplayedMnemonicIndex(mnemonicIndex);
	editButton.setEnabled(false);
	accessibleContext = editButton.getAccessibleContext();
	accessibleContext.setAccessibleName(bundle.getString("ACSN_Edit"));	// NOI18N
	accessibleContext.setAccessibleDescription(bundle.getString("ACSD_Edit"));	// NOI18N
	buttonPanel.add(editButton);

       buttonText = bundle.getString("LBL_Delete");
       mnemonicIndex = buttonText.indexOf(bundle.getString("MNC_Delete").charAt(0));
       if(mnemonicIndex < 0) {
           mnemonicIndex = 0;
       }
       removeButton.setText(buttonText); //NOI18N
       removeButton.setDisplayedMnemonicIndex(mnemonicIndex);
	removeButton.setEnabled(false);
	accessibleContext = removeButton.getAccessibleContext();
	accessibleContext.setAccessibleName(bundle.getString("ACSN_Delete"));	// NOI18N
	accessibleContext.setAccessibleDescription(bundle.getString("ACSD_Delete"));	// NOI18N
	buttonPanel.add(removeButton);

	southPanel.add(buttonPanel, java.awt.BorderLayout.CENTER);
	southPanel.add(rightPanel, java.awt.BorderLayout.EAST);
	add(southPanel, java.awt.BorderLayout.SOUTH);
}
 
Example 15
Source File: DashboardViewer.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private DashboardViewer() {
    expandedNodes = new HashMap<TreeListNode, Boolean>();
    dashboardComponent = new JScrollPane() {
        @Override
        public void requestFocus() {
            Component view = getViewport().getView();
            if (view != null) {
                view.requestFocus();
            } else {
                super.requestFocus();
            }
        }

        @Override
        public boolean requestFocusInWindow() {
            Component view = getViewport().getView();
            return view != null ? view.requestFocusInWindow() : super.requestFocusInWindow();
        }
    };
    dashboardComponent.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    dashboardComponent.setBorder(BorderFactory.createEmptyBorder());
    dashboardComponent.setBackground(ColorManager.getDefault().getDefaultBackground());
    dashboardComponent.getViewport().setBackground(ColorManager.getDefault().getDefaultBackground());
    mapCategoryToNode = new HashMap<Category, CategoryNode>();
    mapRepositoryToNode = new HashMap<String, RepositoryNode>();
    mapRepositoryToUnsubmittedNode = new HashMap<RepositoryImpl, UnsubmittedCategoryNode>();
    categoryNodes = new ArrayList<CategoryNode>();
    repositoryNodes = new ArrayList<RepositoryNode>();

    LinkButton btnAddCategory = new LinkButton(ImageUtilities.loadImageIcon("org/netbeans/modules/bugtracking/tasks/resources/add_category.png", true), new CreateCategoryAction()); //NOI18N
    btnAddCategory.setToolTipText(NbBundle.getMessage(DashboardViewer.class, "LBL_CreateCategory")); // NOI18N
    LinkButton btnClearCategories = new LinkButton(ImageUtilities.loadImageIcon("org/netbeans/modules/bugtracking/tasks/resources/clear.png", true), new Actions.ClearCategoriesAction());
    btnClearCategories.setToolTipText(NbBundle.getMessage(DashboardViewer.class, "LBL_ClearCategories")); // NOI18N
    titleCategoryNode = new TitleNode(NbBundle.getMessage(TitleNode.class, "LBL_Categories"), btnAddCategory, btnClearCategories); // NOI18N

    LinkButton btnAddRepo = new LinkButton(ImageUtilities.loadImageIcon("org/netbeans/modules/bugtracking/tasks/resources/add_repo.png", true), new CreateRepositoryAction()); //NOI18N
    btnAddRepo.setToolTipText(NbBundle.getMessage(DashboardViewer.class, "LBL_AddRepo")); // NOI18N
    titleRepositoryNode = new TitleNode(NbBundle.getMessage(TitleNode.class, "LBL_Repositories"), btnAddRepo); // NOI18N

    AbstractAction reloadAction = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            loadData();
        }
    };
    errorRepositories = new ErrorNode(NbBundle.getMessage(TitleNode.class, "ERR_Repositories"), reloadAction); // NOI18N
    errorCategories = new ErrorNode(NbBundle.getMessage(TitleNode.class, "ERR_Categories"), reloadAction); // NOI18N

    modelListener = new ModelListener();
    model.addModelListener(modelListener);
    model.addRoot(-1, titleCategoryNode);
    model.addRoot(-1, titleRepositoryNode);

    AccessibleContext accessibleContext = treeList.getAccessibleContext();
    String a11y = NbBundle.getMessage(DashboardViewer.class, "A11Y_TeamProjects"); //NOI18N
    accessibleContext.setAccessibleName(a11y);
    accessibleContext.setAccessibleDescription(a11y);
    appliedTaskFilters = new AppliedFilters<TaskNode>();
    appliedCategoryFilters = new AppliedFilters<CategoryNode>();
    appliedRepositoryFilters = new AppliedFilters<RepositoryNode>();
    appliedCategoryFilters.addFilter(new UnsubmittedCategoryFilter());
    taskHits = 0;
    treeList.setTransferHandler(new DashboardTransferHandler());
    treeList.setDragEnabled(true);
    treeList.setDropMode(DropMode.ON_OR_INSERT);
    treeList.setModel(model);
    attachActions();
    dashboardComponent.setViewportView(treeList);
    dashboardComponent.invalidate();
    dashboardComponent.revalidate();
    dashboardComponent.repaint();
}