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

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

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

JButton.getBounds介绍

暂无

代码示例

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

  1. final JPopupMenu menu = new JPopupMenu();
  2. menu.add(...whatever...);
  3. final JButton button = new JButton();
  4. button.setText("My Menu");
  5. button.addActionListener(new ActionListener() {
  6. public void actionPerformed(ActionEvent ev) {
  7. menu.show(button, button.getBounds().x, button.getBounds().y
  8. + button.getBounds().height);
  9. }
  10. });

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

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

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

  1. public void mouseExited(MouseEvent e)
  2. {
  3. if(!iconButton.getBounds().contains(e.getPoint()) &&
  4. !maxButton.getBounds().contains(e.getPoint()) &&
  5. !closeButton.getBounds().contains(e.getPoint()))
  6. {
  7. handyEmptyBorder.setDrawBorder(false);
  8. repaint();
  9. }
  10. }
  11. }

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

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

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

  1. @Override
  2. public void actionPerformed(ActionEvent e) {
  3. final JPopupMenu menu = new JPopupMenu();
  4. JMenuItem menuItemEdit = new JMenuItem("Auto track number");
  5. menu.add(menuItemEdit).addActionListener(new ActionListener() {
  6. @Override
  7. public void actionPerformed(ActionEvent e) {
  8. Tools.autoTrackNumber(tagFieldsModel);
  9. tagFieldsModel.sort();
  10. tagsTable.revalidate();
  11. tagsTable.repaint();
  12. }
  13. });
  14. menu.show(tools, 0, tools.getBounds().height);
  15. }
  16. });

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

  1. JComponent comp = Box.createVerticalBox();
  2. final JComponent upper = new JPanel();
  3. final JButton upperChild = new JButton("happy in upper");
  4. upper.add(upperChild);
  5. final JComponent lower = new JPanel();
  6. final JButton lowerChild = new JButton("unhappy in lower");
  7. lower.add(lowerChild);
  8. comp.add(upper);
  9. comp.add(lower);
  10. LayerUI<JComponent> ui = new LayerUI<JComponent>() {
  11. @Override
  12. public void paint(Graphics g, JComponent c) {
  13. super.paint(g, c);
  14. Rectangle u = SwingUtilities.convertRectangle(upper, upperChild.getBounds(), c);
  15. Rectangle l = SwingUtilities.convertRectangle(lower, lowerChild.getBounds(), c);
  16. g.setColor(Color.RED);
  17. g.drawLine(u.x, u.y + u.height, l.x, l.y);
  18. }
  19. };
  20. JLayer<JComponent> layer = new JLayer<JComponent>(comp, ui);

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

  1. @Override
  2. public void actionPerformed(ActionEvent e) {
  3. JPopupMenu menu = new JPopupMenu("New File");
  4. List<CodeParserPlugin> plugins = new ArrayList<CodeParserPlugin>();
  5. plugins.addAll(Plugins.getCodeParserPlugins());
  6. Collections.sort(plugins, new PluginSorter());
  7. for (CodeParserPlugin plugin : plugins) {
  8. menu.add(new NewFileAction(plugin, tabbedPane));
  9. }
  10. menu.show(newFileButton, 0, newFileButton.getBounds().height);
  11. }
  12. });

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

  1. @Override
  2. public void actionPerformed(ActionEvent e) {
  3. JPopupMenu menu = new JPopupMenu("Open File");
  4. List<CodeParserPlugin> plugins = new ArrayList<CodeParserPlugin>();
  5. plugins.addAll(Plugins.getCodeParserPlugins());
  6. Collections.sort(plugins, new PluginSorter());
  7. for (CodeParserPlugin plugin : plugins) {
  8. menu.add(new OpenFileAction(plugin, tabbedPane));
  9. }
  10. menu.show(openFileButton, 0, openFileButton.getBounds().height);
  11. }
  12. });

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

  1. public class Click {
  2. public static void main(String[] args) {
  3. SwingUtilities.invokeLater(new Runnable() {
  4. public void run() {
  5. final JFrame f = new JFrame("Click pos");
  6. f.setSize(640, 480);
  7. final JButton b = new JButton("Click Me!");
  8. b.addMouseListener(new MouseAdapter() {
  9. public void mouseClicked(MouseEvent e) {
  10. final JButton bb = (JButton) e.getSource();
  11. final Rectangle bbox = bb.getBounds();
  12. final int x = bbox.x + e.getX();
  13. final int y = bbox.y + e.getY();
  14. JOptionPane.showMessageDialog(f, "pos: " + x + " " + y);
  15. }
  16. });
  17. f.getContentPane().add(b, BorderLayout.SOUTH);
  18. f.setVisible(true);
  19. }
  20. });
  21. }
  22. }

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

  1. /**
  2. * Paints the divider.
  3. *
  4. * @param g Description of Parameter
  5. */
  6. public void paint(Graphics g) {
  7. //Paint the border.
  8. //Border border = getBorder();
  9. //if (border != null) {
  10. Dimension size = getSize();
  11. //border.paintBorder(this, g, 0, 0, size.width, size.height);
  12. skin.getSplitPane().paintGutter(g, splitPane, size);
  13. if (leftButton != null) {
  14. Rectangle bounds = leftButton.getBounds();
  15. Graphics glb = g.create(bounds.x, bounds.y, bounds.width, bounds.height);
  16. leftButton.paint(glb);
  17. }
  18. if (rightButton != null) {
  19. Rectangle bounds = rightButton.getBounds();
  20. Graphics grb = g.create(bounds.x, bounds.y, bounds.width, bounds.height);
  21. rightButton.paint(grb);
  22. }
  23. skin.getSplitPane().paintThumb(g, splitPane, size);
  24. }

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

  1. @Override
  2. public void mouseReleased(MouseEvent event) {
  3. // Do nothing if the mouse was released inside the toggle button.
  4. Point mousePositionOnScreen = MouseInfo.getPointerInfo().getLocation();
  5. Rectangle toggleBoundsOnScreen = getComponentToggleTimeMenuButton().getBounds();
  6. toggleBoundsOnScreen.setLocation(getComponentToggleTimeMenuButton().getLocationOnScreen());
  7. if (toggleBoundsOnScreen.contains(mousePositionOnScreen)) {
  8. return;
  9. }
  10. if (timeMenuPanel != null) {
  11. timeMenuPanel.mouseReleasedFromToggleButtonOutsideButton();
  12. }
  13. }
  14. });

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

  1. Rectangle r = new Rectangle(0, 0, 0, 0);
  2. if (frame.isIconifiable())
  3. r = iconButton.getBounds();
  4. else if (frame.isMaximizable())
  5. r = maxButton.getBounds();
  6. else if (frame.isClosable()) r = closeButton.getBounds();
  7. int titleW;

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

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

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

  1. len = iconButton.getBounds().x;
  2. len = maxButton.getBounds().x;
  3. len = closeButton.getBounds().x;

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

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

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

  1. rect = iconifyButton.getBounds();

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

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

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

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

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

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

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

  1. /**
  2. * Paint the background for a tab scroll button.
  3. *
  4. * @param ss the tab subregion SynthContext.
  5. * @param g the Graphics context.
  6. * @param scrollButton the button to paint.
  7. */
  8. protected void paintScrollButtonBackground(SeaGlassContext ss, Graphics g, JButton scrollButton) {
  9. Rectangle tabRect = scrollButton.getBounds();
  10. int x = tabRect.x;
  11. int y = tabRect.y;
  12. int height = tabRect.height;
  13. int width = tabRect.width;
  14. boolean flipSegments = (orientation == ControlOrientation.HORIZONTAL && !tabPane.getComponentOrientation().isLeftToRight());
  15. SeaGlassLookAndFeel.updateSubregion(ss, g, tabRect);
  16. tabPane.putClientProperty("JTabbedPane.Tab.segmentPosition",
  17. ((scrollButton == scrollBackwardButton) ^ flipSegments) ? "first" : "last");
  18. int oldState = tabContext.getComponentState();
  19. ButtonModel model = scrollButton.getModel();
  20. int isPressed = model.isPressed() && model.isArmed() ? PRESSED : 0;
  21. int buttonState = SeaGlassLookAndFeel.getComponentState(scrollButton) | isPressed;
  22. tabContext.setComponentState(buttonState);
  23. tabContext.getPainter().paintTabbedPaneTabBackground(tabContext, g, x, y, width, height, -1, tabPlacement);
  24. tabContext.getPainter().paintTabbedPaneTabBorder(tabContext, g, x, y, width, height, -1, tabPlacement);
  25. tabContext.setComponentState(oldState);
  26. }

相关文章

JButton类方法