当前位置: 首页>>代码示例>>Java>>正文


Java JButton.setMargin方法代码示例

本文整理汇总了Java中javax.swing.JButton.setMargin方法的典型用法代码示例。如果您正苦于以下问题:Java JButton.setMargin方法的具体用法?Java JButton.setMargin怎么用?Java JButton.setMargin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JButton的用法示例。


在下文中一共展示了JButton.setMargin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
    }
}
 
开发者ID:ser316asu,项目名称:SER316-Ingolstadt,代码行数:21,代码来源:CharTablePanel.java

示例2: getContributeButton

import javax.swing.JButton; //导入方法依赖的package包/类
public JButton getContributeButton() {
	JButton contributeB = new JButton();
	contributeB.setLayout(new BorderLayout());
	JLabel label1 = new JLabel("Contribute");
	JLabel label2 = new JLabel("Data");
	label1.setFont(new Font("Arial", Font.BOLD, 11));
	contributeB.add(BorderLayout.CENTER,label1);
	label2.setFont(new Font("Arial", Font.BOLD, 11));
	label2.setHorizontalAlignment(SwingConstants.CENTER);
	contributeB.add(BorderLayout.SOUTH,label2);
	contributeB.setSize(new Dimension(115, 30));
	contributeB.setMargin(new Insets(0, 0, 0, 0));
	contributeB.setBackground(new Color( 224, 224, 224)); ;
	contributeB.setFont(new Font("Arial", Font.BOLD, 11));
	contributeB.setHorizontalAlignment(SwingConstants.LEFT);
	
	return contributeB;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:19,代码来源:MapTools.java

示例3: 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);
		}
	});

}
 
开发者ID:jonasxiao,项目名称:FinalSpeed,代码行数:25,代码来源:AddressCellRenderer.java

示例4: setOperator

import javax.swing.JButton; //导入方法依赖的package包/类
@Override
public void setOperator(final Operator operator) {
	button = new JButton(new ResourceAction(true, "enumeration") {

		private static final long serialVersionUID = 3163983383358779866L;

		@Override
		public void actionPerformed(ActionEvent e) {
			EnumerationPropertyDialog dialog = new EnumerationPropertyDialog(type, valuesList, operator);
			dialog.setVisible(true);
			if (dialog.isOk()) {
				fireEditingStopped();
				setButtonText();
			} else {
				fireEditingCanceled();
			}
		}
	});
	button.setMargin(new Insets(0, 0, 0, 0));
	// button.setToolTipText(type.getDescription());
	setButtonText();
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:23,代码来源:EnumerationValueCellEditor.java

示例5: getTableCellEditorComponent

import javax.swing.JButton; //导入方法依赖的package包/类
@Override
public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected, final int row, final int column) {
	final Component c = super.getTableCellEditorComponent(table, value, isSelected, row, column);
	final JButton button = new JButton("?");
	button.setMargin(new Insets(0, 0, 0, 0));
	button.setToolTipText(Column.WHO_IS.getLabel());
	button.setPreferredSize(new Dimension(Column.WHO_IS.getWidth(), c.getHeight()));
	if (Env.INSTANCE.getOs() == OS.win) {
		button.setBorder(null);
	}
	button.addActionListener(e -> {
		final AbstractPacketPoint point = _sniffer.getCapture().get(_table.convertRowIndexToModel(row));
		WhoIsPanel.showWhoIsDialog(PacketTablePanel.this, _services, point);
		if (table.isEditing()) {
			table.getCellEditor().stopCellEditing();
		}
		_whois.clear();
	});
	return button;
}
 
开发者ID:leolewis,项目名称:openvisualtraceroute,代码行数:21,代码来源:PacketTablePanel.java

示例6: getTableCellEditorComponent

import javax.swing.JButton; //导入方法依赖的package包/类
@Override
public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected, final int row, final int column) {
	final Component c = super.getTableCellEditorComponent(table, value, isSelected, row, column);
	final JButton button = new JButton("?");
	button.setMargin(new Insets(0, 0, 0, 0));
	button.setToolTipText(Column.WHO_IS.getLabel());
	button.setPreferredSize(new Dimension(Column.WHO_IS.getWidth(), c.getHeight()));
	button.setMaximumSize(button.getPreferredSize());
	if (Env.INSTANCE.getOs() == OS.win) {
		button.setBorder(null);
	}
	button.setEnabled(!_searching);
	button.addActionListener(e -> {
		final RoutePoint point = _route.getRoute().get(_table.convertRowIndexToModel(row));
		WhoIsPanel.showWhoIsDialog(RouteTablePanel.this, _services, point);
		if (table.isEditing()) {
			table.getCellEditor().stopCellEditing();
		}
		_whois.clear();
	});
	return button;
}
 
开发者ID:leolewis,项目名称:openvisualtraceroute,代码行数:23,代码来源:RouteTablePanel.java

示例7: createButton

