001package org.jdesktop.swingx.prompt;
002
003import java.awt.Cursor;
004import java.awt.Insets;
005
006import javax.swing.BorderFactory;
007import javax.swing.JButton;
008import javax.swing.border.Border;
009
010import org.jdesktop.swingx.plaf.SearchFieldUI;
011
012/**
013 * Non focusable, no border, no margin and insets button with no content area
014 * filled.
015 * 
016 * @author Peter Weishapl <petw@gmx.net>
017 * 
018 */
019public class BuddyButton extends JButton {
020    public BuddyButton() {
021        this(null);
022    }
023
024    public BuddyButton(String text) {
025        super(text);
026        setFocusable(false);
027        setMargin(SearchFieldUI.NO_INSETS);
028
029        // Windows UI will add 1 pixel for width and height, if this is true
030        setFocusPainted(false);
031
032        setBorderPainted(false);
033        setContentAreaFilled(false);
034        setIconTextGap(0);
035
036        setBorder(null);
037
038        setOpaque(false);
039
040        setCursor(Cursor.getDefaultCursor());
041    }
042
043    // Windows UI overrides Insets.
044    // Who knows what other UIs are doing...
045    @Override
046    public Insets getInsets() {
047        return SearchFieldUI.NO_INSETS;
048    }
049
050    @Override
051    public Insets getInsets(Insets insets) {
052        return getInsets();
053    }
054
055    @Override
056    public Insets getMargin() {
057        return getInsets();
058    }
059
060    @Override
061    public void setBorder(Border border) {
062        // Don't let Motif overwrite my Border
063        super.setBorder(BorderFactory.createEmptyBorder());
064    }
065}