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

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

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

JButton.getWidth介绍

暂无

代码示例

代码示例来源:origin: kiegroup/optaplanner

unassignedIndex++;
if (x + taskButton.getWidth() > panelWidth) {
  panelWidth = x + taskButton.getWidth();

代码示例来源:origin: org.netbeans.api/org-openide-awt

private void displayOverflow() {
  int x = getOrientation() == HORIZONTAL ? overflowButton.getLocationOnScreen().x : overflowButton.getLocationOnScreen().x + overflowButton.getWidth();
  int y = getOrientation() == HORIZONTAL ? overflowButton.getLocationOnScreen().y + overflowButton.getHeight() : overflowButton.getLocationOnScreen().y;
  popup.setLocation(x, y);
  popup.setVisible(true);
}

代码示例来源:origin: Audiveris/audiveris

@Override
public void actionPerformed (ActionEvent e)
{
  Object source = e.getSource();
  if (source instanceof JButton) {
    JButton button = (JButton) source;
    popup.show(button, button.getWidth(), 20);
  }
}

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

@Override
  public void mousePressed(MouseEvent e) {
    JPopupMenu menu = new JPopupMenu();
    menu.add(new JMenuItem(addNewBoardAction));
    menu.add(new JMenuItem(addExistingBoardAction));
    menu.show(btnAddBoard, (int) btnAddBoard.getWidth(), (int) btnAddBoard.getHeight());
  }
});

代码示例来源:origin: org.netbeans.api/org-openide-awt

if (popup.isShowing() && overflowButton.isShowing() && (e.getID() == MouseEvent.MOUSE_MOVED || e.getID() == MouseEvent.MOUSE_EXITED)) {
  int minX = overflowButton.getLocationOnScreen().x;
  int maxX_ob = minX + overflowButton.getWidth();
  int maxX = getOrientation() == HORIZONTAL ? minX + popup.getWidth()
      : minX + overflowButton.getWidth() + popup.getWidth();
  int minY = overflowButton.getLocationOnScreen().y;
  int maxY_ob = minY + overflowButton.getHeight();

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

@ScriptFunction(jsDoc = WIDTH_JSDOC)
@Override
public int getWidth() {
  return super.getWidth();
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-notifications

void setArrowLocation( int arrowLocation) {
  this.arrowLocation = arrowLocation;
  if( arrowLocation == GridBagConstraints.NORTHEAST || arrowLocation == GridBagConstraints.NORTHWEST ) {
    setBorder( BorderFactory.createEmptyBorder(0, 0, Y_OFFSET, btnDismiss.getWidth()));
  } else {
    setBorder( BorderFactory.createEmptyBorder(Y_OFFSET, 0, 0, btnDismiss.getWidth()));
  }
}

代码示例来源:origin: xyz.cofe/gui.swing

@Override
  public void recive(ActionEvent obj) {
    confMenu.show(confButton, confButton.getWidth()/2, confButton.getHeight()/2);
  }
});

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

ImageIcon icon = ...;
JButton b = ...;
Image im = icon.getImage();
Image im2 = im.getScaledInstance(b.getWidth(), b.getHeight(), ...);
b.setIcon(new ImageIcon(im2));

代码示例来源: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: stackoverflow.com

public void actionPerformed(ActionEvent e) {
  // TODO Auto-generated method stub
  JButton button = (JButton) e.getSource();
.
.
for(int i=0;i<PSIZE;++i){
 if (tiles[i] == button){
  btnClicks[i] ++;
  if (btnClicks[i]t % 2 == 0) {
      button.setIcon(new ImageIcon(OneImageButton.class.getResource("/images/dambee.jpg")));
    } else {
      BufferedImage img = ImageIO.read(...); // learn how to load images from resource. "/images/kiss.jpg"
      int w = button.getWidth();
      int h = button.getHeight();
      img = img.getSubimage(w*(i/16), h*(i%16), w, h);
      button.setIcon(img);
    }

  }
 }
}

代码示例来源:origin: vasl-developers/vasl

