示例#1
0
  /**
   * Return defined button with own click handler
   *
   * @param type selected button type
   * @param title text displayed on button hover
   * @param clickAction ClickHandler / if null it's not added
   * @return create button
   */
  public static CustomButton getPredefinedButton(
      ButtonType type, String title, ClickHandler clickAction) {

    CustomButton b = new CustomButton();

    // icon first
    b.setIcon(getButtonIconByType(type));
    // then text

    b.setText(getButtonTextByType(type));

    if (title != null && !title.isEmpty()) {
      b.setTitle(title);
    }

    if (clickAction != null) {
      b.addClickHandler(clickAction);
    }

    if (ButtonType.CONTINUE.equals(type)) {
      b.setImageAlign(true);
    }

    return b;
  }
示例#2
0
文件: Css.java 项目: k9m/simplechat
  public static JButton getCustButton(String path_On, String path_Off) {
    CustomButton component = new CustomButton();
    Icon myIcon1 = new ImageIcon(path_On);
    Icon myIcon2 = new ImageIcon(path_Off);

    int height = myIcon1.getIconHeight();
    int width = myIcon1.getIconWidth();
    Dimension dim = new Dimension(height + 1, width + 1);

    component.setCursor(CURSOR);
    component.setRolloverEnabled(true);
    component.setMinimumSize(dim);
    component.setMaximumSize(dim);
    component.setPreferredSize(dim);

    component.setIcon(myIcon2);
    component.setRolloverIcon(myIcon1);
    component.setPressedIcon(myIcon1);

    // button.setBorderPainted(false);
    // button.setContentAreaFilled(false);

    return component;
  }