Java 8 JPopupMenu - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 JPopupMenu class.

This code example shows how to use the following methods:add, addSeparator
			System.err.println("Does not handle OS '"+osName+"'");
			return null; 
		} 
	} 
	public static final JPopupMenu createOpenOpenWithShowDirPopupPanel(final File file) {
		JPopupMenu menu=new JPopupMenu();
		 
		//JButton bOpen=new JButton("Open"); 
		JMenuItem miOpen=new JMenuItem("Open");
		JMenuItem miOpenWith=new JMenuItem("Open with...");
		JMenuItem miShowDir=new JMenuItem("Open parent directory");
		 
		boolean isWindows = osName.indexOf("windows") >= 0;
			 
		miShowDir.setToolTipText("<html><body>Browse directory :<br><code>"+file.getParentFile().toString()+"</code></body></html>");
		//bOpen.setToolTipText("<html><body>Open file :<br><code>"+file.toString()+"</code></body></html>"); 
		 
		/*bOpen.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { 
				try { 
					runSystemOpenFile(file); 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getPreferredSize, setPreferredSize, isVisible, pack, show
		int newPopupRowCount = Math.min(listModel.getSize(), maxPopupRowCount);
		adjustPopupSize(newPopupRowCount);
 
		// Show popup just beneath the text field 
		if (!isOptionsPopupVisible()) { 
			popup.show(textField, 0, textField.getHeight());
		} 
	} 
 
	// Adjusts the size of the popup (tricky) 
	private void adjustPopupSize(int newPopupRowCount) {
		if (popupRowCount == newPopupRowCount) {
			return; 
		} 
		popupRowCount = newPopupRowCount;
 
		// Set visible row count in list 
		list.setVisibleRowCount(popupRowCount);
		// Let the UI calculate the preferred size 
		popup.setPreferredSize(null);

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setFocusable, setBorder, addPopupMenuListener
	public SymbolTablePopupD(AppD app, MyTextField textField){
 
		this.app = app;
		this.textField = textField;
		 
		popup = new JPopupMenu();
		popup.setFocusable(false);
		popup.setBorder(BorderFactory.createLineBorder(SystemColor.controlShadow));
 
		createSymbolTable(); 
		registerListeners(); 
		locale = app.getLocale();
		 
		app.setComponentOrientation(popup);
	} 
 
 
 
	private void createSymbolTable() { 
 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:add, show
                deleteSelectedItem(); 
            } 
        }); 
         
        // show the popup menu 
        final JPopupMenu menu = new JPopupMenu();
        menu.add( delete );
        menu.show( this, (int)p.getX(), (int)p.getY() );
         
    } 
     
    /** 
     *  does exactly what it says on the tin.  tries to remove the 
     *  selected playlist from the collection, and if this works then 
     *  it's removed from the list aswell. 
     *  
     */ 
     
    private void deleteSelectedItem() { 
         
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
        MenuFactory.addFileMenu(pop);
        return pop;
    } 
 
    public static JPopupMenu getDefaultConfigElementMenu() {
        JPopupMenu pop = new JPopupMenu();
        MenuFactory.addEditMenu(pop, true);
        MenuFactory.addFileMenu(pop);
        return pop;
    } 
 
    public static JPopupMenu getDefaultVisualizerMenu() {
        JPopupMenu pop = new JPopupMenu();
        MenuFactory.addEditMenu(pop, true);
        MenuFactory.addFileMenu(pop);
        return pop;
    } 
 
    public static JPopupMenu getDefaultTimerMenu() {
        JPopupMenu pop = new JPopupMenu();
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:add, hide, isVisible
        JWindow w = new JWindow();
        w.setSize(100, 100);
        w.setVisible(true);
        Util.waitForIdle(r);
 
        final JPopupMenu menu = new JPopupMenu();
        JButton item = new JButton("A button in popup");
 
        menu.add(item);
 
        w.addMouseListener(new MouseAdapter() {
                public void mousePressed(MouseEvent me) {
                menu.show(me.getComponent(), me.getX(), me.getY());
 
                System.out.println("Showing menu at " + menu.getLocationOnScreen() +
                                   " isVisible: " + menu.isVisible() +
                                   " isValid: " + menu.isValid());
                } 
            }); 
 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:add, addSeparator
	 * Creates the popmenu for the lens, allow the user to change settings: 
	 * zoom factor, lens size and display units. 
	 */ 
	private void createPopupMenu() 
	{ 
		popupMenu = new JPopupMenu(POPUP_MENU_DESCRIPTION);
		popupMenu.add(new JMenuItem(POPUP_MENU_TOPOPTION));
		popupMenu.addSeparator();
		popupMenu.add(createFileMenu());
		popupMenu.add(createLensOptions());
		popupMenu.add(createZoomOptions());
		popupMenu.add(createDisplayOptions());
		popupMenu.add(createLensColorOptions());
	} 
	 
	/**  
	 * Creates the popmenu for the lens, allow the user to change settings: 
	 * zoom factor, lens size and display units. 
	 */ 
	private void createMenubarMenu() 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getComponent, add, insert
	public static int count = 0;
	public void addMenuComponent(JMenu menu, final Component component, final int index) {
	    final JPopupMenu popupMenu = menu.getPopupMenu();
	    final int itemCount = popupMenu.getComponentCount();
	    if(index == 0 || index < itemCount)
	    	popupMenu.insert(component, index);
        else { 
        	final Component lastMenuItem = popupMenu.getComponent(itemCount - 1);
        	final boolean extraSubMenu = isExtraSubMenu(lastMenuItem);
	        if (extraSubMenu || !fitsOnScreen(popupMenu, component)) {
	        	final JMenu submenu;
				if(extraSubMenu) {
	        		submenu = (JMenu) lastMenuItem;
	        	} 
                else { 
	        		if (component instanceof JPopupMenu.Separator)
	        			return; 
	        		submenu = new JMenu("");
	        		submenu.putClientProperty(EXTRA_SUBMENU, Boolean.TRUE);
	        		popupMenu.add(submenu);

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:removeAll, add, addSeparator, isPopupTrigger, isVisible
	 
	public void reset() 
	{ 
		contextNode = null;
		copyAction.setContextNode(null);
		popup.removeAll();
		if(popup.isVisible())
			{popup.setVisible(false);}
	} 
 
	//MouseListener methods 
	public void mouseClicked(MouseEvent event)
	{ 
		showPopup(event);
	} 
	public void mouseEntered(MouseEvent event)
	{ 
		showPopup(event);
	} 
	public void mouseExited(MouseEvent event)

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:add, setLayout, setBorder
                VolumeSlider.this.requestFocus();
            } 
        }; 
         
        // Set attributes and add slider. 
        popup.setBorder(BorderFactory.createLineBorder(borderForeground));
        popup.setLayout(new BorderLayout());
        popup.add(this, BorderLayout.CENTER);
         
        return popup;
    } 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 JPopupMenu Methods: