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()); }
/** constructor */ public MPopButton() { popListeners = new Vector(); popup = new JPopupMenu(); popActionListener = new MPopActionListener(this); addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { popup.show(MPopButton.this, 6, getSize().height - 6); } }); popup.addPopupMenuListener( new PopupMenuListener() { public void popupMenuWillBecomeVisible(PopupMenuEvent e) { Util.setMenuUp(true); } public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { Util.setMenuUp(false); } public void popupMenuCanceled(PopupMenuEvent e) {} }); } // MPopButton()
public void setPopupMenu(JPopupMenu menu) { this.menu = menu; menu.addPopupMenuListener(padapter); }