Example usage for javax.swing JButton setFocusPainted

List of usage examples for javax.swing JButton setFocusPainted

Introduction

In this page you can find the example usage for javax.swing JButton setFocusPainted.

Prototype

@BeanProperty(visualUpdate = true, description = "Whether focus should be painted")
public void setFocusPainted(boolean b) 

Source Link

Document

Sets the paintFocus property, which must be true for the focus state to be painted.

Usage

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

/**
 * Creates a new image button.//w ww .  j a 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 JButton newImageButton(ImageIcon icon, ImageIcon rolloverIcon, Action action) {
    JButton button = new JButton(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.tinymediamanager.ui.dialogs.ImageChooserDialog.java

@SuppressWarnings({ "unchecked", "rawtypes" })
private void addImage(BufferedImage originalImage, final MediaArtwork artwork) {
    Point size = null;//from   w w  w.jav a 2s.  c  o m

    GridBagLayout gbl = new GridBagLayout();

    switch (type) {
    case FANART:
    case CLEARART:
    case THUMB:
    case DISC:
        gbl.columnWidths = new int[] { 130 };
        gbl.rowHeights = new int[] { 180 };
        size = ImageCache.calculateSize(300, 150, originalImage.getWidth(), originalImage.getHeight(), true);
        break;

    case BANNER:
    case LOGO:
    case CLEARLOGO:
        gbl.columnWidths = new int[] { 130 };
        gbl.rowHeights = new int[] { 120 };
        size = ImageCache.calculateSize(300, 100, originalImage.getWidth(), originalImage.getHeight(), true);
        break;

    case POSTER:
    default:
        gbl.columnWidths = new int[] { 180 };
        gbl.rowHeights = new int[] { 270 };
        size = ImageCache.calculateSize(150, 250, originalImage.getWidth(), originalImage.getHeight(), true);
        break;

    }

    gbl.columnWeights = new double[] { Double.MIN_VALUE };
    gbl.rowWeights = new double[] { Double.MIN_VALUE };
    JPanel imagePanel = new JPanel();
    imagePanel.setLayout(gbl);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 3;
    gbc.insets = new Insets(5, 5, 5, 5);

    JToggleButton button = new JToggleButton();
    button.setBackground(Color.white);
    button.setUI(toggleButtonUI);
    button.setMargin(new Insets(10, 10, 10, 10));
    ImageIcon imageIcon = new ImageIcon(Scalr.resize(originalImage, Scalr.Method.BALANCED, Scalr.Mode.AUTOMATIC,
            size.x, size.y, Scalr.OP_ANTIALIAS));
    button.setIcon(imageIcon);
    button.putClientProperty("MediaArtwork", artwork);

    buttonGroup.add(button);
    buttons.add(button);
    imagePanel.add(button, gbc);

    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.anchor = GridBagConstraints.LAST_LINE_START;
    gbc.insets = new Insets(0, 5, 0, 0);

    JComboBox cb = null;
    if (artwork.getImageSizes().size() > 0) {
        cb = new JComboBox(artwork.getImageSizes().toArray());
    } else {
        cb = new JComboBox(new String[] { originalImage.getWidth() + "x" + originalImage.getHeight() });
    }
    button.putClientProperty("MediaArtworkSize", cb);
    imagePanel.add(cb, gbc);

    // should we provide an option for extrathumbs
    if (mediaType == MediaType.MOVIE && type == ImageType.FANART
            && MovieModuleManager.MOVIE_SETTINGS.isImageExtraThumbs()) {
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 1;
        gbc.anchor = GridBagConstraints.LINE_END;
        JLabel label = new JLabel("Extrathumb");
        imagePanel.add(label, gbc);

        gbc = new GridBagConstraints();
        gbc.gridx = 2;
        gbc.gridy = 1;
        gbc.anchor = GridBagConstraints.LINE_END;
        JCheckBox chkbx = new JCheckBox();
        button.putClientProperty("MediaArtworkExtrathumb", chkbx);
        imagePanel.add(chkbx, gbc);
    }

    // should we provide an option for extrafanart
    if (mediaType == MediaType.MOVIE && type == ImageType.FANART
            && MovieModuleManager.MOVIE_SETTINGS.isImageExtraFanart()) {
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = MovieModuleManager.MOVIE_SETTINGS.isImageExtraThumbs() ? 2 : 1;
        gbc.anchor = GridBagConstraints.LINE_END;
        JLabel label = new JLabel("Extrafanart");
        imagePanel.add(label, gbc);

        gbc = new GridBagConstraints();
        gbc.gridx = 2;
        gbc.gridy = MovieModuleManager.MOVIE_SETTINGS.isImageExtraThumbs() ? 2 : 1;
        gbc.anchor = GridBagConstraints.LINE_END;
        JCheckBox chkbx = new JCheckBox();
        button.putClientProperty("MediaArtworkExtrafanart", chkbx);
        imagePanel.add(chkbx, gbc);
    }

    /* show image button */
    gbc.gridx = 0;
    gbc.gridy++;
    gbc.anchor = GridBagConstraints.LAST_LINE_START;
    gbc.gridwidth = 3;
    gbc.insets = new Insets(0, 0, 0, 0);
    JButton btnShowImage = new JButton("<html><font color=\"#0000CF\"><u>"
            + BUNDLE.getString("image.showoriginal") + "</u></font></html>");
    btnShowImage.setBorderPainted(false);
    btnShowImage.setFocusPainted(false);
    btnShowImage.setContentAreaFilled(false);
    btnShowImage.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            ImagePreviewDialog dialog = new ImagePreviewDialog(artwork.getDefaultUrl());
            dialog.setVisible(true);
        }
    });
    imagePanel.add(btnShowImage, gbc);

    panelImages.add(imagePanel);
    panelImages.validate();
    panelImages.getParent().validate();
}

