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

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

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

JButton.getWidth介绍

暂无

代码示例

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

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

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

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

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

  1. @Override
  2. public void actionPerformed (ActionEvent e)
  3. {
  4. Object source = e.getSource();
  5. if (source instanceof JButton) {
  6. JButton button = (JButton) source;
  7. popup.show(button, button.getWidth(), 20);
  8. }
  9. }

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

  1. @Override
  2. public void mousePressed(MouseEvent e) {
  3. JPopupMenu menu = new JPopupMenu();
  4. menu.add(new JMenuItem(addNewBoardAction));
  5. menu.add(new JMenuItem(addExistingBoardAction));
  6. menu.show(btnAddBoard, (int) btnAddBoard.getWidth(), (int) btnAddBoard.getHeight());
  7. }
  8. });

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

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

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

  1. @ScriptFunction(jsDoc = WIDTH_JSDOC)
  2. @Override
  3. public int getWidth() {
  4. return super.getWidth();
  5. }

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

  1. void setArrowLocation( int arrowLocation) {
  2. this.arrowLocation = arrowLocation;
  3. if( arrowLocation == GridBagConstraints.NORTHEAST || arrowLocation == GridBagConstraints.NORTHWEST ) {
  4. setBorder( BorderFactory.createEmptyBorder(0, 0, Y_OFFSET, btnDismiss.getWidth()));
  5. } else {
  6. setBorder( BorderFactory.createEmptyBorder(Y_OFFSET, 0, 0, btnDismiss.getWidth()));
  7. }
  8. }

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

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

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

  1. ImageIcon icon = ...;
  2. JButton b = ...;
  3. Image im = icon.getImage();
  4. Image im2 = im.getScaledInstance(b.getWidth(), b.getHeight(), ...);
  5. b.setIcon(new ImageIcon(im2));

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

  1. public void actionPerformed(ActionEvent e) {
  2. // TODO Auto-generated method stub
  3. JButton button = (JButton) e.getSource();
  4. .
  5. .
  6. for(int i=0;i<PSIZE;++i){
  7. if (tiles[i] == button){
  8. btnClicks[i] ++;
  9. if (btnClicks[i]t % 2 == 0) {
  10. button.setIcon(new ImageIcon(OneImageButton.class.getResource("/images/dambee.jpg")));
  11. } else {
  12. BufferedImage img = ImageIO.read(...); // learn how to load images from resource. "/images/kiss.jpg"
  13. int w = button.getWidth();
  14. int h = button.getHeight();
  15. img = img.getSubimage(w*(i/16), h*(i%16), w, h);
  16. button.setIcon(img);
  17. }
  18. }
  19. }
  20. }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1. private void shiftButtonsDown(int offset) {
  2. for (Iterator<JButton> i = buttons.values().iterator(); i.hasNext(); ) {
  3. JButton button = i.next();
  4. button.setBounds( button.getX(),
  5. button.getY() + offset,
  6. button.getWidth(),
  7. button.getHeight());
  8. } // for loop through buttons
  9. for (Iterator<Coordinates> k = lines.iterator(); k.hasNext(); ) {
  10. Coordinates coords = k.next();
  11. coords.setY1(coords.getY1() + offset);
  12. coords.setY2(coords.getY2() + offset);
  13. }
  14. }// private void shiftButtonsDown(int offset)

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

  1. /**
  2. * recalculates all lines from that node to all its children
  3. */
  4. private void recalculateLines(STreeNode node) {
  5. Integer id = node.getID();
  6. JButton button = buttons.get(id);
  7. int bX = button.getX() + button.getWidth()/2;
  8. int bY = button.getY() + button.getHeight();
  9. for (Enumeration<?> e = node.children(); e.hasMoreElements(); ) {
  10. STreeNode subNode = (STreeNode) e.nextElement();
  11. Integer sid = subNode.getID();
  12. JButton subButton = buttons.get(sid);
  13. Coordinates coords = new Coordinates(
  14. bX,
  15. bY,
  16. subButton.getX() + subButton.getWidth()/2,
  17. subButton.getY());
  18. lines.add(coords);
  19. }
  20. }

相关文章

JButton类方法