javax.swing.JButton.setIconTextGap()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(197)

本文整理了Java中javax.swing.JButton.setIconTextGap()方法的一些代码示例,展示了JButton.setIconTextGap()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JButton.setIconTextGap()方法的具体详情如下:
包路径:javax.swing.JButton
类名称:JButton
方法名:setIconTextGap

JButton.setIconTextGap介绍

暂无

代码示例

代码示例来源:origin: org.cytoscape/vizmap-gui-impl

protected void setButtonColor(final Color newColor) {
  final int iconWidth = 20;
  final int iconHeight = 10;
  final BufferedImage bi = new BufferedImage(iconWidth, iconHeight, BufferedImage.TYPE_INT_RGB);
  final Graphics2D g2 = bi.createGraphics();
  g2.setColor(newColor);
  g2.fillRect(0, 0, iconWidth, iconHeight);
  Icon colorIcon = new ImageIcon(bi);
  colorButton.setIcon(colorIcon);
  colorButton.setIconTextGap(10);
}

代码示例来源:origin: cytoscape/application

protected void setButtonColor(Color newColor) {
  final int iconWidth = 10;
  final int iconHeight = 10;
  final BufferedImage bi = new BufferedImage(iconWidth, iconHeight, BufferedImage.TYPE_INT_RGB);
  final Graphics2D g2 = bi.createGraphics();
  /*
   * Fill background
   */
  g2.setColor(newColor);
  g2.fillRect(0, 0, iconWidth, iconHeight);
  Icon colorIcon = new ImageIcon(bi);
  colorButton.setIcon(colorIcon);
  colorButton.setIconTextGap(6);

}

代码示例来源:origin: com.eas.platypus/platypus-js-forms

@ScriptFunction
@Override
public void setIconTextGap(int aValue) {
  super.setIconTextGap(aValue);
}

代码示例来源:origin: locationtech/jts

public static JButton createButton(String title, ImageIcon icon, String tip, ActionListener action, boolean isFocusable ) {
 JButton btn = new JButton();
 if (title != null) btn.setText(title);
 if (tip != null) btn.setToolTipText(tip);
 if (icon != null) {
  btn.setIcon(icon);
  btn.setIconTextGap(2);
 }
 btn.setMargin(new Insets(0, 2, 0, 2));
 if (action != null) btn.addActionListener(action);
 if (! isFocusable) {
  btn.setFocusable(false);
  btn.setFocusPainted(false);
 }
 return btn;
}

代码示例来源:origin: org.rwshop/org.rwshop.swing.common

