Example usage for javax.accessibility AccessibleContext ACCESSIBLE_DESCRIPTION_PROPERTY

List of usage examples for javax.accessibility AccessibleContext ACCESSIBLE_DESCRIPTION_PROPERTY

Introduction

In this page you can find the example usage for javax.accessibility AccessibleContext ACCESSIBLE_DESCRIPTION_PROPERTY.

Prototype

String ACCESSIBLE_DESCRIPTION_PROPERTY

To view the source code for javax.accessibility AccessibleContext ACCESSIBLE_DESCRIPTION_PROPERTY.

Click Source Link

Document

Constant used to determine when the #accessibleDescription property has changed.

Usage

From source file:net.sf.vfsjfilechooser.plaf.metal.MetalVFSFileChooserUI.java

@SuppressWarnings("serial")
@Override/*from  ww  w .  ja  v  a 2 s .  c  om*/
public void installComponents(VFSJFileChooser fc) {
    AbstractVFSFileSystemView fsv = fc.getFileSystemView();

    fc.setBorder(new EmptyBorder(12, 12, 11, 11));
    fc.setLayout(new BorderLayout(0, 11));

    filePane = new VFSFilePane(new MetalVFSFileChooserUIAccessor());
    fc.addPropertyChangeListener(filePane);

    updateUseShellFolder();

    // ********************************* //
    // **** Construct the top panel **** //
    // ********************************* //

    // Directory manipulation buttons
    JPanel topPanel = new JPanel(new BorderLayout(11, 0));
    topButtonPanel = new JPanel();
    topButtonPanel.setLayout(new BoxLayout(topButtonPanel, BoxLayout.LINE_AXIS));
    topPanel.add(topButtonPanel, BorderLayout.AFTER_LINE_ENDS);

    // Add the top panel to the fileChooser
    fc.add(topPanel, BorderLayout.NORTH);

    // ComboBox Label
    lookInLabel = new JLabel(lookInLabelText);
    topPanel.add(lookInLabel, BorderLayout.BEFORE_LINE_BEGINS);

    // CurrentDir ComboBox
    directoryComboBox = new JComboBox() {
        @Override
        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            // Must be small enough to not affect total width.
            d.width = 150;

            return d;
        }
    };
    directoryComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, lookInLabelText);
    directoryComboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    lookInLabel.setLabelFor(directoryComboBox);
    directoryComboBoxModel = createDirectoryComboBoxModel(fc);
    directoryComboBox.setModel(directoryComboBoxModel);
    directoryComboBox.addActionListener(directoryComboBoxAction);
    directoryComboBox.setRenderer(createDirectoryComboBoxRenderer(fc));
    directoryComboBox.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    directoryComboBox.setAlignmentY(JComponent.TOP_ALIGNMENT);
    directoryComboBox.setMaximumRowCount(8);

    topPanel.add(directoryComboBox, BorderLayout.CENTER);

    // Up Button
    upFolderButton = new JButton(getChangeToParentDirectoryAction());
    upFolderButton.setText(null);
    upFolderButton.setIcon(upFolderIcon);
    upFolderButton.setToolTipText(upFolderToolTipText);
    upFolderButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, upFolderAccessibleName);
    upFolderButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    upFolderButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    upFolderButton.setMargin(shrinkwrap);

    topButtonPanel.add(upFolderButton);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // Home Button
    FileObject homeDir = fsv.getHomeDirectory();
    String toolTipText = homeFolderToolTipText;

    if (fsv.isRoot(homeDir)) {
        toolTipText = getFileView(fc).getName(homeDir); // Probably "Desktop".
    }

    JButton b = new JButton(homeFolderIcon);
    b.setToolTipText(toolTipText);
    b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, homeFolderAccessibleName);
    b.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    b.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    b.setMargin(shrinkwrap);

    b.addActionListener(getGoHomeAction());
    topButtonPanel.add(b);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // New Directory Button
    if (!UIManager.getBoolean("FileChooser.readOnly")) {
        b = new JButton(filePane.getNewFolderAction());
        b.setText(null);
        b.setIcon(newFolderIcon);
        b.setToolTipText(newFolderToolTipText);
        b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, newFolderAccessibleName);
        b.setAlignmentX(JComponent.LEFT_ALIGNMENT);
        b.setAlignmentY(JComponent.CENTER_ALIGNMENT);
        b.setMargin(shrinkwrap);
    }

    topButtonPanel.add(b);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // View button group
    ButtonGroup viewButtonGroup = new ButtonGroup();

    // List Button
    listViewButton = new JToggleButton(listViewIcon);
    listViewButton.setToolTipText(listViewButtonToolTipText);
    listViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, listViewButtonAccessibleName);
    listViewButton.setSelected(true);
    listViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    listViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    listViewButton.setMargin(shrinkwrap);
    listViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_LIST));
    topButtonPanel.add(listViewButton);
    viewButtonGroup.add(listViewButton);

    // Details Button
    detailsViewButton = new JToggleButton(detailsViewIcon);
    detailsViewButton.setToolTipText(detailsViewButtonToolTipText);
    detailsViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
            detailsViewButtonAccessibleName);
    detailsViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    detailsViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    detailsViewButton.setMargin(shrinkwrap);
    detailsViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_DETAILS));
    topButtonPanel.add(detailsViewButton);
    viewButtonGroup.add(detailsViewButton);
    filePane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            if ("viewType".equals(e.getPropertyName())) {
                final int viewType = filePane.getViewType();

                if (viewType == VFSFilePane.VIEWTYPE_LIST) {
                    listViewButton.setSelected(true);
                } else if (viewType == VFSFilePane.VIEWTYPE_DETAILS) {
                    detailsViewButton.setSelected(true);
                }
            }
        }
    });

    // ************************************** //
    // ******* Add the directory pane ******* //
    // ************************************** //
    fc.add(getAccessoryPanel(), BorderLayout.AFTER_LINE_ENDS);

    JComponent accessory = fc.getAccessory();

    if (accessory != null) {
        getAccessoryPanel().add(accessory);
    }

    filePane.setPreferredSize(LIST_PREF_SIZE);
    fc.add(filePane, BorderLayout.CENTER);

    // ********************************** //
    // **** Construct the bottom panel ** //
    // ********************************** //
    bottomPanel = getBottomPanel();
    bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.Y_AXIS));
    fc.add(bottomPanel, BorderLayout.SOUTH);

    // FileName label and textfield
    JPanel fileNamePanel = new JPanel();
    fileNamePanel.setLayout(new BoxLayout(fileNamePanel, BoxLayout.LINE_AXIS));
    bottomPanel.add(fileNamePanel);
    bottomPanel.add(Box.createRigidArea(vstrut5));

    fileNameLabel = new AlignedLabel();
    populateFileNameLabel();
    fileNamePanel.add(fileNameLabel);

    fileNameTextField = new JTextField(35) {
        @Override
        public Dimension getMaximumSize() {
            return new Dimension(Short.MAX_VALUE, super.getPreferredSize().height);
        }
    };

    PopupHandler.installDefaultMouseListener(fileNameTextField);

    fileNamePanel.add(fileNameTextField);
    fileNameLabel.setLabelFor(fileNameTextField);
    fileNameTextField.addFocusListener(new FocusAdapter() {
        @Override
        public void focusGained(FocusEvent e) {
            if (!getFileChooser().isMultiSelectionEnabled()) {
                filePane.clearSelection();
            }
        }
    });

    if (fc.isMultiSelectionEnabled()) {
        setFileName(fileNameString(fc.getSelectedFiles()));
    } else {
        setFileName(fileNameString(fc.getSelectedFile()));
    }

    // Filetype label and combobox
    JPanel filesOfTypePanel = new JPanel();
    filesOfTypePanel.setLayout(new BoxLayout(filesOfTypePanel, BoxLayout.LINE_AXIS));
    bottomPanel.add(filesOfTypePanel);

    AlignedLabel filesOfTypeLabel = new AlignedLabel(filesOfTypeLabelText);
    filesOfTypePanel.add(filesOfTypeLabel);

    filterComboBoxModel = createFilterComboBoxModel();
    fc.addPropertyChangeListener(filterComboBoxModel);
    filterComboBox = new JComboBox(filterComboBoxModel);
    filterComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, filesOfTypeLabelText);
    filesOfTypeLabel.setLabelFor(filterComboBox);
    filterComboBox.setRenderer(createFilterComboBoxRenderer());
    filesOfTypePanel.add(filterComboBox);

    // buttons
    getButtonPanel().setLayout(new ButtonAreaLayout());

    approveButton = new JButton(getApproveButtonText(fc));
    // Note: Metal does not use mnemonics for approve and cancel
    approveButton.addActionListener(getApproveSelectionAction());
    fileNameTextField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                getApproveSelectionAction().actionPerformed(null);
            }
        }
    });
    approveButton.setToolTipText(getApproveButtonToolTipText(fc));
    getButtonPanel().add(approveButton);

    cancelButton = new JButton(cancelButtonText);
    cancelButton.setToolTipText(cancelButtonToolTipText);
    cancelButton.addActionListener(getCancelSelectionAction());
    getButtonPanel().add(cancelButton);

    if (fc.getControlButtonsAreShown()) {
        addControlButtons();
    }

    groupLabels(new AlignedLabel[] { fileNameLabel, filesOfTypeLabel });
}

