Example usage for javax.swing JButton getAccessibleContext

List of usage examples for javax.swing JButton getAccessibleContext

Introduction

In this page you can find the example usage for javax.swing JButton getAccessibleContext.

Prototype

@BeanProperty(bound = false, expert = true, description = "The AccessibleContext associated with this Button.")
public AccessibleContext getAccessibleContext() 

Source Link

Document

Gets the AccessibleContext associated with this JButton.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton button = new JButton(new ImageIcon("image.gif"));
    button.setToolTipText("Button Name");

    button.getAccessibleContext().setAccessibleName("Button Name");
}

From source file:com.kenai.redminenb.util.RedmineUtil.java

public static boolean show(ActionListenerPanel panel, String title, String okName) {
    JButton ok = new JButton(okName);
    JButton cancel = new JButton("Cancel"); // NOI18N
    final DialogDescriptor dd = new DialogDescriptor(panel, title, true, new Object[] { ok, cancel }, ok,
            DialogDescriptor.DEFAULT_ALIGN, HelpCtx.DEFAULT_HELP, panel);

    ok.getAccessibleContext().setAccessibleDescription(ok.getText());
    cancel.getAccessibleContext().setAccessibleDescription(cancel.getText());

    panel.setOkButton(ok);/*from  w  w w . j av a 2 s  .  c  o  m*/
    panel.setCancelButton(cancel);
    panel.setDialogDescribtor(dd);

    dd.setClosingOptions(new Object[] { cancel });

    return DialogDisplayer.getDefault().notify(dd) == ok;
}

From source file:com.game.ui.views.CharachterEditorPanel.java

@Override
public void actionPerformed(ActionEvent ae) {
    if (ae.getActionCommand().equalsIgnoreCase("dropDown")) {
        JComboBox comboBox = (JComboBox) ae.getSource();
        JPanel panel = (JPanel) comboBox.getParent().getComponent(4);
        String name = comboBox.getSelectedItem().toString();
        for (GameCharacter enemy : GameBean.enemyDetails) {
            if (enemy.getName().equalsIgnoreCase(name)) {
                ((JTextField) panel.getComponent(2)).setText(enemy.getName());
                ((JTextField) panel.getComponent(4)).setText(enemy.getImagePath());
                ((JTextField) panel.getComponent(6)).setText(new Integer(enemy.getHealth()).toString());
                ((JTextField) panel.getComponent(8)).setText(new Integer(enemy.getAttackPts()).toString());
                ((JTextField) panel.getComponent(10)).setText(new Integer(enemy.getArmor()).toString());
                ((JTextField) panel.getComponent(12)).setText(new Integer(enemy.getAttackRange()).toString());
                ((JTextField) panel.getComponent(14)).setText(new Integer(enemy.getMovement()).toString());
                return;
            }/*w w  w.  j av  a2 s.  c  o  m*/
        }
    } else {
        JButton btn = (JButton) ae.getSource();
        JPanel panel = (JPanel) btn.getParent();
        int indexOfBtn = btn.getAccessibleContext().getAccessibleIndexInParent();
        String name = ((JTextField) panel.getComponent(2)).getText();
        String image = ((JTextField) panel.getComponent(4)).getText();
        String health = ((JTextField) panel.getComponent(6)).getText();
        String attackPts = ((JTextField) panel.getComponent(8)).getText();
        String armourPts = ((JTextField) panel.getComponent(10)).getText();
        String attackRnge = ((JTextField) panel.getComponent(12)).getText();
        String movement = ((JTextField) panel.getComponent(14)).getText();
        System.out.println("Index : " + indexOfBtn);
        JLabel message = ((JLabel) this.getComponent(5));
        message.setText("");
        message.setVisible(false);
        if (StringUtils.isNotBlank(name) && StringUtils.isNotBlank(image) && StringUtils.isNotBlank(health)
                && StringUtils.isNotBlank(attackPts) && StringUtils.isNotBlank(armourPts)
                && StringUtils.isNotBlank(attackRnge) && StringUtils.isNotBlank(movement)) {
            message.setVisible(false);
            GameCharacter character = new GameCharacter();
            character.setName(name);
            character.setAttackPts(Integer.parseInt(attackPts));
            character.setAttackRange(Integer.parseInt(attackRnge));
            character.setHealth(Integer.parseInt(health));
            character.setImagePath(image);
            character.setMovement(Integer.parseInt(movement));
            character.setArmor(Integer.parseInt(armourPts));
            boolean characterAlrdyPresent = false;
            for (int i = 0; i < GameBean.enemyDetails.size(); i++) {
                GameCharacter charFromList = GameBean.enemyDetails.get(i);
                if (charFromList.getName().equalsIgnoreCase(name)) {
                    GameBean.enemyDetails.remove(i);
                    GameBean.enemyDetails.add(i, character);
                    characterAlrdyPresent = true;
                }
            }
            if (!characterAlrdyPresent) {
                GameBean.enemyDetails.add(character);
            }
            try {
                GameUtils.writeCharactersToXML(GameBean.enemyDetails, Configuration.PATH_FOR_ENEMY_CHARACTERS);
                message.setText("Saved Successfully..");
                message.setVisible(true);
                if (!characterAlrdyPresent) {
                    comboBox.addItem(name);
                    comboBox.setSelectedItem(name);
                }
                TileInformation tileInfo = GameBean.mapInfo.getPathMap().get(location);
                if (tileInfo == null) {
                    tileInfo = new TileInformation();
                }
                tileInfo.setEnemy(character);
                GameBean.mapInfo.getPathMap().put(location, tileInfo);
                chkBox.setSelected(true);
                this.revalidate();
                return;
            } catch (Exception e) {
                System.out.println("CharachterEditorPanel : actionPerformed() : Some error occured " + e);
                e.printStackTrace();
            }

        } else {
            message.setText("Pls enter all the fields or pls choose a character from the drop down");
            message.setVisible(true);
            this.revalidate();
        }
    }
}

