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

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

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

JButton.getInsets介绍

暂无

代码示例

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

JFrame frame2 = new JFrame("Tauler Joc");
JPanel panell = new JPanel();
ImageIcon icon = new ImageIcon("king.jpg");
JButton jb= new JButton();
jb.setBounds(200,200,700,700);
panell.add(jb);

// Set image to size of JButton...
int offset = jb.getInsets().left;
jb.setIcon(resizeIcon(icon, jb.getWidth() - offset, jb.getHeight() - offset));

frame2.add(panell);
frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

代码示例来源:origin: com.github.arnabk/pgslookandfeel

protected Rectangle rectangleForCurrentValue() {
  int width = comboBox.getWidth();
  int height = comboBox.getHeight();
  Insets insets = getInsets();
  int buttonSize = height - (insets.top + insets.bottom);
  if (arrowButton != null) {
    if (arrowButton instanceof PgsComboBoxButtonUI) {
      Icon icon = ((PgsComboBoxButtonUI) arrowButton).getComboIcon();
      Insets buttonInsets = arrowButton.getInsets();
      buttonSize = icon.getIconWidth() + buttonInsets.left +
          buttonInsets.right;
    } else {
      buttonSize = arrowButton.getWidth();
    }
  }
  if(PgsUtils.isLeftToRight(comboBox)) {
    return new Rectangle(insets.left+2, insets.top+1,
               width - (insets.left + insets.right + buttonSize + 4),
               height - (insets.top + insets.bottom)-2);
  } else {
    return new Rectangle(insets.left + buttonSize + 2, insets.top+1,
               width - (insets.left + insets.right + buttonSize + 4),
               height - (insets.top + insets.bottom)-2);
  }
}

代码示例来源:origin: org.tentackle/tentackle-swing

@Override
 public void actionPerformed(ActionEvent e)  {
  if (!comboBox.isEditable()) {
   flasherVisible = !flasherVisible;
   if (!flasherVisible)  {
    Graphics g = arrowButton.getGraphics();
    if (g != null)  {
     g.setColor(usingOcean ? UIManager.getColor("Button.focus") : arrowButton.getBackground());
     Insets insets = arrowButton.getInsets();
     int width = arrowButton.getWidth() - (insets.left + insets.right);
     int height = arrowButton.getHeight() - (insets.top + insets.bottom);
     if (height > 0 && width > 0) {
      int left = insets.left;
      int top = insets.top;
      g.drawRect( left - 1, top - 1, width + 3, height + 1 );
     }
    }
   }
   else  {
    arrowButton.repaint();
   }
  }
 }
}

代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-client

private void refreshUI() {
  if (notification.isClosed()) {
    closeActionListener.actionPerformed(null);
  }
  setVisible(!notification.isHidden());
  nameLabel.setText(notification.getName());
  // set the subtext color to red if the description contains the word "error"
  subTextLabel.setText(notification.getDescription());
  subTextLabel.setForeground(notification.getDescription().toLowerCase().contains("error") ? subTextErrorColor : subTextNormalColor);
  closeButton.setVisible(notification.canHide());
  ViewUtil.ellipsizeLabel(nameLabel, middleWidth - 2 * innerinsets);
  ViewUtil.ellipsizeLabel(subTextLabel, middleWidth - 2 * innerinsets);
  if (notification.isShowsProgress()) {
    progressIndifinite.setVisible(notification.isIndeterminateProgress());
    progress.setVisible(!notification.isIndeterminateProgress());
    progress.setValue((int) (notification.getProgress() * 100));
  } else {
    progressIndifinite.setVisible(false);
    progress.setVisible(false);
  }
  if (notification.getAction() != null) {
    actionButton.removeActionListener(notification.getAction());
    actionButton.addActionListener(notification.getAction());
    actionButton.setText(ViewUtil.ellipsize(notification.getActionName(), rightWidth - innerinsets - actionButton.getInsets().left - actionButton.getInsets().right));
    actionButton.setVisible(true);
  }
  this.updateUI();
}

代码示例来源:origin: com.github.arnabk/pgslookandfeel

public void layoutComboBox(Container parent, MetalComboBoxLayoutManager manager) {
  if (arrowButton != null) {
    if (arrowButton instanceof PgsComboBoxButtonUI) {
      Icon icon = ((PgsComboBoxButtonUI) arrowButton).getComboIcon();
      Insets buttonInsets = arrowButton.getInsets();
      Insets insets = comboBox.getInsets();
      int buttonWidth = icon.getIconWidth() + buttonInsets.left +
          buttonInsets.right;
      arrowButton.setBounds(
          PgsUtils.isLeftToRight(comboBox)
              ? (comboBox.getWidth() - insets.right - buttonWidth)
              : insets.left+2,
          insets.top + 2, buttonWidth - 2,
          comboBox.getHeight() - insets.top - insets.bottom - 4);
    } else {
      Insets insets = comboBox.getInsets();
      int width = comboBox.getWidth();
      int height = comboBox.getHeight();
      arrowButton.setBounds(
          insets.left, insets.top,
          width - (insets.left + insets.right),
          height - (insets.top + insets.bottom));
    }
  }
  if (editor != null) {
    Rectangle cvb = rectangleForCurrentValue();
    editor.setBounds(cvb);
  }
}

代码示例来源:origin: com.jidesoft/jide-oss

if (arrowButton instanceof BasicJideComboBoxButton) {
  Icon icon = ((BasicJideComboBoxButton) arrowButton).getComboIcon();
  Insets buttonInsets = arrowButton.getInsets();
  Insets insets = comboBox.getInsets();
  int buttonWidth = icon.getIconWidth() + buttonInsets.left +

相关文章

JButton类方法