List of usage examples for javax.swing JButton setContentAreaFilled
@BeanProperty(visualUpdate = true, description = "Whether the button should paint the content area or leave it transparent.") public void setContentAreaFilled(boolean b)
contentAreaFilled
property. From source file:BooksDemo.java
public static JButton createButton(String text) { JButton button = new JButton(text); button.setFocusPainted(true);//w w w. ja v a 2s. com 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);//ww w . j a va 2 s.c o m 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: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.ja v a 2 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 w w w . j a va2 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:Main.java
/** * Configures a button as if it was an hyperlink. * /*from w ww . j av a2s . 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: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);/*from ww w . ja va2 s . c om*/ b.setContentAreaFilled(false); 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);/*from w w w. j a v a 2s . c o m*/ btn.setMargin(new Insets(0, 0, 0, 0)); btn.setContentAreaFilled(false); btn.setMnemonic(mnemonics); return btn; }
From source file:com.intel.stl.ui.common.view.ComponentFactory.java
public static JButton getImageButton(ImageIcon icon) { JButton res = new JButton(icon); res.setMargin(new Insets(0, 0, 0, 0)); res.setBorderPainted(false);/*w w w. ja va 2 s . c om*/ res.setContentAreaFilled(false); return res; }
From source file:edu.gmu.cs.sim.util.media.chart.SeriesAttributes.java
void buildManipulators() { JButton removeButton = new JButton(I_CLOSE); removeButton.setPressedIcon(I_CLOSE_PRESSED); removeButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));//4,4,4,4)); removeButton.setBorderPainted(false); removeButton.setContentAreaFilled(false); removeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (JOptionPane.showOptionDialog(null, "Remove the Series " + getSeriesName() + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new Object[] { "Remove", "Cancel" }, null) == 0) // remove {/*w w w.java2 s . c o m*/ getGenerator().removeSeries(getSeriesIndex()); } } }); removeButton.setToolTipText("Remove this series"); JButton upButton = new JButton(I_UP); upButton.setPressedIcon(I_UP_PRESSED); upButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));//4,4,4,4)); upButton.setBorderPainted(false); upButton.setContentAreaFilled(false); upButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { getGenerator().moveSeries(getSeriesIndex(), true); } }); upButton.setToolTipText("Draw this series higher in the series order"); JButton downButton = new JButton(I_DOWN); downButton.setPressedIcon(I_DOWN_PRESSED); downButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));//4,4,4,4)); downButton.setBorderPainted(false); downButton.setContentAreaFilled(false); downButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { getGenerator().moveSeries(getSeriesIndex(), false); } }); downButton.setToolTipText("Draw this series lower in the series order"); manipulators.add(removeButton); manipulators.add(upButton); manipulators.add(downButton); }
From source file:sim.util.media.chart.SeriesAttributes.java
void buildManipulators() { JButton removeButton = new JButton(I_CLOSE); removeButton.setPressedIcon(I_CLOSE_PRESSED); removeButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));//4,4,4,4)); removeButton.setBorderPainted(false); removeButton.setContentAreaFilled(false); removeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (JOptionPane.showOptionDialog(null, "Remove the Series " + getSeriesName() + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new Object[] { "Remove", "Cancel" }, null) == 0) // remove getGenerator().removeSeries(getSeriesIndex()); }//from ww w.j a v a 2 s .c o m }); removeButton.setToolTipText("Remove this series"); JButton upButton = new JButton(I_UP); upButton.setPressedIcon(I_UP_PRESSED); upButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));//4,4,4,4)); upButton.setBorderPainted(false); upButton.setContentAreaFilled(false); upButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { getGenerator().moveSeries(getSeriesIndex(), true); } }); upButton.setToolTipText("Draw this series higher in the series order"); JButton downButton = new JButton(I_DOWN); downButton.setPressedIcon(I_DOWN_PRESSED); downButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));//4,4,4,4)); downButton.setBorderPainted(false); downButton.setContentAreaFilled(false); downButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { getGenerator().moveSeries(getSeriesIndex(), false); } }); downButton.setToolTipText("Draw this series lower in the series order"); manipulators.add(removeButton); manipulators.add(upButton); manipulators.add(downButton); }