From source file:com.googlecode.vfsjfilechooser2.plaf.metal.MetalVFSFileChooserUI.java

@SuppressWarnings("serial")
@Override/*from   ww  w .  j a va  2  s .c  o  m*/
public void installComponents(VFSJFileChooser fc) {
    AbstractVFSFileSystemView fsv = fc.getFileSystemView();

    fc.setBorder(new EmptyBorder(12, 12, 11, 11));
    fc.setLayout(new BorderLayout(0, 11));

    filePane = new VFSFilePane(new MetalVFSFileChooserUIAccessor());
    fc.addPropertyChangeListener(filePane);

    updateUseShellFolder();

    // ********************************* //
    // **** Construct the top panel **** //
    // ********************************* //

    // Directory manipulation buttons
    JPanel topPanel = new JPanel(new BorderLayout(11, 0));
    topButtonPanel = new JPanel();
    topButtonPanel.setLayout(new BoxLayout(topButtonPanel, BoxLayout.LINE_AXIS));
    topPanel.add(topButtonPanel, BorderLayout.AFTER_LINE_ENDS);

    // Add the top panel to the fileChooser
    fc.add(topPanel, BorderLayout.NORTH);

    // ComboBox Label
    lookInLabel = new JLabel(lookInLabelText);
    topPanel.add(lookInLabel, BorderLayout.BEFORE_LINE_BEGINS);

    // CurrentDir ComboBox
    directoryComboBox = new JComboBox() {
        @Override
        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            // Must be small enough to not affect total width.
            d.width = 150;

            return d;
        }
    };
    directoryComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, lookInLabelText);
    directoryComboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    lookInLabel.setLabelFor(directoryComboBox);
    directoryComboBoxModel = createDirectoryComboBoxModel(fc);
    directoryComboBox.setModel(directoryComboBoxModel);
    directoryComboBox.addActionListener(directoryComboBoxAction);
    directoryComboBox.setRenderer(createDirectoryComboBoxRenderer(fc));
    directoryComboBox.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    directoryComboBox.setAlignmentY(JComponent.TOP_ALIGNMENT);
    directoryComboBox.setMaximumRowCount(8);

    topPanel.add(directoryComboBox, BorderLayout.CENTER);

    // Up Button
    upFolderButton = new JButton(getChangeToParentDirectoryAction());
    upFolderButton.setText(null);
    upFolderButton.setIcon(upFolderIcon);
    upFolderButton.setToolTipText(upFolderToolTipText);
    upFolderButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, upFolderAccessibleName);
    upFolderButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    upFolderButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    upFolderButton.setMargin(shrinkwrap);

    topButtonPanel.add(upFolderButton);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // Home Button
    FileObject homeDir = fsv.getHomeDirectory();
    String toolTipText = homeFolderToolTipText;

    if (fsv.isRoot(homeDir)) {
        toolTipText = getFileView(fc).getName(homeDir); // Probably "Desktop".
    }

    JButton b = new JButton(homeFolderIcon);
    b.setToolTipText(toolTipText);
    b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, homeFolderAccessibleName);
    b.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    b.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    b.setMargin(shrinkwrap);

    b.addActionListener(getGoHomeAction());
    topButtonPanel.add(b);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // New Directory Button
    if (!UIManager.getBoolean("FileChooser.readOnly")) {
        b = new JButton(filePane.getNewFolderAction());
        b.setText(null);
        b.setIcon(newFolderIcon);
        b.setToolTipText(newFolderToolTipText);
        b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, newFolderAccessibleName);
        b.setAlignmentX(JComponent.LEFT_ALIGNMENT);
        b.setAlignmentY(JComponent.CENTER_ALIGNMENT);
        b.setMargin(shrinkwrap);
    }

    topButtonPanel.add(b);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // View button group
    ButtonGroup viewButtonGroup = new ButtonGroup();

    // List Button
    listViewButton = new JToggleButton(listViewIcon);
    listViewButton.setToolTipText(listViewButtonToolTipText);
    listViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, listViewButtonAccessibleName);
    listViewButton.setSelected(true);
    listViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    listViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    listViewButton.setMargin(shrinkwrap);
    listViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_LIST));
    topButtonPanel.add(listViewButton);
    viewButtonGroup.add(listViewButton);

    // Details Button
    detailsViewButton = new JToggleButton(detailsViewIcon);
    detailsViewButton.setToolTipText(detailsViewButtonToolTipText);
    detailsViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
            detailsViewButtonAccessibleName);
    detailsViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    detailsViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    detailsViewButton.setMargin(shrinkwrap);
    detailsViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_DETAILS));
    topButtonPanel.add(detailsViewButton);
    viewButtonGroup.add(detailsViewButton);
    filePane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            if ("viewType".equals(e.getPropertyName())) {
                final int viewType = filePane.getViewType();

                if (viewType == VFSFilePane.VIEWTYPE_LIST) {
                    listViewButton.setSelected(true);
                } else if (viewType == VFSFilePane.VIEWTYPE_DETAILS) {
                    detailsViewButton.setSelected(true);
                }
            }
        }
    });

    // ************************************** //
    // ******* Add the directory pane ******* //
    // ************************************** //
    fc.add(getAccessoryPanel(), BorderLayout.AFTER_LINE_ENDS);

    JComponent accessory = fc.getAccessory();

    if (accessory != null) {
        getAccessoryPanel().add(accessory);
    }

    filePane.setPreferredSize(LIST_PREF_SIZE);
    fc.add(filePane, BorderLayout.CENTER);

    // ********************************** //
    // **** Construct the bottom panel ** //
    // ********************************** //
    bottomPanel = getBottomPanel();
    bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.Y_AXIS));
    fc.add(bottomPanel, BorderLayout.SOUTH);

    // FileName label and textfield
    JPanel fileNamePanel = new JPanel();
    fileNamePanel.setLayout(new BoxLayout(fileNamePanel, BoxLayout.LINE_AXIS));
    bottomPanel.add(fileNamePanel);
    bottomPanel.add(Box.createRigidArea(vstrut5));

    fileNameLabel = new AlignedLabel();
    populateFileNameLabel();
    fileNamePanel.add(fileNameLabel);

    fileNameTextField = new JTextField(35) {
        @Override
        public Dimension getMaximumSize() {
            return new Dimension(Short.MAX_VALUE, super.getPreferredSize().height);
        }
    };

    PopupHandler.installDefaultMouseListener(fileNameTextField);

    fileNamePanel.add(fileNameTextField);
    fileNameLabel.setLabelFor(fileNameTextField);
    fileNameTextField.addFocusListener(new FocusAdapter() {
        @Override
        public void focusGained(FocusEvent e) {
            if (!getFileChooser().isMultiSelectionEnabled()) {
                filePane.clearSelection();
            }
        }
    });

    if (fc.isMultiSelectionEnabled()) {
        setFileName(fileNameString(fc.getSelectedFileObjects()));
    } else {
        setFileName(fileNameString(fc.getSelectedFileObject()));
    }

    // Filetype label and combobox
    JPanel filesOfTypePanel = new JPanel();
    filesOfTypePanel.setLayout(new BoxLayout(filesOfTypePanel, BoxLayout.LINE_AXIS));
    bottomPanel.add(filesOfTypePanel);

    AlignedLabel filesOfTypeLabel = new AlignedLabel(filesOfTypeLabelText);
    filesOfTypePanel.add(filesOfTypeLabel);

    filterComboBoxModel = createFilterComboBoxModel();
    fc.addPropertyChangeListener(filterComboBoxModel);
    filterComboBox = new JComboBox(filterComboBoxModel);
    filterComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, filesOfTypeLabelText);
    filesOfTypeLabel.setLabelFor(filterComboBox);
    filterComboBox.setRenderer(createFilterComboBoxRenderer());
    filesOfTypePanel.add(filterComboBox);

    // buttons
    getButtonPanel().setLayout(new ButtonAreaLayout());

    approveButton = new JButton(getApproveButtonText(fc));
    // Note: Metal does not use mnemonics for approve and cancel
    approveButton.addActionListener(getApproveSelectionAction());
    fileNameTextField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                getApproveSelectionAction().actionPerformed(null);
            } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                getFileChooser().cancelSelection();
            }
        }
    });
    approveButton.setToolTipText(getApproveButtonToolTipText(fc));
    getButtonPanel().add(approveButton);

    cancelButton = new JButton(cancelButtonText);
    cancelButton.setToolTipText(cancelButtonToolTipText);
    cancelButton.addActionListener(getCancelSelectionAction());
    getButtonPanel().add(cancelButton);

    if (fc.getControlButtonsAreShown()) {
        addControlButtons();
    }

    groupLabels(new AlignedLabel[] { fileNameLabel, filesOfTypeLabel });
}