import javax.swing.JButton; //导入方法依赖的package包/类
private JButton createButton(int icon) {
	JButton button = new JButton( Icons.getIcon(icon,false));
	button.setPressedIcon( Icons.getIcon(icon, true) );
	button.setDisabledIcon( Icons.getDisabledIcon( icon, false ));
	button.setBorder( BorderFactory.createLineBorder(Color.black));
	button.setMargin(new Insets(1,0,1,0));
	return button;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:9,代码来源:LayerManager.java

示例8: createButton

import javax.swing.JButton; //导入方法依赖的package包/类
private static JButton createButton(String iconPath, String tooltip) {
    Icon icon = ImageUtilities.loadImageIcon(iconPath, false);
    final JButton button = new JButton(icon);
    // ensure small size, just for the icon
    Dimension size = new Dimension(icon.getIconWidth() + 8, icon.getIconHeight() + 8);
    button.setPreferredSize(size);
    button.setMargin(new Insets(1, 1, 1, 1));
    button.setBorder(new EmptyBorder(button.getBorder().getBorderInsets(button)));
    button.setToolTipText(tooltip);
    button.setFocusable(false);
    return button;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:TerminalSettingsAction.java

示例9: 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;
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:42,代码来源:NegotiationDialog.java

示例10: createButton

import javax.swing.JButton; //导入方法依赖的package包/类
public static JButton createButton (Icon icon, String tooltip) {
    final JButton button = new JButton(icon);
    // ensure small size, just for the icon
    Dimension size = new Dimension(icon.getIconWidth() + 8, icon.getIconHeight() + 8);
    button.setPreferredSize(size);
    button.setMargin(new Insets(1, 1, 1, 1));
    button.setBorder(new EmptyBorder(button.getBorder().getBorderInsets(button)));
    button.setToolTipText(tooltip);
    button.setFocusable(false);
    return button;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:VariablesViewButtons.java

示例11: createFileChooserButton

import javax.swing.JButton; //导入方法依赖的package包/类
protected JButton createFileChooserButton() {
	JButton button = new JButton(new ResourceAction(true, "choose_file") {

		private static final long serialVersionUID = 1L;

		@Override
		public void actionPerformed(ActionEvent e) {
			buttonPressed();
		}
	});
	button.setMargin(new Insets(0, 0, 0, 0));
	return button;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:14,代码来源:FileValueCellEditor.java

示例12: 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;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:21,代码来源:Utility.java

示例13: createButton

import javax.swing.JButton; //导入方法依赖的package包/类
private JButton createButton(String name, ActionListener listener) {
    JButton button = new JButton(name);
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setOpaque(false);
    button.setHorizontalAlignment(SwingConstants.LEADING);
    button.setForeground(Utility.LINK_COLOR);
    button.setBorder(Utility.LEFTCELLBORDER);
    button.addActionListener(listener);
    return button;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:11,代码来源:CompactLabourReport.java

示例14: createButton

import javax.swing.JButton; //导入方法依赖的package包/类
JButton createButton(String name){
	JButton button=new JButton(name);
	button.setMargin(new Insets(0,5,0,5));
	button.setFocusPainted(false);
	return button;
}
 
开发者ID:jonasxiao,项目名称:FinalSpeed,代码行数:7,代码来源:ClientNoUI.java

示例15: initGuiComponents

import javax.swing.JButton; //导入方法依赖的package包/类
protected void initGuiComponents() {
  getContentPane().setLayout(
      new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
  getContentPane().add(Box.createVerticalStrut(5));
  Box hBox = Box.createHorizontalBox();
  hBox.add(Box.createHorizontalStrut(6));
  hBox.add(new JLabel("Find:"));
  hBox.add(Box.createHorizontalStrut(6));
  hBox.add(patternTextField = new JTextField(20));
  hBox.add(Box.createHorizontalStrut(3));
  JButton helpRegExpButton = new JButton("?");
  helpRegExpButton.setMargin(new Insets(0, 2, 0, 2));
  helpRegExpButton.setToolTipText("GATE search expression builder.");
  hBox.add(helpRegExpButton);
  hBox.add(Box.createHorizontalGlue());
  hBox.add(Box.createHorizontalStrut(6));
  hBox.add(Box.createHorizontalGlue());
  getContentPane().add(hBox);
  getContentPane().add(Box.createVerticalStrut(5));
  hBox = Box.createHorizontalBox();
  hBox.add(Box.createHorizontalStrut(6));
  hBox.add(ignoreCaseChk = new JCheckBox("Ignore case", true));
  hBox.add(Box.createHorizontalStrut(6));
  hBox.add(wholeWordsChk = new JCheckBox("Whole word", false));
  hBox.add(Box.createHorizontalStrut(6));
  hBox.add(regularExpressionChk = new JCheckBox("Regular Exp.", false));
  regularExpressionChk.setToolTipText("Regular expression search.");
  hBox.add(Box.createHorizontalStrut(6));
  hBox.add(highlightsChk = new JCheckBox("Highlights", false));
  highlightsChk
      .setToolTipText("Restrict the search on the highlighted annotations.");
  hBox.add(Box.createHorizontalStrut(6));
  hBox.add(Box.createHorizontalGlue());
  getContentPane().add(hBox);
  getContentPane().add(Box.createVerticalStrut(5));
  hBox = Box.createHorizontalBox();
  hBox.add(Box.createHorizontalGlue());
  JButton findFirstButton = new JButton(findFirstAction);
  hBox.add(findFirstButton);
  hBox.add(Box.createHorizontalStrut(6));
  hBox.add(new JButton(findNextAction));
  hBox.add(Box.createHorizontalStrut(6));
  hBox.add(new JButton(cancelAction));
  hBox.add(Box.createHorizontalGlue());
  getContentPane().add(hBox);
  getContentPane().add(Box.createVerticalStrut(5));
  getRootPane().setDefaultButton(findFirstButton);
  helpRegExpButton.addActionListener(new SearchExpressionsAction(
      patternTextField, this, regularExpressionChk));
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:51,代码来源:DocumentEditor.java


注:本文中的javax.swing.JButton.setMargin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。