From source file:org.tinymediamanager.ui.MainWindow.java

/**
 * Create the application./*w  w w . ja  v a 2s.co  m*/
 * 
 * @param name
 *          the name
 */
public MainWindow(String name) {
    super(name);
    setName("mainWindow");
    setMinimumSize(new Dimension(1000, 700));

    instance = this;

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    JMenu mnTmm = new JMenu("tinyMediaManager");
    mnTmm.setMnemonic(KeyEvent.VK_T);
    menuBar.add(mnTmm);

    if (!Globals.isDonator()) {
        mnTmm.add(new RegisterDonatorVersionAction());
    }

    mnTmm.add(new SettingsAction());
    mnTmm.addSeparator();
    mnTmm.add(new LaunchUpdaterAction());
    mnTmm.addSeparator();
    mnTmm.add(new ExitAction());
    initialize();

    // tools menu
    JMenu tools = new JMenu(BUNDLE.getString("tmm.tools")); //$NON-NLS-1$
    tools.setMnemonic(KeyEvent.VK_O);
    tools.add(new ClearDatabaseAction());

    JMenu cache = new JMenu(BUNDLE.getString("tmm.cache")); //$NON-NLS-1$
    cache.setMnemonic(KeyEvent.VK_C);
    tools.add(cache);
    JMenuItem clearImageCache = new JMenuItem(new ClearImageCacheAction());
    clearImageCache.setMnemonic(KeyEvent.VK_I);
    cache.add(clearImageCache);

    JMenuItem rebuildImageCache = new JMenuItem(new RebuildImageCacheAction());
    rebuildImageCache.setMnemonic(KeyEvent.VK_R);
    cache.add(rebuildImageCache);

    JMenuItem tmmFolder = new JMenuItem(BUNDLE.getString("tmm.gotoinstalldir")); //$NON-NLS-1$
    tmmFolder.setMnemonic(KeyEvent.VK_I);
    tools.add(tmmFolder);
    tmmFolder.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            Path path = Paths.get(System.getProperty("user.dir"));
            try {
                // check whether this location exists
                if (Files.exists(path)) {
                    TmmUIHelper.openFile(path);
                }
            } catch (Exception ex) {
                LOGGER.error("open filemanager", ex);
                MessageManager.instance.pushMessage(new Message(MessageLevel.ERROR, path,
                        "message.erroropenfolder", new String[] { ":", ex.getLocalizedMessage() }));
            }
        }
    });

    JMenuItem tmmLogs = new JMenuItem(BUNDLE.getString("tmm.errorlogs")); //$NON-NLS-1$
    tmmLogs.setMnemonic(KeyEvent.VK_L);
    tools.add(tmmLogs);
    tmmLogs.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            JDialog logDialog = new LogDialog();
            logDialog.setLocationRelativeTo(MainWindow.getActiveInstance());
            logDialog.setVisible(true);
        }
    });

    JMenuItem tmmMessages = new JMenuItem(BUNDLE.getString("tmm.messages")); //$NON-NLS-1$
    tmmMessages.setMnemonic(KeyEvent.VK_L);
    tools.add(tmmMessages);
    tmmMessages.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            JDialog messageDialog = MessageHistoryDialog.getInstance();
            messageDialog.setVisible(true);
        }
    });

    tools.addSeparator();
    final JMenu menuWakeOnLan = new JMenu(BUNDLE.getString("tmm.wakeonlan")); //$NON-NLS-1$
    menuWakeOnLan.setMnemonic(KeyEvent.VK_W);
    menuWakeOnLan.addMenuListener(new MenuListener() {
        @Override
        public void menuCanceled(MenuEvent arg0) {
        }

        @Override
        public void menuDeselected(MenuEvent arg0) {
        }

        @Override
        public void menuSelected(MenuEvent arg0) {
            menuWakeOnLan.removeAll();
            for (final WolDevice device : Globals.settings.getWolDevices()) {
                JMenuItem item = new JMenuItem(device.getName());
                item.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent arg0) {
                        Utils.sendWakeOnLanPacket(device.getMacAddress());
                    }
                });
                menuWakeOnLan.add(item);
            }
        }
    });
    tools.add(menuWakeOnLan);

    // activate/deactivate WakeOnLan menu item
    tools.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(MenuEvent e) {
            if (Globals.settings.getWolDevices().size() > 0) {
                menuWakeOnLan.setEnabled(true);
            } else {
                menuWakeOnLan.setEnabled(false);
            }
        }

        @Override
        public void menuDeselected(MenuEvent e) {
        }

        @Override
        public void menuCanceled(MenuEvent e) {
        }
    });

    if (Globals.isDebug()) {
        final JMenu debugMenu = new JMenu("Debug"); //$NON-NLS-1$

        JMenuItem trace = new JMenuItem("set Logger to TRACE"); //$NON-NLS-1$
        trace.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
                lc.getLogger("org.tinymediamanager").setLevel(Level.TRACE);
                MessageManager.instance.pushMessage(new Message("Trace levels set!", ""));
                LOGGER.trace("if you see that, we're now on TRACE logging level ;)");
            }
        });

        debugMenu.add(trace);
        tools.add(debugMenu);
    }

    menuBar.add(tools);

    mnTmm = new JMenu(BUNDLE.getString("tmm.contact")); //$NON-NLS-1$
    mnTmm.setMnemonic(KeyEvent.VK_C);
    mnTmm.add(new FeedbackAction()).setMnemonic(KeyEvent.VK_F);
    mnTmm.add(new BugReportAction()).setMnemonic(KeyEvent.VK_B);
    menuBar.add(mnTmm);

    mnTmm = new JMenu(BUNDLE.getString("tmm.help")); //$NON-NLS-1$
    mnTmm.setMnemonic(KeyEvent.VK_H);
    menuBar.add(mnTmm);

    mnTmm.add(new WikiAction()).setMnemonic(KeyEvent.VK_W);
    mnTmm.add(new FaqAction()).setMnemonic(KeyEvent.VK_F);
    mnTmm.add(new ForumAction()).setMnemonic(KeyEvent.VK_O);
    mnTmm.addSeparator();

    mnTmm.add(new AboutAction()).setMnemonic(KeyEvent.VK_A);

    menuBar.add(Box.createGlue());

    if (!Globals.isDonator()) {
        JButton btnDonate = new JButton(new DonateAction());
        btnDonate.setBorderPainted(false);
        btnDonate.setFocusPainted(false);
        btnDonate.setContentAreaFilled(false);
        menuBar.add(btnDonate);
    }

    checkForUpdate();
}

