I added the font size but it has not changed.

btnUser.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int x = btnUser.getX(); int y = btnUser.getY() + btnUser.getHeight(); JPopupMenu jPopupMenu = new JPopupMenu(); jPopupMenu.setFont(new Font("Tahoma", Font.PLAIN, 20)); jPopupMenu.add(new AbstractAction("Exit") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { System.exit(0); } }); jPopupMenu.show(panel, x, y); } }); 

    2 answers 2

    As far as I remember, popupMenu consists of menuItem and already they can be set to font . Try something like this:

     //... JPopupMenu jPopupMenu = new JPopupMenu(); JMenuItem item; popup.add(item = new JMenuItem("Первый")); item.setFont(new Font("Tahoma", Font.PLAIN, 20)); popup.add(item = new JMenuItem("Второй")); item.setFont(new Font("Arial", Font.PLAIN, 15)); //... 
    • Yes, what you need, thanks. - S. Oleg

    I did it like this.

     JMenuItem mntmExit = new JMenuItem("EXIT"); mntmExit.setFont(new Font("Tahoma", Font.PLAIN, 20)); mntmExit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.exit(0); } }); jPopupMenu.add(mntmExit);