From source file:com.eviware.soapui.support.components.SimpleForm.java

public JButton appendButton(String label, String tooltip) {
    JButton button = new JButton();
    button.setToolTipText(StringUtils.defaultIfEmpty(tooltip, null));
    button.getAccessibleContext().setAccessibleDescription(tooltip);
    append(label, button);//from ww w. java2s .c o m
    return button;
}

From source file:org.swiftexplorer.gui.AboutDlg.java

public static void show(Component parent, HasLocalizedStrings stringsBundle) {
    URI uri = null;/* w w  w  .  ja v a  2 s. c  o  m*/
    try {
        uri = new URI("http://www.swiftexplorer.org");
    } catch (URISyntaxException e) {
        logger.error("URL seems to be ill-formed", e);
    }
    final String buttontext = "www.swiftexplorer.org";

    Box mainBox = Box.createVerticalBox();
    mainBox.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0));

    StringBuilder sb = loadResource("/about.html");
    JLabel label = new JLabel(sb.toString());
    label.getAccessibleContext().setAccessibleDescription(getTitle(stringsBundle));
    mainBox.add(label);

    if (uri != null) {
        JButton button = new JButton();
        button.setText(buttontext);
        button.setToolTipText(uri.toString());
        button.addActionListener(new OpenUrlAction(uri));
        FontMetrics metrics = button.getFontMetrics(button.getFont());
        if (metrics != null)
            button.setSize(metrics.stringWidth(buttontext), button.getHeight());
        button.getAccessibleContext().setAccessibleDescription(buttontext);
        mainBox.add(button);
    }

    mainBox.add(Box.createVerticalStrut(10));

    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    panel.add(mainBox);

    JOptionPane.showMessageDialog(parent, panel, getTitle(stringsBundle), JOptionPane.INFORMATION_MESSAGE,
            getIcon());
}