public void actionPerformed(ActionEvent e)
  {
    if (getPopupMenu() != null)
      if (e.getSource() instanceof JButton)
        getPopupMenu().show((JButton)e.getSource(), ((JButton)e.getSource()).getWidth() - 5, ((JButton)e.getSource()).getHeight() - 5);
  }
});

代码示例来源:origin: net.sourceforge.jadex/jadex-tools-comanalyzer

public void actionPerformed(ActionEvent e)
  {
    JButton jb = (JButton)e.getSource();
    JPopupMenu popup = new MessageSliderMenu("Message Slider", ToolTab.this);
    popup.show(jb, (int)(jb.getWidth() - popup.getPreferredSize().getWidth()) / 2, (int)-popup.getPreferredSize().getHeight());
  }
};

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

public void scrollToVisible() {
  pickColor.scrollRectToVisible(new Rectangle(0, 0, pickColor.getWidth(), pickColor.getHeight()));
}
private int getFormRow() {

代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui

private void showColumnSelectionPopup(final JPopupMenu headerPopup, final JButton cornerButton) {
    initColumnSelectorItems();
    headerPopup.show(cornerButton, cornerButton.getWidth() - headerPopup.getPreferredSize().width, cornerButton.getHeight());
  }
}

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

JButton j=new JButton("START");
 j.setSize(100,50);
 j.setLocation(imageLabel.getWidth()/2-j.getWidth()/2, imageLabel.getHeight()/2-j.getHeight()/2);
 //then add Button into imageLabel
 imageLabel.add(j);

代码示例来源:origin: UNIVALI-LITE/Portugol-Studio

@Override
protected void paintIncreaseHighlight(Graphics g) {
  Insets insets = scrollbar.getInsets();
  Rectangle thumbR = getThumbBounds();
  g.setColor(new Color(202,207,203));
  if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
    int x = insets.left+decrButton.getWidth()/2-2;
    int y = thumbR.y;
    int w = 4;
    int h = incrButton.getY() - y;
    g.fillRect(x, y, w, h);
  }
}

代码示例来源:origin: uk.ac.gate.plugins/tools

private void addLines(STreeNode newNode) {
 JButton newButton = buttons.get(newNode.getID());
 int nbX = newButton.getX() + newButton.getWidth()/2;
 int nbY = newButton.getY() + newButton.getHeight();
 for (Iterator<JButton> i = selection.iterator(); i.hasNext(); ) {
  JButton selButton = i.next();
  //I create it a rect but it will in fact be used as x1, y1, x2, y2 for the
  //draw line. see drawLines.
  Coordinates coords = new Coordinates(
               nbX,
               nbY,
               selButton.getX() + selButton.getWidth()/2,
               selButton.getY());
  lines.add(coords);
 }
} // addLines

代码示例来源:origin: uk.ac.gate.plugins/tools

private void shiftButtonsDown(int offset) {
 for (Iterator<JButton> i = buttons.values().iterator(); i.hasNext(); ) {
  JButton button = i.next();
  button.setBounds(        button.getX(),
            button.getY() + offset,
            button.getWidth(),
            button.getHeight());
 } // for loop through buttons
 for (Iterator<Coordinates> k = lines.iterator(); k.hasNext(); ) {
  Coordinates coords = k.next();
  coords.setY1(coords.getY1() + offset);
  coords.setY2(coords.getY2() + offset);
 }
}// private void shiftButtonsDown(int offset)

代码示例来源:origin: uk.ac.gate.plugins/tools

/**
 * recalculates all lines from that node to all its children
 */
private void recalculateLines(STreeNode node) {
 Integer id = node.getID();
 JButton button = buttons.get(id);
 int bX = button.getX() + button.getWidth()/2;
 int bY = button.getY() + button.getHeight();
 for (Enumeration<?> e = node.children(); e.hasMoreElements(); ) {
  STreeNode subNode = (STreeNode) e.nextElement();
  Integer sid = subNode.getID();
  JButton subButton = buttons.get(sid);
  Coordinates coords = new Coordinates(
               bX,
               bY,
               subButton.getX() + subButton.getWidth()/2,
               subButton.getY());
  lines.add(coords);
 }
}

相关文章

JButton类方法