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

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

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

JButton.getSize介绍

暂无

代码示例

代码示例来源:origin: com.synaptix/SynaptixSwing

public Dimension getSize() {
  if (!needsRotate) {
    return super.getSize();
  }
  Dimension size = super.getSize();
  switch (direction) {
  case VERTICAL_DOWN:
  case VERTICAL_UP:
    return new Dimension(size.height, size.width);
  default:
    return super.getSize();
  }
}

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

public class Button extends JApplet implements ActionListener {

  private JButton button;

  public void init() {
   Container container = getContentPane();
   container.setLayout(null);
   container.setBackground(Color.white);
   button = new JButton("Press Me");
   button.setSize(getWidth()/2,20);
   button.setLocation(getWidth()/2-button.getSize().width/2, getHeight()/2-button.getSize().height/2);
   container.add(button);
   button.addActionListener(this);
  }

  public void actionPerformed(ActionEvent e) {
   int width = (button.getSize().width == getWidth()/2) ? getWidth()/4 : getWidth()/2;
   int height = button.getSize().height;
   button.setSize(width,height);
   button.setLocation(getWidth()/2-width/2, getHeight()/2-height/2);
  }
}

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

new JCheckBox() {
     JButton button = new JButton();
     {
       button.setModel(getModel());
     }
     @Override
     protected void paintComponent(Graphics g) {
       if (!button.getSize().equals(getSize())) {
         button.setSize(getSize());
       }
       button.paint(g);
       super.paintComponent(g);
     }
     @Override
     public void setEnabled(boolean b) {
       super.setEnabled(b);
       button.setEnabled(b);
     }
   };

代码示例来源:origin: RPTools/maptool

public void actionPerformed(ActionEvent e) {
    ZoneSelectionPopup popup = new ZoneSelectionPopup();
    popup.show(button, button.getSize().width - popup.getPreferredSize().width, 0);
  }
});

代码示例来源:origin: matsim-org/matsim

ZoomEntry z = zooms.get(i);
JButton b = buttons.get(i);
ImageIcon icon = new ImageIcon(ImageUtil.createThumbnail(z.getSnap(),Math.min(z.getSnap().getWidth(),b.getSize().width)-20));
b.setIcon(icon);

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

m.show(bamViewButton, 0, (int) bamViewButton.getSize().getHeight());

代码示例来源:origin: MegaMek/megamek

chatPanel.add(butDone, gbc);
butDone.setSize(AbstractPhaseDisplay.DONE_BUTTON_WIDTH,butDone.getHeight());
butDone.setPreferredSize(butDone.getSize());
butDone.setMinimumSize(butDone.getSize());
chatPanel.setMinimumSize(chatPanel.getPreferredSize());

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

@Override
public void actionPerformed(ActionEvent e) {
  JPopupMenu m = new JPopupMenu();
  Set<AppCommHandler> handlers = AppCommRegistry.getInstance().getHandlersForEvent(PatientVariantAnalyzeComm.class);
  final PatientVariantAnalyzeComm event = new PatientVariantAnalyzeComm(null, patient.getID());
  for (final AppCommHandler handler : handlers) {
    JMenuItem item = new JMenuItem(handler.getHandlerName());
    ImageIcon icon = handler.getHandlerIcon();
    if (icon != null) {
      int iconSize = 22;
      Image img = ViewUtil.getScaledInstance(
          icon.getImage(),
          iconSize,
          iconSize,
          RenderingHints.VALUE_INTERPOLATION_BILINEAR,
          true);
      item.setIcon(new ImageIcon(img));
    }
    ActionListener l = new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        handler.handleCommEvent(event);
      }
    };
    item.addActionListener(l);
    m.add(item);
  }
  m.show(dnaIDButton, 0, (int) dnaIDButton.getSize().getHeight());
}

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

&& e.getID() == MouseEvent.MOUSE_RELEASED
  && e.getButton() == MouseEvent.BUTTON1) {
Dimension size = super.getSize();
if (size != null) {
  int x = e.getX();

代码示例来源:origin: AndreasFagschlunger/O2Xfs

private void applyXfsPosition(final WFSPINFDK pinFDK) {
  final String method = "applyXfsPosition(WFSPINFDK)";
  final VirtualKey key = PINKeyUtil.getVirtualKey(pinFDK.getFDK());
  final MenuButton menuButton = getMenuButton(key);
  if (menuButton == null) {
    if (LOG.isInfoEnabled()) {
      LOG.info(method, "Could not find MenuButton for VirtualKey: "
          + key);
    }
    return;
  }
  final Dimension frameSize = uiFrame.getSize();
  final JButton button = menuButton.getButton();
  final Dimension buttonSize = button.getSize();
  final int x = calcXPosition(buttonSize, pinFDK.getXPosition(),
      frameSize.width);
  final int y = calcYPosition(buttonSize, pinFDK.getYPosition(),
      frameSize.height);
  if (LOG.isDebugEnabled()) {
    LOG.debug(method, "x=" + x + ",y=" + y + ",menuButton="
        + menuButton);
  }
  button.setBounds(new Rectangle(x, y, buttonSize.width,
      buttonSize.height));
}

相关文章

JButton类方法