Java JButton Create makeIconButton(Icon icon, String tooltip)

Here you can find the source of makeIconButton(Icon icon, String tooltip)

Description

make Icon Button

License

Apache License

Declaration

public static JButton makeIconButton(Icon icon, String tooltip) 

Method Source Code

//package com.java2s;
/*//ww  w .ja  v a2s. c  o  m
 * Copyright (c) 2015 IBM Corporation and others.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * You may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

import javax.swing.*;
import java.awt.*;

public class Main {
    public static final Color BLUE3 = new Color(0, 178, 239);
    public static final Color BLUE8 = new Color(0, 25, 52);
    private static final Font BIG = new Font("Inconsolata, Arial", Font.BOLD, 14);

    public static JButton makeIconButton(Icon icon, String tooltip) {
        JButton button = new JButton(icon);
        button.setToolTipText(tooltip);
        button.setBackground(BLUE8);
        button.setForeground(BLUE3);
        button.setBorder(BorderFactory.createMatteBorder(5, 5, 5, 5, new Color(0, 0, 0, 0)));
        button.setFont(BIG);
        return button;
    }
}

Related

  1. makeButton(String name, ActionListener l)
  2. makeButtonActLikeLabel(JButton button)
  3. makeButtonBar(int align, Component... comps)
  4. makeButtonFlat(AbstractButton button)
  5. makeButtonPanel(Vector names, ActionListener actionListener)
  6. makeNavigationButton(String actionCommand, String toolTipText, String altText)
  7. makeRadioButton(String text, String actionCommand, ButtonGroup buttonGroup, boolean selected)
  8. makeToggleButton(final Object owner, final String id, final String altText, final int wpad, final int hpad)
  9. newButton(String name, String text)