From source file:snepsui.Interface.DrawNetwork.java

/**
 * Initializes the components in the DrawNetwork panel
 *///from  ww  w  . j  a va2 s.c  o m
private void initGUI() {
    nodesList = new LinkedList<Node>();
    molNodes = new Hashtable<String, CaseFrame>();
    builtMolNodes = new Hashtable<String, Node>();

    this.setPreferredSize(new Dimension(815, 600));

    graph = new DirectedOrderedSparseMultigraph<String, String>();

    this.layout = new StaticLayout<String, String>(graph, new Dimension(700, 450));

    shape = new Transformer<String, Integer>() {
        public Integer transform(String vertex) {
            int stringLength = 0;
            if (molNodes.containsKey(vertex)) {
                stringLength = 3;
            } else {
                for (Node node : nodesList) {
                    if (vertex.equals(node.getIdentifier())) {
                        stringLength = node.getIdentifier().length();
                    }
                }
            }
            return stringLength;
        }
    };

    vertexPaint = new Transformer<String, Paint>() {
        public Paint transform(String vertex) {
            if (molNodes.containsKey(vertex)) {
                if (builtMolNodes.containsKey(vertex)) {
                    Node node = builtMolNodes.get(vertex);
                    if (node.getClass().getSimpleName().equals("PatternNode")) {
                        return Color.blue;
                    } else if (node.getClass().getSimpleName().equals("ClosedNode")) {
                        return Color.yellow;
                    }
                } else
                    return Color.white;
            } else {
                for (Node node : nodesList) {
                    if (node.getIdentifier().equals(vertex)) {
                        if (node.getClass().getSimpleName().equals("BaseNode")) {
                            return Color.green;
                        } else if (node.getClass().getSimpleName().equals("VariableNode")) {
                            return Color.gray;
                        } else if (node.getClass().getSimpleName().equals("PatternNode")) {
                            return Color.blue;
                        } else if (node.getClass().getSimpleName().equals("ClosedNode")) {
                            return Color.yellow;
                        } else {
                            return Color.magenta;
                        }
                    }
                }
            }
            return Color.white;
        }
    };

    edgeLabel = new Transformer<String, String>() {
        public String transform(String edge) {
            String result = "";

            if (edge.isEmpty())
                graph.removeEdge("");
            vv.repaint();
            try {
                result = edge.substring(0, edge.indexOf(":"));
            } catch (StringIndexOutOfBoundsException e) {

            }
            return result;
        }
    };

    VertexShapeSizeAspect<String> vssa = new VertexShapeSizeAspect<String>(graph, shape);

    vv = new VisualizationViewer<String, String>(layout, new Dimension(700, 470));
    vv.setBackground(Color.white);

    vv.getRenderContext().setVertexLabelTransformer(MapTransformer.<String, String>getInstance(
            LazyMap.<String, String>decorate(new HashMap<String, String>(), new ToStringLabeller<String>())));
    vv.getRenderContext().setEdgeLabelTransformer(MapTransformer.<String, String>getInstance(
            LazyMap.<String, String>decorate(new HashMap<String, String>(), new ToStringLabeller<String>())));
    vv.setVertexToolTipTransformer(vv.getRenderContext().getVertexLabelTransformer());
    vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
    vv.getRenderContext().setVertexShapeTransformer(vssa);
    vv.getRenderContext()
            .setEdgeLabelClosenessTransformer(new ConstantDirectionalEdgeValueTransformer(0.5, 0.5));
    vv.getRenderContext().setEdgeLabelTransformer(edgeLabel);
    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
    vv.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            point = e.getPoint();
        }

        public void mouseReleased(MouseEvent e) {
            vv.repaint();
        }
    });
    vssa.setScaling(true);

    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    this.add(panel);
    Factory<String> vertexFactory = new VertexFactory();
    Factory<String> edgeFactory = new EdgeFactory();

    final EditingModalGraphMouse<String, String> graphMouse = new EditingModalGraphMouse<String, String>(
            vv.getRenderContext(), vertexFactory, edgeFactory);

    graphMouse.add(new CustomEditingPopupGraphMousePlugin<String>(vertexFactory, edgeFactory));
    graphMouse.remove(graphMouse.getPopupEditingPlugin());

    vv.setGraphMouse(graphMouse);
    vv.addKeyListener(graphMouse.getModeKeyListener());

    graphMouse.setMode(ModalGraphMouse.Mode.EDITING);

    final ScalingControl scaler = new CrossoverScalingControl();

    vv.scaleToLayout(scaler);

    String path = "src/snepsui/Interface/resources/icons/";

    JButton plus = new JButton();
    plus.setIcon(new ImageIcon(path + "zoom_in.png"));
    plus.setSize(18, 18);
    plus.setFocusPainted(false);
    plus.setBorderPainted(false);
    plus.setContentAreaFilled(false);
    plus.setMargin(new Insets(0, 0, 0, 0));
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });

    JButton minus = new JButton();
    minus.setIcon(new ImageIcon(path + "zoom_out.png"));
    minus.setSize(18, 18);
    minus.setFocusPainted(false);
    minus.setBorderPainted(false);
    minus.setContentAreaFilled(false);
    minus.setMargin(new Insets(0, 0, 0, 0));
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JPanel scaleGrid = new JPanel(new GridLayout(1, 2));
    scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));

    JButton colors = new JButton(new ImageIcon(path + "colors.png"));
    colors.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(getRootPane(), new NodeColors());
        }
    });

    JButton infoButton = new JButton(new ImageIcon(path + "info.png"));
    infoButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(vv, instructions, "Instructions", JOptionPane.INFORMATION_MESSAGE,
                    new ImageIcon("src/snepsui/Interface/resources/icons/info.png"));
        }
    });

    JButton resetbutton = new JButton(new ImageIcon(path + "refresh.png"));
    resetbutton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            ImageIcon icon = new ImageIcon("src/snepsui/Interface/resources/icons/info.png");
            int result = JOptionPane.showConfirmDialog(vv, "Are you sure you want to reset the drawing area?",
                    "Reset", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, icon);
            if (result == JOptionPane.YES_OPTION) {
                builtMolNodes.clear();
                molNodes.clear();
                nodesList.clear();

                LinkedList<String> vertexList = new LinkedList<String>();
                Collection<String> vertices = graph.getVertices();
                for (String vertex : vertices) {
                    vertexList.add(vertex);
                }

                for (String item : vertexList) {
                    graph.removeVertex(item);
                }
                vv.repaint();
            }
        }
    });

    JLabel caseframeLabel = new JLabel("Case Frames");
    DefaultComboBoxModel caseframeComboBoxModel = new DefaultComboBoxModel(
            new String[] { "define-caseframe", "undefine-caseframe" });
    caseframeComboBox = new JComboBox();
    caseframeComboBox.setModel(caseframeComboBoxModel);
    caseframeComboBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            addCaseFrameCommands(e);
        }
    });

    JLabel relationsLabel = new JLabel("Relations");
    DefaultComboBoxModel relationsComboBoxModel = new DefaultComboBoxModel(
            new String[] { "define", "undefine" });
    relationsComboBox = new JComboBox();
    relationsComboBox.setModel(relationsComboBoxModel);
    relationsComboBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            addRelationCommands(e);
        }
    });

    JPanel options = new JPanel(new GridLayout(3, 1));
    options.add(infoButton);
    options.add(resetbutton);
    options.add(colors);
    this.add(options, BorderLayout.EAST);

    JPanel controls = new JPanel();
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(scaleGrid);
    controls.add(relationsLabel);
    controls.add(relationsComboBox);
    controls.add(caseframeLabel);
    controls.add(caseframeComboBox);
    JComboBox modeBox = graphMouse.getModeComboBox();
    controls.add(modeBox);
    this.add(controls, BorderLayout.SOUTH);
}

