Java JButton Create createButton(ImageIcon icon, String text)

Here you can find the source of createButton(ImageIcon icon, String text)

Description

create Button

License

Open Source License

Return

A JButton in which the text is shown if the icon is null

Declaration

public static JButton createButton(ImageIcon icon, String text) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import javax.swing.*;

public class Main {
    /** @return A JButton in which the text is shown if the icon is null */
    public static JButton createButton(ImageIcon icon, String text) {
        JButton toret;// w  w w. j  ava2s.  c o  m

        if (icon != null) {
            toret = new JButton(icon);
        } else {
            toret = new JButton(text);
        }

        toret.setToolTipText(text);
        return toret;
    }
}

Related

  1. createButton(Action action)
  2. createButton(Action action)
  3. createButton(char mnemonic, Action action, Icon icon)
  4. CreateButton(final String name, final String text, final ImageIcon icon, final JPanel panel)
  5. createButton(Icon icon, String tooltip, String ac)
  6. createButton(String aText, String aTooltip, ActionListener aListener)
  7. createButton(String name, ActionListener listener)
  8. createButton(String name, int x, int y, int width, int height, ImageIcon imageIcon)
  9. createButton(String text, boolean parse)