Example usage for javax.swing JButton setBorderPainted

List of usage examples for javax.swing JButton setBorderPainted

Introduction

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

Prototype

@BeanProperty(visualUpdate = true, description = "Whether the border should be painted.")
public void setBorderPainted(boolean b) 

Source Link

Document

Sets the borderPainted property.

Usage

From source file:Main.java

/***************************************************************************
 * Creates a {@link JButton} with settings that are common for toolbars.
 * // w  ww  .  j  a v a2 s  .c  o  m
 * @param tooltip
 * @param icon
 * @return
 **************************************************************************/
public static JButton createToolbarButton(String tooltip, Icon icon) {
    JButton button = new JButton("", icon);
    button.setFocusable(false);
    button.setBorderPainted(false);
    button.setToolTipText(tooltip);
    return button;
}

From source file:BooksDemo.java

public static JButton createButton(String text) {
    JButton button = new JButton(text);
    button.setFocusPainted(true);/*from   ww  w .  j  a v a2  s  .  c  om*/
    button.setBorderPainted(true);
    button.setContentAreaFilled(true);
    return button;
}

From source file:BooksDemo.java

public static JButton createButton(String text, String icon, boolean flat) {
    ImageIcon iconNormal = readImageIcon(icon + ".png");
    ImageIcon iconHighlight = readImageIcon(icon + "_highlight.png");
    ImageIcon iconPressed = readImageIcon(icon + "_pressed.png");

    JButton button = new JButton(text, iconNormal);
    button.setFocusPainted(!flat);/*from  www.  ja v  a  2 s.c  om*/
    button.setBorderPainted(!flat);
    button.setContentAreaFilled(!flat);
    if (iconHighlight != null) {
        button.setRolloverEnabled(true);
        button.setRolloverIcon(iconHighlight);
    }
    if (iconPressed != null)
        button.setPressedIcon(iconPressed);
    return button;
}

From source file:Main.java

/**
 * Configures a button as if it was an hyperlink.
 * /*from   www  .j  a v  a  2  s. co m*/
 * @param button
 *            the button to configure.
 */
public static void configureButtonAsHyperlink(JButton button) {
    if (button == null) {
        return;
    }

    StringBuffer html = new StringBuffer();
    html.append("<html><font color=\"blue\"><u>");
    html.append(button.getText());
    html.append("</u></font></html>");

    button.setText(html.toString());
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    button.setFocusPainted(false);
    button.setBorderPainted(false);
    button.setContentAreaFilled(false);
}

From source file:net.sf.texprinter.utils.UIUtils.java

/**
 * Formats a button to a label with wider margins. In short, this
 * method is similar to the button/label one, but with wider margins.
 *
 * @param button The button. Nothing new here.
 *//*from   www . jav  a2  s . co  m*/
public static void formatButtonAsList(JButton button) {

    // disable focus paint
    button.setFocusPainted(false);

    // fix the margins
    button.setMargin(new Insets(0, 0, 0, 5));

    // disable content area fill
    button.setContentAreaFilled(false);

    // disable border paint
    button.setBorderPainted(false);

    // disable property
    button.setOpaque(false);
}

From source file:net.sf.texprinter.utils.UIUtils.java

/**
 * Formats a JButton as a JLabel. In some cases, I just want the a
 * JButton component to act as a JLabel, so this method does this
 * for me.//from  www  .j av  a  2  s.  co m
 *
 * @param button The button. Some makeup is made to the button, so
 * it will look as a good old JLabel component.
 */
public static void formatButtonAsLabel(JButton button) {

    // disable focus paint
    button.setFocusPainted(false);

    // redefine margins
    button.setMargin(new Insets(0, 0, 0, 0));

    // disable content area fill
    button.setContentAreaFilled(false);

    // disable border paint
    button.setBorderPainted(false);

    // disable property
    button.setOpaque(false);
}

From source file:es.emergya.ui.plugins.JButtonCellEditor.java

