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

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

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

JButton.getBounds介绍

暂无

代码示例

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

final JPopupMenu menu = new JPopupMenu();
menu.add(...whatever...);

final JButton button = new JButton();
button.setText("My Menu");
button.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent ev) {
    menu.show(button, button.getBounds().x, button.getBounds().y
      + button.getBounds().height);
  }
});

代码示例来源:origin: raydac/netbeans-mmd-plugin

@Override
public boolean contains(int x, int y) {
 return this.closeButton.getBounds().contains(x, y);
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf

public void mouseExited(MouseEvent e)
  {
    if(!iconButton.getBounds().contains(e.getPoint()) &&
      !maxButton.getBounds().contains(e.getPoint()) &&
      !closeButton.getBounds().contains(e.getPoint()))
    {
      handyEmptyBorder.setDrawBorder(false);
      repaint();
    }
  }
}

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

Rectangle bounds = button.getBounds();
bounds.x -= 10;
bounds.y -= 10;

代码示例来源:origin: tulskiy/musique

@Override
  public void actionPerformed(ActionEvent e) {
    final JPopupMenu menu = new JPopupMenu();
    JMenuItem menuItemEdit = new JMenuItem("Auto track number");
    menu.add(menuItemEdit).addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        Tools.autoTrackNumber(tagFieldsModel);
        tagFieldsModel.sort();
        
        tagsTable.revalidate();
        tagsTable.repaint();
      }
    });
    
    menu.show(tools, 0, tools.getBounds().height);
  }
});

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

JComponent comp = Box.createVerticalBox();
 final JComponent upper = new JPanel();
 final JButton upperChild = new JButton("happy in upper");
 upper.add(upperChild);
 final JComponent lower = new JPanel();
 final JButton lowerChild = new JButton("unhappy in lower");
 lower.add(lowerChild);
 comp.add(upper);
 comp.add(lower);
 LayerUI<JComponent> ui = new LayerUI<JComponent>() {
   @Override
   public void paint(Graphics g, JComponent c) {
     super.paint(g, c);
     Rectangle u = SwingUtilities.convertRectangle(upper, upperChild.getBounds(), c);
     Rectangle l = SwingUtilities.convertRectangle(lower, lowerChild.getBounds(), c);
     g.setColor(Color.RED);
     g.drawLine(u.x, u.y + u.height, l.x, l.y);
   }
 };
 JLayer<JComponent> layer = new JLayer<JComponent>(comp, ui);

代码示例来源:origin: CallForSanity/Gaalop

@Override
  public void actionPerformed(ActionEvent e) {
    JPopupMenu menu = new JPopupMenu("New File");
    List<CodeParserPlugin> plugins = new ArrayList<CodeParserPlugin>();
    plugins.addAll(Plugins.getCodeParserPlugins());
    Collections.sort(plugins, new PluginSorter());
    for (CodeParserPlugin plugin : plugins) {
      menu.add(new NewFileAction(plugin, tabbedPane));
    }
    menu.show(newFileButton, 0, newFileButton.getBounds().height);
  }
});

代码示例来源:origin: CallForSanity/Gaalop

@Override
  public void actionPerformed(ActionEvent e) {
    JPopupMenu menu = new JPopupMenu("Open File");
    List<CodeParserPlugin> plugins = new ArrayList<CodeParserPlugin>();
    plugins.addAll(Plugins.getCodeParserPlugins());
    Collections.sort(plugins, new PluginSorter());
    for (CodeParserPlugin plugin : plugins) {
      menu.add(new OpenFileAction(plugin, tabbedPane));
    }
    menu.show(openFileButton, 0, openFileButton.getBounds().height);
  }
});

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

public class Click { 
  public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        final JFrame f = new JFrame("Click pos");
        f.setSize(640, 480);

        final JButton b = new JButton("Click Me!");
        b.addMouseListener(new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            final JButton bb = (JButton) e.getSource();
            final Rectangle bbox = bb.getBounds();
            final int x = bbox.x + e.getX();
            final int y = bbox.y + e.getY();
            JOptionPane.showMessageDialog(f, "pos: " + x + " " + y);
          }
        });
        f.getContentPane().add(b, BorderLayout.SOUTH);
        f.setVisible(true);
      }
    });
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/skinlf

/**
 * Paints the divider.
 *
 * @param g  Description of Parameter
 */
