本文整理汇总了Java中javax.swing.JButton.setOpaque方法的典型用法代码示例。如果您正苦于以下问题:Java JButton.setOpaque方法的具体用法?Java JButton.setOpaque怎么用?Java JButton.setOpaque使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JButton
的用法示例。
在下文中一共展示了JButton.setOpaque方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDecreaseButton
import javax.swing.JButton; //导入方法依赖的package包/类
protected JButton createDecreaseButton(int orientation) {
JButton btn = new XDMButton();
btn.setHorizontalAlignment(JButton.CENTER);
btn.setPreferredSize(new Dimension(15, 15));
btn.setContentAreaFilled(false);
btn.setBorderPainted(false);
btn.setOpaque(false);
if (orientation == SwingConstants.NORTH) {
btn.setIcon(XDMIconMap.getIcon("UP_ARROW"));
}
if (orientation == SwingConstants.SOUTH) {
btn.setIcon(XDMIconMap.getIcon("DOWN_ARROW"));
}
if (orientation == SwingConstants.EAST) {
btn.setIcon(XDMIconMap.getIcon("LEFT_ARROW"));
}
if (orientation == SwingConstants.WEST) {
btn.setIcon(XDMIconMap.getIcon("RIGHT_ARROW"));
}
return btn;
}
示例2: createButtons
import javax.swing.JButton; //导入方法依赖的package包/类
void createButtons() {
for (int i = 0; i < chars.length; i++) {
JButton button = new JButton(new CharAction(chars[i]));
button.setMaximumSize(new Dimension(50, 22));
//button.setMinimumSize(new Dimension(22, 22));
button.setPreferredSize(new Dimension(30, 22));
button.setRequestFocusEnabled(false);
button.setFocusable(false);
button.setBorderPainted(false);
button.setOpaque(false);
button.setMargin(new Insets(0,0,0,0));
button.setFont(new Font("serif", 0, 14));
if (i == chars.length-1) {
button.setText("nbsp");
button.setFont(new Font("Dialog",0,10));
button.setMargin(new Insets(0,0,0,0));
}
this.add(button, null);
}
}
示例3: getToolbarPresenter
import javax.swing.JButton; //导入方法依赖的package包/类
public static Component getToolbarPresenter(Action action) {
JButton button = new JButton(action);
button.setBorderPainted(false);
button.setOpaque(false);
button.setText(null);
button.putClientProperty("hideActionText", Boolean.TRUE); // NOI18N
Object icon = action.getValue(Action.SMALL_ICON);
if (icon == null) {
icon = ImageUtilities.loadImageIcon("org/netbeans/modules/dlight/terminal/action/local_term.png", false);// NOI18N
}
if (!(icon instanceof Icon)) {
throw new IllegalStateException("No icon provided for " + action); // NOI18N
}
button.setDisabledIcon(ImageUtilities.createDisabledIcon((Icon) icon));
return button;
}
示例4: init
import javax.swing.JButton; //导入方法依赖的package包/类
void init(){
panel=new JPanel();
panel.setLayout(new MigLayout("insets 0 5 0 0","[grow,fill]rel[right]", "[]0[]"));
panel.setOpaque(true);
panel.setBackground(color_normal);
addressLabel=new JLabel("");
panel.add(addressLabel,"");
addressLabel.setOpaque(false);
button_remove=new JButton("x");
//panel.add(button_remove,"align right");
button_remove.setOpaque(false);
button_remove.setContentAreaFilled(false);
button_remove.setBorderPainted(false);
button_remove.setMargin(new Insets(0, 10, 0, 10));
button_remove.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println(e);
}
});
}
示例5: addActions
import javax.swing.JButton; //导入方法依赖的package包/类
private void addActions(JToolBar tb, Action[] actions) {
tb.removeAll();
boolean visible = false;
if (actions != null) {
for (Action a : actions) {
if (a != null) {
JButton btn = tb.add(a);
btn.setBorder(new javax.swing.border.EmptyBorder(0, 2, 0, 2));
btn.setBorderPainted(false);
btn.setContentAreaFilled(false);
btn.setRolloverEnabled(false);
btn.setOpaque(false);
btn.setFocusable(false);
visible = true;
} else {
tb.add(new JSeparator(JSeparator.VERTICAL));
}
}
}
tb.setVisible(visible);
}
示例6: createDetails
import javax.swing.JButton; //导入方法依赖的package包/类
private JComponent createDetails( String text, ActionListener action ) {
if( null == action ) {
return new JLabel(text);
}
try {
text = "<html><u>" + XMLUtil.toElementContent(text); //NOI18N
} catch( CharConversionException ex ) {
throw new IllegalArgumentException(ex);
}
JButton btn = new JButton(text);
btn.setFocusable(false);
btn.setBorder(BorderFactory.createEmptyBorder());
btn.setBorderPainted(false);
btn.setFocusPainted(false);
btn.setOpaque(false);
btn.setContentAreaFilled(false);
btn.addActionListener(action);
btn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
Color c = UIManager.getColor("nb.html.link.foreground"); //NOI18N
if (c != null) {
btn.setForeground(c);
}
return btn;
}
示例7: SyncChangesBar
import javax.swing.JButton; //导入方法依赖的package包/类
public SyncChangesBar(FileListPanel fileList, Backend backend)
{
this.backend = backend;
label = new JLabel(" "); //$NON-NLS-1$
label.setFont(label.getFont().deriveFont(Font.BOLD));
JButton button = new JButton(new SynchroniseChangesAction(backend, fileList));
button.setOpaque(false);
setOpaque(true);
setBackground(Color.RED);
label.setForeground(Color.WHITE);
setLayout(new BorderLayout());
add(label, BorderLayout.CENTER);
add(button, BorderLayout.EAST);
refresh();
}
示例8: getTradeItemButton
import javax.swing.JButton; //导入方法依赖的package包/类
/**
* Gets a trade item button for a given item.
*
* @param item The {@code TradeItem} to make a button for.
* @param saleDir Boolean to indicate the EU price for sale (T) or buy (F)
* @return A new {@code JButton} for the item.
*/
private JButton getTradeItemButton(TradeItem item, boolean saleDir) {
Market market = getMyPlayer().getMarket();
JButton button = new JButton(new RemoveAction(item));
// Checks if the items are goods
if (item.getGoods() != null) {
int buyPriceTotal = market.getBidPrice(item.getGoods().getType(), item.getGoods().getAmount());
int salePriceTotal = market.getSalePrice(item.getGoods().getType(), item.getGoods().getAmount());
// Depending on saleDir, creates a button for goods w/ EU buy or sale price
if (saleDir) {
button.setText(Messages.message(item.getLabel()) + " " +
Messages.message(StringTemplate
.template("negotiationDialog.euSalePrice")
.addAmount("%priceTotal%", salePriceTotal)));
} else {
button.setText(Messages.message(item.getLabel()) + " " +
Messages.message(StringTemplate
.template("negotiationDialog.euBuyPrice")
.addAmount("%priceTotal%", buyPriceTotal)));
}
} else {
// If not goods, follow protocol
button.setText(Messages.message(item.getLabel()));
}
button.setMargin(Utility.EMPTY_MARGIN);
button.setOpaque(false);
button.setForeground(Utility.LINK_COLOR);
button.setBorder(Utility.blankBorder(0, 0, 0, 0));
button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
return button;
}
示例9: buildErrorLabel
import javax.swing.JButton; //导入方法依赖的package包/类
private JComponent buildErrorLabel() {
Component header = getContentHeader();
JPanel panel = new JPanel(new GridBagLayout());
panel.setOpaque( false );
int row = 0;
if( null != header ) {
panel.add( header, new GridBagConstraints(0,row++,1,1,1.0,0.0,
GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0 ) );
}
panel.add( new JLabel(BundleSupport.getLabel("ErrLoadingFeed")), // NOI18N
new GridBagConstraints(0,row++,1,1,0.0,0.0,
GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(5,10,10,5),0,0 ) );
JButton button = new JButton();
Mnemonics.setLocalizedText( button, BundleSupport.getLabel( "Reload" ) ); // NOI18N
button.setOpaque( false );
button.addActionListener( new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
lastReload = 0;
reload();
}
});
panel.add( button, new GridBagConstraints(0,row++,1,1,0.0,0.0,
GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(5,10,10,5),0,0 ) );
return panel;
}
示例10: createButton
import javax.swing.JButton; //导入方法依赖的package包/类
static JButton createButton(String text, String imageName, String actionCommand) {
final JButton button = new JButton();
button.setOpaque(false);
button.setHorizontalAlignment(SwingConstants.LEADING);
if (text != null) {
button.setText(text);
}
if (imageName != null) {
button.setIcon(DcdUiHelper.createIcon(imageName));
}
if (actionCommand != null) {
button.setActionCommand(actionCommand);
}
return button;
}
示例11: stylizeButton
import javax.swing.JButton; //导入方法依赖的package包/类
public void stylizeButton(JButton b){
Border thickBorder = new LineBorder(Color.WHITE, 3);
b.setFont(new Font("Arial", Font.BOLD, 18));
b.setBorder(thickBorder);
b.setContentAreaFilled(false);
b.setOpaque(true);
b.setBackground(Color.BLACK);
b.setForeground(Color.WHITE);
}
示例12: stylizeButton
import javax.swing.JButton; //导入方法依赖的package包/类
public void stylizeButton(JButton b){
Border thickBorder = new LineBorder(Color.WHITE, 3);
b.setBorder(thickBorder);
b.setContentAreaFilled(false);
b.setOpaque(true);
b.setBackground(Color.BLACK);
b.setForeground(Color.WHITE);
}
示例13: getLinkButton
import javax.swing.JButton; //导入方法依赖的package包/类
/**
* Return a button suitable for linking to another panel
* (e.g. ColopediaPanel).
*
* @param text a {@code String} value
* @param icon an {@code Icon} value
* @param action a {@code String} value
* @return a {@code JButton} value
*/
public static JButton getLinkButton(String text, Icon icon, String action) {
JButton button = new JButton(text, icon);
button.setMargin(EMPTY_MARGIN);
button.setOpaque(false);
button.setForeground(LINK_COLOR);
button.setAlignmentY(0.8f);
button.setBorder(blankBorder(0, 0, 0, 0));
button.setActionCommand(action);
button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
return button;
}
示例14: addImpl
import javax.swing.JButton; //导入方法依赖的package包/类
@Override
protected void addImpl( Component comp, Object constraints, int index ) {
super.addImpl( comp, constraints, index );
if( comp instanceof JButton ) {
JButton btn = (JButton) comp;
btn.setContentAreaFilled( false );
btn.setOpaque( false );
btn.setBorder( BorderFactory.createEmptyBorder(2,2,2,2) );
btn.setFocusable( false );
btn.setBorderPainted( false );
btn.setRolloverEnabled( false );
}
}
示例15: stylizeButton
import javax.swing.JButton; //导入方法依赖的package包/类
public void stylizeButton(JButton b){
Border thickBorder = new LineBorder(Color.WHITE, 3);
b.setBorder(thickBorder);
b.setContentAreaFilled(false);
b.setOpaque(true);
b.setBackground(Color.BLACK);
b.setForeground(Color.WHITE);
}