Example usage for javax.swing JToggleButton setBorder

List of usage examples for javax.swing JToggleButton setBorder

Introduction

In this page you can find the example usage for javax.swing JToggleButton setBorder.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.")
public void setBorder(Border border) 

Source Link

Document

Sets the border of this component.

Usage

From source file:components.CrayonPanel.java

protected JToggleButton createCrayon(String name, Border normalBorder) {
    JToggleButton crayon = new JToggleButton();
    crayon.setActionCommand(name);//from www .  j  a va  2  s.co m
    crayon.addActionListener(this);

    //Set the image or, if that's invalid, equivalent text.
    ImageIcon icon = createImageIcon("images/" + name + ".gif");
    if (icon != null) {
        crayon.setIcon(icon);
        crayon.setToolTipText("The " + name + " crayon");
        crayon.setBorder(normalBorder);
    } else {
        crayon.setText("Image not found. This is the " + name + " button.");
        crayon.setFont(crayon.getFont().deriveFont(Font.ITALIC));
        crayon.setHorizontalAlignment(JButton.HORIZONTAL);
        crayon.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    }

    return crayon;
}

From source file:com.maxl.java.amikodesk.AMiKoDesk.java

private static void setupToggleButton(JToggleButton button) {
    button.setBackground(m_but_color_bg);
    button.setFocusPainted(false);// w  w w  . java2s  . co  m
    button.setBorder(new CompoundBorder(new LineBorder(m_but_color_bg), new EmptyBorder(0, 3, 0, 0)));
    button.setHorizontalAlignment(SwingConstants.LEFT);
}

From source file:com.maxl.java.amikodesk.AMiKoDesk.java

private static void setupButton(JToggleButton button, String toolTipText, String rolloverImg,
        String selectedImg) {/*from   w  ww.  j a  v  a2s.  c o m*/
    button.setFont(new Font("Dialog", Font.PLAIN, 12));
    button.setVerticalTextPosition(SwingConstants.BOTTOM);
    button.setHorizontalTextPosition(SwingConstants.CENTER);
    button.setText(toolTipText);
    button.setRolloverIcon(new ImageIcon(Constants.IMG_FOLDER + rolloverImg));
    button.setSelectedIcon(new ImageIcon(Constants.IMG_FOLDER + selectedImg));
    button.setBackground(m_selected_but_color);
    button.setToolTipText(toolTipText);

    // Remove border
    Border emptyBorder = BorderFactory.createEmptyBorder();
    button.setBorder(emptyBorder);
    // Set adequate size
    button.setPreferredSize(new Dimension(32, 32));
}

From source file:org.datacleaner.windows.AnalysisJobBuilderWindowImpl.java

private JToggleButton createViewToggleButton(final String text, final String iconPath) {
    final ImageIcon icon = imageManager.getImageIcon(iconPath);
    final JToggleButton button = new JToggleButton(text, icon);
    button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    button.setFont(WidgetUtils.FONT_SMALL);
    button.setForeground(WidgetUtils.BG_COLOR_BRIGHTEST);
    button.setBackground(WidgetUtils.BG_COLOR_DARK);
    button.setBorderPainted(false);//  w  w  w.j a v a 2s  .  c  o m
    button.setBorder(new CompoundBorder(WidgetUtils.BORDER_THIN, new EmptyBorder(0, 4, 0, 4)));
    return button;
}

From source file:org.revager.tools.GUITools.java

/**
 * Creates a new image toggle button.//from  ww w  . ja  v a  2 s.c  o m
 * 
 * @param icon
 *            the normal icon
 * @param rolloverIcon
 *            the rollover icon
 * @param action
 *            the action
 * 
 * @return the newly created image button
 */
public static JToggleButton newImageToggleButton(ImageIcon icon, ImageIcon rolloverIcon, Action action) {
    JToggleButton button = new JToggleButton(action);
    button.setToolTipText(button.getText());
    button.setText(null);
    button.setContentAreaFilled(false);
    button.setBorder(new EmptyBorder(0, 0, 0, 0));
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setBorderPainted(false);
    button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    button.setFocusPainted(false);
    button.setFocusable(false);

    button.setIcon(icon);
    button.setRolloverIcon(rolloverIcon);
    button.setRolloverSelectedIcon(rolloverIcon);
    button.setSelectedIcon(rolloverIcon);

    return button;
}

From source file:org.revager.tools.GUITools.java

/**
 * Creates a new image toggle button./*from   www  . j  a  va  2  s .c  o  m*/
 * 
 * @return the newly created image toggle button
 */
public static JToggleButton newImageToggleButton() {
    JToggleButton button = new JToggleButton();

    button.setBorder(new EmptyBorder(2, 2, 2, 8));
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setBorderPainted(false);
    button.setOpaque(false);
    button.setContentAreaFilled(false);
    button.setFocusable(false);
    button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    return button;
}