@Override
public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected,
        final int row, final int column) {
    JButton b = (JButton) value;
    b.setBorderPainted(false);
    b.setContentAreaFilled(false);//from w w w  . j av a  2  s.c  o m
    b.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() {
                @Override
                protected Object doInBackground() throws Exception {
                    stopCellEditing();
                    return null;
                }
            };
            SwingUtilities.invokeLater(sw);

            SwingWorker<Object, Object> sw1 = new SwingWorker<Object, Object>() {
                @Override
                protected Object doInBackground() throws Exception {
                    table.repaint();
                    return null;
                }
            };
            SwingUtilities.invokeLater(sw1);
        }
    });
    return b;
}

From source file:ButtonScroll.java

protected JButton createButton(String name, char mnemonics) {
    JButton btn = new JButton(name);
    btn.setToolTipText("Move " + name);
    btn.setBorderPainted(false);
    btn.setMargin(new Insets(0, 0, 0, 0));
    btn.setContentAreaFilled(false);/*from   w  w  w  .  j  a  v a  2 s.  c o  m*/
    btn.setMnemonic(mnemonics);
    return btn;
}

From source file:net.nosleep.superanalyzer.panels.HomePanel.java

public JPanel createRightButtonBarPanel(final PieRotator rotator) {
    URL url = this.getClass().getResource("/media/" + "ButtonPlay.png");
    final ImageIcon playIcon = new ImageIcon(Toolkit.getDefaultToolkit().getImage(url));
    url = this.getClass().getResource("/media/" + "ButtonPause.png");
    final ImageIcon pauseIcon = new ImageIcon(Toolkit.getDefaultToolkit().getImage(url));
    final JButton button = new JButton(playIcon);
    button.setBorder(null);/* w  w  w .jav a 2s .c  om*/
    button.setBorderPainted(false);
    button.setText(null);
    button.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            if (rotator.isRunning() == false) {
                rotator.start();
                button.setIcon(pauseIcon);
            } else {
                rotator.stop();
                button.setIcon(playIcon);
            }
        }
    });

    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);
    toolBar.setBackground(Color.white);
    toolBar.add(button);

    JPanel barPanel = new JPanel(new BorderLayout());
    barPanel.setBackground(Color.white);
    barPanel.add(toolBar, BorderLayout.SOUTH);

    return barPanel;
}

From source file:cool.pandora.modeller.ui.BagTableFormBuilder.java

/**
 * addBinding.// ww w. ja  va2s . co  m
 *
 * @param isRequired   boolean
 * @param labelName    String
 * @param component    JComponent
 * @param removeButton JComponent
 * @return JComponent
 */
private JComponent[] addBinding(final boolean isRequired, final String labelName, final JComponent component,
        final JComponent removeButton) {
    removeButton.setFocusable(false);
    final JLabel label = new JLabel(labelName); // createLabelFor(fieldName,
    // component);
    label.setToolTipText("Double-Click to Edit");
    final TableLayoutBuilder layoutBuilder = getLayoutBuilder();
    if (!layoutBuilder.hasGapToLeft()) {
        layoutBuilder.gapCol();
    }
    layoutBuilder.cell(label, "colSpec=left:pref:noGrow");
    final JComponent reqComp;
    /* */
    if (isRequired) {
        final JButton b = new JButton("R");
        b.setForeground(Color.red);
        b.setOpaque(false);
        b.setBorderPainted(false);
        reqComp = b;
    } else {
        final JButton b = new JButton("");
        b.setOpaque(false);
        b.setBorderPainted(false);
        reqComp = b;
    }
    /* */
    reqComp.setFocusable(false);
    layoutBuilder.cell(reqComp, "colSpec=left:pref:noGrow");
    layoutBuilder.cell(component, "colSpec=fill:pref:grow");
    layoutBuilder.labelGapCol();
    layoutBuilder.cell(removeButton, "colSpec=left:pref:noGrow");
    layoutBuilder.labelGapCol();
    return new JComponent[] { label, reqComp, component, removeButton };
}