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

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

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

JButton.getInsets介绍

暂无

代码示例

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

  1. JFrame frame2 = new JFrame("Tauler Joc");
  2. JPanel panell = new JPanel();
  3. ImageIcon icon = new ImageIcon("king.jpg");
  4. JButton jb= new JButton();
  5. jb.setBounds(200,200,700,700);
  6. panell.add(jb);
  7. // Set image to size of JButton...
  8. int offset = jb.getInsets().left;
  9. jb.setIcon(resizeIcon(icon, jb.getWidth() - offset, jb.getHeight() - offset));
  10. frame2.add(panell);
  11. frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

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

  1. protected Rectangle rectangleForCurrentValue() {
  2. int width = comboBox.getWidth();
  3. int height = comboBox.getHeight();
  4. Insets insets = getInsets();
  5. int buttonSize = height - (insets.top + insets.bottom);
  6. if (arrowButton != null) {
  7. if (arrowButton instanceof PgsComboBoxButtonUI) {
  8. Icon icon = ((PgsComboBoxButtonUI) arrowButton).getComboIcon();
  9. Insets buttonInsets = arrowButton.getInsets();
  10. buttonSize = icon.getIconWidth() + buttonInsets.left +
  11. buttonInsets.right;
  12. } else {
  13. buttonSize = arrowButton.getWidth();
  14. }
  15. }
  16. if(PgsUtils.isLeftToRight(comboBox)) {
  17. return new Rectangle(insets.left+2, insets.top+1,
  18. width - (insets.left + insets.right + buttonSize + 4),
  19. height - (insets.top + insets.bottom)-2);
  20. } else {
  21. return new Rectangle(insets.left + buttonSize + 2, insets.top+1,
  22. width - (insets.left + insets.right + buttonSize + 4),
  23. height - (insets.top + insets.bottom)-2);
  24. }
  25. }

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

  1. @Override
  2. public void actionPerformed(ActionEvent e) {
  3. if (!comboBox.isEditable()) {
  4. flasherVisible = !flasherVisible;
  5. if (!flasherVisible) {
  6. Graphics g = arrowButton.getGraphics();
  7. if (g != null) {
  8. g.setColor(usingOcean ? UIManager.getColor("Button.focus") : arrowButton.getBackground());
  9. Insets insets = arrowButton.getInsets();
  10. int width = arrowButton.getWidth() - (insets.left + insets.right);
  11. int height = arrowButton.getHeight() - (insets.top + insets.bottom);
  12. if (height > 0 && width > 0) {
  13. int left = insets.left;
  14. int top = insets.top;
  15. g.drawRect( left - 1, top - 1, width + 3, height + 1 );
  16. }
  17. }
  18. }
  19. else {
  20. arrowButton.repaint();
  21. }
  22. }
  23. }
  24. }

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

  1. private void refreshUI() {
  2. if (notification.isClosed()) {
  3. closeActionListener.actionPerformed(null);
  4. }
  5. setVisible(!notification.isHidden());
  6. nameLabel.setText(notification.getName());
  7. // set the subtext color to red if the description contains the word "error"
  8. subTextLabel.setText(notification.getDescription());
  9. subTextLabel.setForeground(notification.getDescription().toLowerCase().contains("error") ? subTextErrorColor : subTextNormalColor);
  10. closeButton.setVisible(notification.canHide());
  11. ViewUtil.ellipsizeLabel(nameLabel, middleWidth - 2 * innerinsets);
  12. ViewUtil.ellipsizeLabel(subTextLabel, middleWidth - 2 * innerinsets);
  13. if (notification.isShowsProgress()) {
  14. progressIndifinite.setVisible(notification.isIndeterminateProgress());
  15. progress.setVisible(!notification.isIndeterminateProgress());
  16. progress.setValue((int) (notification.getProgress() * 100));
  17. } else {
  18. progressIndifinite.setVisible(false);
  19. progress.setVisible(false);
  20. }
  21. if (notification.getAction() != null) {
  22. actionButton.removeActionListener(notification.getAction());
  23. actionButton.addActionListener(notification.getAction());
  24. actionButton.setText(ViewUtil.ellipsize(notification.getActionName(), rightWidth - innerinsets - actionButton.getInsets().left - actionButton.getInsets().right));
  25. actionButton.setVisible(true);
  26. }
  27. this.updateUI();
  28. }

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

  1. public void layoutComboBox(Container parent, MetalComboBoxLayoutManager manager) {
  2. if (arrowButton != null) {
  3. if (arrowButton instanceof PgsComboBoxButtonUI) {
  4. Icon icon = ((PgsComboBoxButtonUI) arrowButton).getComboIcon();
  5. Insets buttonInsets = arrowButton.getInsets();
  6. Insets insets = comboBox.getInsets();
  7. int buttonWidth = icon.getIconWidth() + buttonInsets.left +
  8. buttonInsets.right;
  9. arrowButton.setBounds(
  10. PgsUtils.isLeftToRight(comboBox)
  11. ? (comboBox.getWidth() - insets.right - buttonWidth)
  12. : insets.left+2,
  13. insets.top + 2, buttonWidth - 2,
  14. comboBox.getHeight() - insets.top - insets.bottom - 4);
  15. } else {
  16. Insets insets = comboBox.getInsets();
  17. int width = comboBox.getWidth();
  18. int height = comboBox.getHeight();
  19. arrowButton.setBounds(
  20. insets.left, insets.top,
  21. width - (insets.left + insets.right),
  22. height - (insets.top + insets.bottom));
  23. }
  24. }
  25. if (editor != null) {
  26. Rectangle cvb = rectangleForCurrentValue();
  27. editor.setBounds(cvb);
  28. }
  29. }

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

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

相关文章

JButton类方法