getbutton.java

来自「好的超市源码供大家下载」· Java 代码 · 共 74 行

JAVA
74
字号
package view.com.getcomponent.button;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;

import view.com.interfaces.GetButtonInt;

/**
 * 获得各种规格的按钮的方法
 * 
 * @author linfeng
 */
public class GetButton implements GetButtonInt {

  /**
   * 
   */
  public JButton getButton(JButton button, String name) {
    button = new JButton(name);
    return button;
  }

  /**
   * 
   */
  public JButton[] getButton(JButton[] button, String[] names) {
    button = new JButton[names.length];
    for (int i = 0; i < names.length; i++) {
      button[i] = new JButton(names[i]);
    }
    return button;
  }

  /**
   * 
   */
  public JButton[] getButton(JButton[] button, String[] names, JDialog dialog) {
    button = new JButton[names.length];
    for (int i = 0; i < names.length; i++) {
      button[i] = new JButton(names[i]);
    }
    return button;
  }

  /**
   * 
   */
  public JButton getButton(String icon, String argActionCommand) {
    JButton button = new JButton(new ImageIcon(icon));
    button.setActionCommand(argActionCommand);
    button.setToolTipText(argActionCommand);
    return button;
  }

  public JButton getButton(String name, String icon, String argActionCommand) {
    JButton button = new JButton(name, new ImageIcon(icon));
    button.setActionCommand(argActionCommand);
    button.setToolTipText(argActionCommand);
    return button;
  }

  public JButton[] getButton(JButton[] button, String[] names, String[] icon,
      String[] argActionCommand) {
    button = new JButton[names.length];
    for (int i = 0; i < names.length; i++) {
      button[i] = new JButton(names[i], new ImageIcon(icon[i]));
      button[i].setActionCommand(argActionCommand[i]);
      button[i].setToolTipText(argActionCommand[i]);
    }
    return button;
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?