@Override public void actionPerformed (ActionEvent e) { JButton button = (JButton) e.getSource(); menu.show(ShapesPane.this, button.getX(), button.getY()); } }
@Override public void actionPerformed (ActionEvent e) { JButton button = (JButton) e.getSource(); menu.show(RangesPane.this, button.getX(), button.getY()); } }
JFrame f = new JFrame("Test"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new JLabel("Test"), BorderLayout.WEST); JButton b = new JButton("Test"); f.add(b); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); System.out.println(SwingUtilities.convertPoint(b, b.getX(), b.getY(), f));
@Override public void componentMoved(ComponentEvent ce) { if (m.isVisible()) { m.show(pillInstance, editButton.getX(), pillInstance.getHeight()); } }
@Override public void mouseClicked(MouseEvent e) { if (btnRecently.isEnabled()) { recentlyPopup.show(e.getComponent(), btnRecently.getX(), btnRecently.getY() + btnRecently.getHeight()); } } });
@Override public void mouseClicked(MouseEvent e) { if (btnFilter.isEnabled()) { filterPopup.show(e.getComponent(), btnFilter.getX(), btnFilter.getY() + btnFilter.getHeight()); } } });
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
/** * Remove column button pressed. * * @param removeColumnButton the remove column button * @param e the e */ protected void removeColumnButton(JButton removeColumnButton, ActionEvent e) { JPopupMenu popupMenu = new JPopupMenu(); List<String> columnNames = model.getColumnNames(); for (String columnName : columnNames) { JMenuItem menuItem = new JMenuItem(columnName); menuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { model.removeColumn(columnName); } }); popupMenu.add(menuItem); } if (e != null) { popupMenu.show( removeColumnButton, removeColumnButton.getX() - removeColumnButton.getWidth(), removeColumnButton.getY()); } }
j.setLocation(j.getX() + 10, j.getY() + 10);
public class PropertiesButton extends JButton { private JPanel theWindow; public PropertiesButton() { theWindow = new JPanel(); theWindow.add(new JMenuCheckBoxItem("Something")); this.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (theWindow.isVisible()) { theWindow.setVisible(false); getParent().remove(theWindow); } else { JButton btn = (JButton)e.getSource(); getParent().add(theWindow); theWindow.setBounds( btn.getX(), btn.getY() + btn.getHeight(), 100, 100); theWindow.setVisible(true); } } }); theWindow.setVisible(false); } }
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)
/** * 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); } }
int x = btnEditFilter.getX() + btnEditFilter.getWidth() + 5; btnClearFilter.setBounds(x, 0, WIDGET_BUTTON_WIDTH, WIDGET_HEIGHT); fieldPanel.add(btnClearFilter);
@Override public void mousePressed(MouseEvent evt) { if(popup != null && popup.isVisible()) popup.setVisible(false); else { popup = dockableWindowManager.createPopupMenu( FloatingWindowContainer.this, entry.factory.name,clone); GUIUtilities.showPopupMenu(popup, menu,menu.getX(),menu.getY() + menu.getHeight(), false); } } } //}}}
maxX = lastButton.getX() - titleSpacing; } else { maxX = frame.getWidth() - frame.getInsets().right - titleSpacing; minX = menuButton.getX() + menuButton.getWidth() + titleSpacing; } else { minX = lastButton.getX() + lastButton.getWidth() + titleSpacing; } else { minX = frame.getInsets().left + titleSpacing; maxX = menuButton.getX() - titleSpacing;
maxX = lastButton.getX() - titleSpacing; } else { maxX = getParentWidth() - getParentInsets().right - titleSpacing; minX = menuButton.getX() + menuButton.getWidth() + titleSpacing; } else { minX = lastButton.getX() + lastButton.getWidth() + titleSpacing; } else { minX = getParentInsets().left + titleSpacing; maxX = getParentWidth() - getParentInsets().right - menuButton.getX() - titleSpacing;
thumbMin = sbInsets.left; thumbMax = XTraScrollBarUI.this.decrButton().getX()
leftButton.setBounds(extraX + offset, y, leftButton .getPreferredSize().width * 2 / 3, blockSize); rightButton.setBounds(leftButton.getX() + leftButton.getWidth(), y, rightButton .getPreferredSize().width * 2 / 3, blockSize);
leftButton.setBounds(extraX + offset, y, leftButton .getPreferredSize().width * 2 / 3, blockSize); rightButton.setBounds(leftButton.getX() + leftButton.getWidth(), y, rightButton .getPreferredSize().width * 2 / 3, blockSize);