private void showSliderMenu() { Point location = new Point(getX(), getY() + getHeight()); SwingUtilities.convertPointToScreen(location, InputVolumeControlButton.this.getParent()); if (isFullScreen()) { location.setLocation( location.getX(), location.getY() - sliderMenu.getPreferredSize().getHeight() - getHeight()); } sliderMenu.setLocation(location); sliderMenu.addPopupMenuListener( new PopupMenuListener() { public void popupMenuWillBecomeVisible(PopupMenuEvent ev) { sliderMenuIsVisible = true; } public void popupMenuWillBecomeInvisible(PopupMenuEvent ev) { sliderMenuIsVisible = false; } public void popupMenuCanceled(PopupMenuEvent ev) {} }); sliderMenu.setVisible(!sliderMenu.isVisible()); }
/** * A chat room was selected. Opens the chat room in the chat window. * * @param e the <tt>MouseEvent</tt> instance containing details of the event that has just * occurred. */ public void mousePressed(MouseEvent e) { // Select the object under the right button click. if ((e.getModifiers() & InputEvent.BUTTON2_MASK) != 0 || (e.getModifiers() & InputEvent.BUTTON3_MASK) != 0 || (e.isControlDown() && !e.isMetaDown())) { int ix = this.chatRoomList.rowAtPoint(e.getPoint()); if (ix != -1) { this.chatRoomList.setRowSelectionInterval(ix, ix); } } Object o = this.chatRoomsTableModel.getValueAt(this.chatRoomList.getSelectedRow()); Point selectedCellPoint = e.getPoint(); SwingUtilities.convertPointToScreen(selectedCellPoint, chatRoomList); if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { JPopupMenu rightButtonMenu; if (o instanceof ChatRoomWrapper) rightButtonMenu = new ChatRoomRightButtonMenu((ChatRoomWrapper) o); else return; rightButtonMenu.setInvoker(this); rightButtonMenu.setLocation(selectedCellPoint); rightButtonMenu.setVisible(true); } }
public static void main(String... args) throws Exception { Robot robot = new Robot(); SwingUtilities.invokeAndWait( new Runnable() { public void run() { popup = new JPopupMenu(); popup.add(new JMenuItem("item")); popup.setVisible(true); } }); robot.waitForIdle(); if (!popup.isShowing()) { throw new RuntimeException("Where is my popup ?"); } SwingUtilities.invokeAndWait( new Runnable() { public void run() { popup.setVisible(false); popup.removeAll(); popup.setVisible(true); } }); robot.waitForIdle(); if (popup.isShowing()) { throw new RuntimeException("Empty popup is shown"); } popup.setVisible(false); }
public void showPopupAbove(Point loc, GraphControllerPopupListener graphControllerPopupListener) { if (_popUp.isVisible()) { _popUp.setVisible(false); } else { _popUp.show(_desktopPane, 0, 0); _popUp.setLocation(loc.x, loc.y - _popUp.getHeight()); } _currentGraphControllerPopupListener = graphControllerPopupListener; }
@Override public void mouseClicked(MouseEvent e) { indexOfLabelPressed = -1; for (int i = 0; i < orderLabel.length; i++) { if (e.getSource() == orderLabel[i]) { indexOfLabelPressed = i; PointerInfo a = MouseInfo.getPointerInfo(); Point b = a.getLocation(); int x = (int) b.getX(); int y = (int) b.getY(); popup.setLocation(x, y); popup.setInvoker(popup); popup.setVisible(true); revalidate(); repaint(); } } if (e.getSource() == topPanelLabel) { indexOfLabelPressed = -2; } if (indexOfLabelPressed == -1) { okDiscountButton.setText("Deduct"); discountPopup.setLocation(700, 220); discountPopup.setInvoker(discountPopup); discountPopup.setVisible(true); itemDiscountPopupLabel.setText( "$" + finalModifier + " off with " + menuPanel.df.format((1 - finalPercentModifier) * 100) + "%" + " discount"); } else if (indexOfLabelPressed == -2) { // TODO resetAll(); } }
/** * Shows the appropriate user interface that would allow the user to add the given * <tt>SourceUIContact</tt> to their contact list. * * @param contact the contact to add */ private void addContact(SourceUIContact contact) { SourceContact sourceContact = (SourceContact) contact.getDescriptor(); List<ContactDetail> details = sourceContact.getContactDetails(OperationSetPersistentPresence.class); int detailsCount = details.size(); if (detailsCount > 1) { JMenuItem addContactMenu = TreeContactList.createAddContactMenu((SourceContact) contact.getDescriptor()); JPopupMenu popupMenu = ((JMenu) addContactMenu).getPopupMenu(); // Add a title label. JLabel infoLabel = new JLabel(); infoLabel.setText( "<html><b>" + GuiActivator.getResources().getI18NString("service.gui.ADD_CONTACT") + "</b></html>"); popupMenu.insert(infoLabel, 0); popupMenu.insert(new Separator(), 1); popupMenu.setFocusable(true); popupMenu.setInvoker(treeContactList); Point location = new Point( addContactButton.getX(), addContactButton.getY() + addContactButton.getHeight()); SwingUtilities.convertPointToScreen(location, treeContactList); location.y = location.y + treeContactList.getPathBounds(treeContactList.getSelectionPath()).y; popupMenu.setLocation(location.x + 8, location.y - 8); popupMenu.setVisible(true); } else if (details.size() == 1) { TreeContactList.showAddContactDialog(details.get(0), sourceContact.getDisplayName()); } }
@Override public void actionPerformed(ActionEvent e) { String source = e.getActionCommand(); Object obj = e.getSource(); // popup buttons if (obj == removeButton) { midPanel.remove(orderLabel[indexOfLabelPressed]); popup.setVisible(false); itemCountOfLabel[indexOfLabelPressed] = 0; revalidate(); repaint(); setCost(); } else if (obj == cancelButton) { popup.setVisible(false); } else if (obj == discountButton) { discountPopup.setLocation(700, 220); discountPopup.setInvoker(discountPopup); discountPopup.setVisible(true); itemDiscountPopupLabel.setText( "Price: " + itemPriceOfLabel[indexOfLabelPressed] + " Discount: " + menuPanel.df.format(((1 - itemPriceModifier[indexOfLabelPressed]) * 100)) + "%"); } else if (obj == countButton) { countPopup.setLocation(700, 220); countPopup.setInvoker(countPopup); countPopup.setVisible(true); } // discount buttons if (indexOfLabelPressed != -1) { // if it is label okDiscountButton.setText("Set Price"); if (obj == discountButton0 || obj == discountButton1 || obj == discountButton2 || obj == discountButton3 || obj == discountButton4 || obj == discountButton5 || obj == discountButton6 || obj == discountButton7 || obj == discountButton8 || obj == discountButton9) { itemDiscountPopupString = itemDiscountPopupString + source; itemDiscountPopupLabel.setText("Discount: " + itemDiscountPopupString); } else if (obj == clearDiscountButton) { itemDiscountPopupString = ""; itemDiscountPopupLabel.setText("Discount: " + itemCountPopupString); discountPopup.setVisible(false); } else if (obj == okDiscountButton) { if (itemDiscountPopupString == "") { itemDiscountPopupString = ""; itemDiscountPopupLabel.setText("Discount: " + itemDiscountPopupString); discountPopup.setVisible(false); } else { itemPriceOfLabel[indexOfLabelPressed] = Double.parseDouble(itemDiscountPopupString) / 100; discountPopup.setVisible(false); setLabelText(); setCost(); itemDiscountPopupString = ""; itemDiscountPopupLabel.setText("Discount: " + itemDiscountPopupString); } } else if (obj == percentDiscountButton) { if (itemDiscountPopupString == "") { itemDiscountPopupString = ""; itemDiscountPopupLabel.setText("Discount: " + itemDiscountPopupString); discountPopup.setVisible(false); } else { itemPriceModifier[indexOfLabelPressed] = (100 - Double.parseDouble(itemDiscountPopupString)) / 100; discountPopup.setVisible(false); setLabelText(); setCost(); itemDiscountPopupString = ""; itemDiscountPopupLabel.setText("Discount: " + itemDiscountPopupString); } } else if (obj == resetDiscountButton) { itemPriceModifier[indexOfLabelPressed] = 1; itemPriceOfLabel[indexOfLabelPressed] = itemOriginalPrice[indexOfLabelPressed]; setLabelText(); setCost(); discountPopup.setVisible(false); itemDiscountPopupString = ""; itemDiscountPopupLabel.setText("Discount: " + itemDiscountPopupString); } } else if (indexOfLabelPressed == -1) { okDiscountButton.setText("Deduct"); if (obj == discountButton0 || obj == discountButton1 || obj == discountButton2 || obj == discountButton3 || obj == discountButton4 || obj == discountButton5 || obj == discountButton6 || obj == discountButton7 || obj == discountButton8 || obj == discountButton9) { itemDiscountPopupString = itemDiscountPopupString + source; itemDiscountPopupLabel.setText("Discount: " + itemDiscountPopupString); } else if (obj == clearDiscountButton) { itemDiscountPopupString = ""; itemDiscountPopupLabel.setText("Discount: " + itemCountPopupString); discountPopup.setVisible(false); } else if (obj == okDiscountButton) { if (itemDiscountPopupString == "") { itemDiscountPopupString = ""; itemDiscountPopupLabel.setText("Discount: " + itemDiscountPopupString); discountPopup.setVisible(false); } else { finalModifier = Double.parseDouble(itemDiscountPopupString) / 100; discountPopup.setVisible(false); setCost(); itemDiscountPopupString = ""; itemDiscountPopupLabel.setText("Discount: " + itemDiscountPopupString); } } else if (obj == percentDiscountButton) { if (itemDiscountPopupString == "") { itemDiscountPopupString = ""; itemDiscountPopupLabel.setText("Discount: " + itemDiscountPopupString); discountPopup.setVisible(false); } else { finalPercentModifier = (100 - Double.parseDouble(itemDiscountPopupString)) / 100; discountPopup.setVisible(false); setCost(); itemDiscountPopupString = ""; itemDiscountPopupLabel.setText("Discount: " + itemDiscountPopupString); } } else if (obj == resetDiscountButton) { finalPercentModifier = 1; finalModifier = 0; setCost(); discountPopup.setVisible(false); itemDiscountPopupString = ""; itemDiscountPopupLabel.setText("Discount: " + itemDiscountPopupString); } } // count buttons if (obj == countButton0 || obj == countButton1 || obj == countButton2 || obj == countButton3 || obj == countButton4 || obj == countButton5 || obj == countButton6 || obj == countButton7 || obj == countButton8 || obj == countButton9) { itemCountPopupString = itemCountPopupString + source; itemCountPopupLabel.setText("Item count: " + itemCountPopupString); } else if (obj == clearCountButton) { itemCountPopupString = ""; itemCountPopupLabel.setText("Item count: " + itemCountPopupString); countPopup.setVisible(false); } else if (obj == okCountButton) { if (itemCountPopupString == "") { itemCountPopupString = ""; itemCountPopupLabel.setText("Item count: " + itemCountPopupString); countPopup.setVisible(false); } else { itemCountOfLabel[indexOfLabelPressed] = Integer.parseInt(itemCountPopupString); countPopup.setVisible(false); setLabelText(); setCost(); itemCountPopupString = ""; itemCountPopupLabel.setText("Item count: " + itemCountPopupString); } } }
protected void hideSystemMenu() { systemMenu.setVisible(false); }
public void closePopup() { myUnderPopup.setVisible(false); myAbovePopup.setVisible(false); }
public void hidePopup() { _popUp.setVisible(false); }