From source file:uk.chromis.pos.forms.JRootApp.java

private void listPeople() {
    try {/*from w  w  w .j  a  v  a  2 s  .  c om*/
        jScrollPane1.getViewport().setView(null);
        JFlowPanel jPeople = new JFlowPanel();
        jPeople.applyComponentOrientation(getComponentOrientation());
        java.util.List people = m_dlSystem.listPeopleVisible();

        for (int i = 0; i < people.size(); i++) {

            AppUser user = (AppUser) people.get(i);
            JButton btn = new JButton(new AppUserAction(user));
            btn.applyComponentOrientation(getComponentOrientation());
            btn.setFocusPainted(false);
            btn.setFocusable(false);
            btn.setRequestFocusEnabled(false);
            btn.setMaximumSize(new Dimension(130, 60));
            btn.setPreferredSize(new Dimension(130, 60));
            btn.setMinimumSize(new Dimension(130, 60));
            btn.setHorizontalAlignment(SwingConstants.CENTER);
            btn.setHorizontalTextPosition(AbstractButton.CENTER);
            btn.setVerticalTextPosition(AbstractButton.BOTTOM);
            jPeople.add(btn);
        }
        jScrollPane1.getViewport().setView(jPeople);

    } catch (BasicException ee) {
    }
}

From source file:util.ui.UiUtilities.java