public void paint(Graphics g) {
 //Paint the border.
 //Border   border = getBorder();
 //if (border != null) {
 Dimension size = getSize();
 //border.paintBorder(this, g, 0, 0, size.width, size.height);
 skin.getSplitPane().paintGutter(g, splitPane, size);
 if (leftButton != null) {
  Rectangle bounds = leftButton.getBounds();
  Graphics glb = g.create(bounds.x, bounds.y, bounds.width, bounds.height);
  leftButton.paint(glb);
 }
 if (rightButton != null) {
  Rectangle bounds = rightButton.getBounds();
  Graphics grb = g.create(bounds.x, bounds.y, bounds.width, bounds.height);
  rightButton.paint(grb);
 }
 skin.getSplitPane().paintThumb(g, splitPane, size);
}

代码示例来源:origin: com.github.lgooddatepicker/LGoodDatePicker

@Override
  public void mouseReleased(MouseEvent event) {
    // Do nothing if the mouse was released inside the toggle button.
    Point mousePositionOnScreen = MouseInfo.getPointerInfo().getLocation();
    Rectangle toggleBoundsOnScreen = getComponentToggleTimeMenuButton().getBounds();
    toggleBoundsOnScreen.setLocation(getComponentToggleTimeMenuButton().getLocationOnScreen());
    if (toggleBoundsOnScreen.contains(mousePositionOnScreen)) {
      return;
    }
    if (timeMenuPanel != null) {
      timeMenuPanel.mouseReleasedFromToggleButtonOutsideButton();
    }
  }
});

代码示例来源:origin: net.sf.squirrel-sql.plugins/graph

Rectangle r = new Rectangle(0, 0, 0, 0);
if (frame.isIconifiable())
  r = iconButton.getBounds();
else if (frame.isMaximizable())
  r = maxButton.getBounds();
else if (frame.isClosable()) r = closeButton.getBounds();
int titleW;

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

Rectangle bounds = listButton.getBounds();
switch (tabPlacement) {
  case TOP:

代码示例来源:origin: net.sf.nimrod/nimrod-laf

len = iconButton.getBounds().x; 
len = maxButton.getBounds().x;
len = closeButton.getBounds().x;

代码示例来源:origin: robward-scisys/sldeditor

(int) buttonEdit.getBounds().getMaxX() + 5,
0,
BasePanel.WIDGET_BUTTON_WIDTH,

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/napkinlaf

rect = iconifyButton.getBounds();

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

Rectangle bounds = listButton.getBounds();
Point p = listButton.getLocationOnScreen();
bounds.x = p.x;

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

((JideTabbedPane.NoFocusButton) _closeButtons[i]).setIndex(i);
if (!bounds.equals(_closeButtons[i].getBounds())) {
  _closeButtons[i].setBounds(bounds);

代码示例来源:origin: com.github.lgooddatepicker/LGoodDatePicker

+ toggleCalendarButton.getBounds().width - popup.getBounds().width - 2;
int defaultY = toggleCalendarButton.getLocationOnScreen().y
    + toggleCalendarButton.getBounds().height + 2;

代码示例来源:origin: khuxtable/seaglass

/**
 * Paint the background for a tab scroll button.
 *
 * @param ss           the tab subregion SynthContext.
 * @param g            the Graphics context.
 * @param scrollButton the button to paint.
 */
protected void paintScrollButtonBackground(SeaGlassContext ss, Graphics g, JButton scrollButton) {
  Rectangle tabRect = scrollButton.getBounds();
  int       x       = tabRect.x;
  int       y       = tabRect.y;
  int       height  = tabRect.height;
  int       width   = tabRect.width;
  boolean flipSegments = (orientation == ControlOrientation.HORIZONTAL && !tabPane.getComponentOrientation().isLeftToRight());
  SeaGlassLookAndFeel.updateSubregion(ss, g, tabRect);
  tabPane.putClientProperty("JTabbedPane.Tab.segmentPosition",
               ((scrollButton == scrollBackwardButton) ^ flipSegments) ? "first" : "last");
  int         oldState    = tabContext.getComponentState();
  ButtonModel model       = scrollButton.getModel();
  int         isPressed   = model.isPressed() && model.isArmed() ? PRESSED : 0;
  int         buttonState = SeaGlassLookAndFeel.getComponentState(scrollButton) | isPressed;
  tabContext.setComponentState(buttonState);
  tabContext.getPainter().paintTabbedPaneTabBackground(tabContext, g, x, y, width, height, -1, tabPlacement);
  tabContext.getPainter().paintTabbedPaneTabBorder(tabContext, g, x, y, width, height, -1, tabPlacement);
  tabContext.setComponentState(oldState);
}

相关文章

JButton类方法