From source file:com.googlecode.vfsjfilechooser2.VFSJFileChooser.java

/**
 * Creates and returns a new <code>JDialog</code> wrapping
 * <code>this</code> centered on the <code>parent</code>
 * in the <code>parent</code>'s frame.
 * This method can be overriden to further manipulate the dialog,
 * to disable resizing, set the location, etc. Example:
 * <pre>/* w  w w.j av  a  2s.  co  m*/
 *     class MyFileChooser extends VFSJFileChooser {
 *         protected JDialog createDialog(Component parent) throws HeadlessException {
 *             JDialog dialog = super.createDialog(parent);
 *             dialog.setLocation(300, 200);
 *             dialog.setResizable(false);
 *             return dialog;
 *         }
 *     }
 * </pre>
 *
 * @param   parent  the parent component of the dialog;
 *                  can be <code>null</code>
 * @return a new <code>JDialog</code> containing this instance
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 * returns true.
 * @see java.awt.GraphicsEnvironment#isHeadless
 * @since 1.4
 */
protected JDialog createDialog(Component parent) throws HeadlessException {
    String title = getUI().getDialogTitle(this);
    putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, title);

    Window window = null;

    try {
        window = SwingUtilities.getWindowAncestor(parent);
    } catch (Exception ex) {
    }

    if (window == null) {
        if (parent instanceof Window) {
            window = (Window) parent;
        } else {
            window = SHARED_FRAME;
        }

        dialog = new JDialog((Frame) window, title, true);
    }

    else if (window instanceof Frame) {
        dialog = new JDialog((Frame) window, title, true);
    } else {
        dialog = new JDialog((Dialog) window, title, true);
    }

    dialog.setComponentOrientation(this.getComponentOrientation());

    Container contentPane = dialog.getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(this, BorderLayout.CENTER);

    if (JDialog.isDefaultLookAndFeelDecorated()) {
        boolean supportsWindowDecorations = UIManager.getLookAndFeel().getSupportsWindowDecorations();

        if (supportsWindowDecorations) {
            dialog.getRootPane().setWindowDecorationStyle(JRootPane.FILE_CHOOSER_DIALOG);
        }
    }

    dialog.pack();
    dialog.setLocationRelativeTo(parent);

    return dialog;
}