/**
 * Gibt einen Button mit Icon und Schrift zurck, der so initialisiert ist,
 * da man ihn gut fr Symbolleisten nutzen kann (Rahmen nur bei Rollover
 * sichtbar usw.)./*from   w  w  w. jav  a2s .c om*/
 * <P>
 * Wenn text und iconDateiname angegeben sind, dann wird text als TooltipText
 * gesetzt.
 *
 * @param text
 *          Der Text des Buttons (Kann null sein, wenn der Button keinen Text
 *          enthalten soll)
 * @param icon
 *          Das Icon des Buttons (Kann ebenfalls null sein, wenn der Button
 *          kein Icon enthalten soll).
 * @return button
 */
public static JButton createToolBarButton(String text, Icon icon) {
    final JButton btn;
    if (icon == null) {
        btn = new JButton(text);
    } else {
        btn = new JButton(icon);
        btn.setToolTipText(text);
        btn.setBorderPainted(false);
        btn.setMargin(ZERO_INSETS);

        btn.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseEntered(MouseEvent e) {
                if (btn.isEnabled()) {
                    btn.setBorderPainted(true);
                }
            }

            @Override
            public void mouseExited(MouseEvent e) {
                btn.setBorderPainted(false);
            }
        });
    }
    btn.setFocusPainted(false);

    return btn;
}