myStopButton.setIconTextGap(0);
myStopButton.addActionListener(new java.awt.event.ActionListener() {
  public void actionPerformed(java.awt.event.ActionEvent evt) {

代码示例来源:origin: digital-preservation/droid

jButtonShowValues.setIconTextGap(0);
jButtonShowValues.setInheritsPopupMenu(true);
jButtonShowValues.setPreferredSize(new java.awt.Dimension(259, 32));

代码示例来源:origin: uk.gov.nationalarchives/droid-ui

jButtonShowValues.setIconTextGap(0);
jButtonShowValues.setInheritsPopupMenu(true);
jButtonShowValues.setPreferredSize(new java.awt.Dimension(259, 32));

代码示例来源:origin: org.gephi/appearance-plugin-ui

colorSwatchButton.setFocusable(false);
colorSwatchButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
colorSwatchButton.setIconTextGap(0);
colorSwatchButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
colorSwatchButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

代码示例来源:origin: ontop/ontop

cmdExportResult.setContentAreaFilled(false);
cmdExportResult.setFocusable(false);
cmdExportResult.setIconTextGap(5);
cmdExportResult.setMaximumSize(new java.awt.Dimension(125, 25));
cmdExportResult.setMinimumSize(new java.awt.Dimension(125, 25));

代码示例来源:origin: com.eas.platypus/platypus-js-forms

@ScriptFunction(jsDoc = CONSTRUCTOR_JSDOC, params = {"text", "icon", "iconTextGap", "actionPerformed"})
public Button(String aText, Icon aIcon, int aIconTextGap, JSObject aActionPerformedHandler) {
  super(aText, aIcon);
  super.setIconTextGap(aIconTextGap);
  super.setHorizontalTextPosition(HorizontalPosition.RIGHT);
  setOnActionPerformed(aActionPerformedHandler);
}

代码示例来源:origin: org.japura/japura-gui

private void reajustTextGap() {
 FontMetrics fm = getFontMetrics(getFont());
 Dimension dim = null;
 if (isShowing()) {
  dim = getSize();
 } else {
  dim = getPreferredSize();
 }
 Insets insets = getInsets();
 int avaiableWidth =
   dim.width - insets.left - insets.right - imageWidth - separatorGap - 3
     - gap;
 int d = gap + 3 + separatorGap;
 int width = fm.stringWidth(getText());
 if (alignment == SwingConstants.LEFT) {
  super.setIconTextGap(avaiableWidth - width + d);
 } else if (alignment == SwingConstants.CENTER) {
  super.setIconTextGap((avaiableWidth / 2) - ((width) / 2) + d);
 } else if (alignment == SwingConstants.RIGHT) {
  super.setIconTextGap(gap + 3 + separatorGap);
 }
}

代码示例来源:origin: org.gephi/desktop-layout

runButton.setIconTextGap(5);
runButton.setMargin(new java.awt.Insets(2, 7, 2, 14));
runButton.addActionListener(new java.awt.event.ActionListener() {
presetsButton.setText(org.openide.util.NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.presetsButton.text")); // NOI18N
presetsButton.setFocusable(false);
presetsButton.setIconTextGap(0);
layoutToolbar.add(presetsButton);

代码示例来源:origin: GoldenGnu/jeveassets

jEsi.setActionCommand(AccountImportAction.ADD_ESI.name());
jEsi.addActionListener(listener);
jEsi.setIconTextGap(20);
jEsi.setFont(font);
jEsi.setHorizontalAlignment(JButton.LEADING);
jEveKit.setActionCommand(AccountImportAction.ADD_EVEKIT.name());
jEveKit.addActionListener(listener);
jEveKit.setIconTextGap(20);
jEveKit.setFont(font);
jEveKit.setHorizontalAlignment(JButton.LEADING);

代码示例来源:origin: ontop/ontop

cmdCreateNew.setBorder(BorderFactory.createEtchedBorder());
cmdCreateNew.setContentAreaFilled(false);
cmdCreateNew.setIconTextGap(5);
cmdCreateNew.setMaximumSize(new Dimension(95, 25));
cmdCreateNew.setMinimumSize(new Dimension(95, 25));
cmdCancel.setBorder(BorderFactory.createEtchedBorder());
cmdCancel.setContentAreaFilled(false);
cmdCancel.setIconTextGap(5);
cmdCancel.setMaximumSize(new Dimension(95, 25));
cmdCancel.setMinimumSize(new Dimension(95, 25));

代码示例来源:origin: ontop/ontop

cmdRemove.setBorder(javax.swing.BorderFactory.createEtchedBorder());
cmdRemove.setContentAreaFilled(false);
cmdRemove.setIconTextGap(5);
cmdRemove.setMaximumSize(new java.awt.Dimension(25, 25));
cmdRemove.setMinimumSize(new java.awt.Dimension(25, 25));
cmdAdd.setBorder(javax.swing.BorderFactory.createEtchedBorder());
cmdAdd.setContentAreaFilled(false);
cmdAdd.setIconTextGap(4);
cmdAdd.setMaximumSize(new java.awt.Dimension(25, 25));
cmdAdd.setMinimumSize(new java.awt.Dimension(25, 25));

代码示例来源:origin: kaikramer/keystore-explorer

jbWelcome.setIconTextGap(0);
jbWelcome.setBorderPainted(false);
jbWelcome.setBorder(null);

代码示例来源:origin: ontop/ontop

cmdAttachPrefix.setBorder(javax.swing.BorderFactory.createEtchedBorder());
cmdAttachPrefix.setContentAreaFilled(false);
cmdAttachPrefix.setIconTextGap(5);
cmdAttachPrefix.setMaximumSize(new java.awt.Dimension(112, 26));
cmdAttachPrefix.setMinimumSize(new java.awt.Dimension(112, 26));
cmdExecuteQuery.setBorder(javax.swing.BorderFactory.createEtchedBorder());
cmdExecuteQuery.setContentAreaFilled(false);
cmdExecuteQuery.setIconTextGap(5);
cmdExecuteQuery.setMaximumSize(new java.awt.Dimension(82, 26));
cmdExecuteQuery.setMinimumSize(new java.awt.Dimension(82, 26));
cmdSaveChanges.setBorder(javax.swing.BorderFactory.createEtchedBorder());
cmdSaveChanges.setContentAreaFilled(false);
cmdSaveChanges.setIconTextGap(5);
cmdSaveChanges.setMaximumSize(new java.awt.Dimension(112, 26));
cmdSaveChanges.setMinimumSize(new java.awt.Dimension(112, 26));

代码示例来源:origin: tulskiy/musique

nextRandomButton.setFocusable(false);
nextRandomButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
nextRandomButton.setIconTextGap(0);
nextRandomButton.setMargin(new java.awt.Insets(2, 3, 2, 3));
nextRandomButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

代码示例来源:origin: stackoverflow.com

jButton.setIconTextGap(nGap);

代码示例来源:origin: lbalazscs/Pixelitor

private void initDropDownButton() {
  dropDownButton = new JButton(downIconEnabled);
  dropDownButton.setDisabledIcon(downIconDisabled);
  dropDownButton.putClientProperty("JComponent.sizeVariant", "mini");
  dropDownButton.setRequestFocusEnabled(false);
  dropDownButton.setInheritsPopupMenu(true);
  dropDownButton.setBorderPainted(false);
  dropDownButton.setFocusPainted(false);
  dropDownButton.addMouseListener(new MouseAdapter() {
    @Override
    public void mousePressed(MouseEvent e) {
      dropDown();
    }
    @Override
    public void mouseEntered(MouseEvent e) {
      dropDownButton.setBorderPainted(true);
    }
    @Override
    public void mouseExited(MouseEvent e) {
      dropDownButton.setBorderPainted(false);
    }
  });
  dropDownButton.setIconTextGap(0);
  dropDownButton.setBorder(null);
  dropDownButton.setMargin(new Insets(0, 0, 0, 0));
  setDropDownButtonSize();
}

相关文章

JButton类方法