Java JButton Key Event makeJButton(ResourceBundle resource, String panelName, String keyword, Icon icon, ActionListener listener)

Here you can find the source of makeJButton(ResourceBundle resource, String panelName, String keyword, Icon icon, ActionListener listener)

Description

Factory Method to create Button using specified params

License

Open Source License

Declaration

public static JButton makeJButton(ResourceBundle resource, String panelName, String keyword, Icon icon,
        ActionListener listener) 

Method Source Code

//package com.java2s;
// it under the terms of the GNU General Public License as published by

import java.awt.event.ActionListener;

import java.util.MissingResourceException;
import java.util.ResourceBundle;

import javax.swing.Icon;
import javax.swing.JButton;

public class Main {
    /**/* w  ww .  j  a  va 2 s  . c  o m*/
     * Factory Method to create Button using specified params
     */
    public static JButton makeJButton(ResourceBundle resource, String panelName, String keyword, Icon icon,
            ActionListener listener) {
        String label;
        try {
            label = resource.getString(panelName + "_BUTTON_" + keyword + "_LABEL");
        } catch (MissingResourceException e) {
            label = "Missing Label";
        }

        JButton button = new JButton();
        if (label != null)
            button.setText(label);
        if (icon != null)
            button.setIcon(icon);
        button.addActionListener(listener);
        //setToolTip(resource, panelName, "BUTTON_"+keyword, button);

        return button;
    }
}

Related

  1. addFastKeys(JButton[] buttonList)
  2. setButtonKeyStroke(final JButton button, KeyStroke keyStroke)