List of usage examples for javax.swing JButton setFocusPainted
@BeanProperty(visualUpdate = true, description = "Whether focus should be painted") public void setFocusPainted(boolean b)
paintFocus
property, which must be true
for the focus state to be painted. From source file:Main.java
/** * @param label//from ww w . j a v a 2 s. c o m * @param icon * @return createb JButton used in toolbar */ public static JButton createToolbarButton(String label, Icon icon) { JButton button = new JButton(icon); button.setFocusPainted(false); button.setMargin(new Insets(0, 0, 0, 0)); button.setToolTipText(label); button.setActionCommand(label); return button; }
From source file:Main.java
/** * @param label//from w w w.ja v a2s . c om * @param iconFileName * @return createb JButton used in toolbar */ public static JButton createToolbarButton(String label, String iconFileName) { JButton button = new JButton(new ImageIcon(iconFileName)); button.setFocusPainted(false); button.setMargin(new Insets(0, 0, 0, 0)); button.setToolTipText(label); button.setActionCommand(label); return button; }
From source file:BooksDemo.java
public static JButton createButton(String text) { JButton button = new JButton(text); button.setFocusPainted(true); button.setBorderPainted(true);/*from ww w . ja v a 2 s .c o m*/ button.setContentAreaFilled(true); return button; }
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.//w w w .j av a 2 s . c o 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: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 w w w .j ava 2 s . c o 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: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); button.setBorderPainted(!flat);/*from www. ja v a 2 s.c o m*/ 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 w w w. j a v a 2s. 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:PngIcon.java
public PngIcon() { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton bt = new JButton(new ImageIcon("dtmail.png")); JLabel lab = new JLabel(new ImageIcon("dtterm.png")); bt.setFocusPainted(false); frame.add(bt, BorderLayout.NORTH); frame.add(lab, BorderLayout.SOUTH); frame.setBounds(50, 50, 200, 200);//www .j a v a 2s . c om frame.setVisible(true); }
From source file:TwoStopsGradient.java
/** Creates a new instance of TwoStopsGradient */ public TwoStopsGradient() { super("Two Stops Gradient"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new GridBagLayout()); JButton button; panel.add(button = new DepthButton("New"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 0, 0)); button.setFocusPainted(false); panel.add(button = new DepthButton("Open"), new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 0, 0)); button.setFocusPainted(false);//from w w w .j a v a2 s.c om panel.add(button = new DepthButton("Save"), new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 0, 0)); button.setFocusPainted(false); add(panel); setSize(320, 240); }
From source file:DateChooserPanel.java
/** * Returns a panel of buttons, each button representing a day in the month. * This is a sub-component of the DatePanel. * * @return the panel./* w w w .j ava 2 s .com*/ */ private JPanel getCalendarPanel() { final JPanel p = new JPanel(new GridLayout(7, 7)); final DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(); final String[] weekDays = dateFormatSymbols.getShortWeekdays(); for (int i = 0; i < this.WEEK_DAYS.length; i++) { p.add(new JLabel(weekDays[this.WEEK_DAYS[i]], SwingConstants.CENTER)); } this.buttons = new JButton[42]; for (int i = 0; i < 42; i++) { final JButton b = new JButton(""); b.setMargin(new Insets(1, 1, 1, 1)); b.setName(Integer.toString(i)); b.setFont(this.dateFont); b.setFocusPainted(false); b.setActionCommand("dateButtonClicked"); b.addActionListener(this); this.buttons[i] = b; p.add(b); } return p; }