MenuItem « Menu « Java Swing Q&A





1. How can I determine which menu item called an ActionListener?    stackoverflow.com

I have a Java program where I have a JMenu with an arbitrary number of items (in this case, there is one menu item for each dynamic library currently loaded in ...

2. How to deactivate a method for a specific menuItem?    stackoverflow.com

I want to check somehow which MenuItem was selected, so that for some menu buttons to draw a grid in a different way. I have the menu created in the package view, ...

3. JMenuItem problem. I have five. One of them compiles with no problem. The others are identical, yet they refuse to compile    stackoverflow.com

for some reason, I am unable to compile this in Eclipse. The "quit" menuItem works and no other menuItem works. Why is that?

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class GUI{

private JFrame frame;

public GUI(){
 ...

4. How to detect mouse click on menuItem when added via addMouseListener    stackoverflow.com

Consider you want to close your java application using "Close application" menu item. 3 possible solutions are (using ActionListener or MouseAdapter or MouseListener):

menuItemClose.addActionListener(new ActionListener() {

    @Override
    ...

5. how to write functions for MenuItems    coderanch.com

8. Integrating menuItem and JButton    coderanch.com

class MyFrame extends JFrame { private Action a = getAction(); /// some action object private JCheckboxMenuItem mItem = new JCheckboxMenuItem("Menu"); private JToolBar toolBar = new JToolBar("toolbar"); public MyFrame(){ toolbar.add(a); } } My question is that is there anyway to fire action object when menuItem's state is changed? The menuItem and toolbar button for that action perform same task so they must ...





11. MenuItem    coderanch.com

12. How to remove menuitem from context menu (SWT)    coderanch.com

hi everybody can someone tell me how i can remove a menuitem from a context menu or even better how i can clear all items from a menu (like resetting the menu). i couldn't find any remove method or so. depending on the selected item i want different entries in my context menu. any ideas? regards

13. Have all menuitems in own class    coderanch.com

import java.awt.*; import javax.swing.*; class MyFrame extends JFrame { public MyFrame() { setTitle(""); setSize(500,300); setLocationRelativeTo(null); setJMenuBar(new MyMenuBar()); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable(){ public void run(){ new MyFrame().setVisible(true); } }); } } class MyMenuBar extends JMenuBar { public MyMenuBar() { JMenu fileMenu = new JMenu("File"); fileMenu.add(new JMenuItem("Open")); add(fileMenu); } }

14. menuitems    coderanch.com

15. How to add different menuitems to child node    coderanch.com

Hi All, I have 2 Swing files 1 is Sync7000_SubChildConfTool.java (main file) and 2nd file is SerialPortSubChild.java. After running the main file SYNC7000 (root node) will display. If i right click on this root node i am getting 4 menu items (Add Serial Channel, Add Optical Channel, Add TCP/UDP Channel, Add Modem Channel) in popup. If i right click on that ...

16. JDesktopPane creates inner frame menuItem actionPerformed does not.    coderanch.com

Hello could someone help me figure out how to make my menu item work? It calls createFrame() to add an additional inner frame. It runs but nothing is added to the JDesktopPane. /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package application1; import guide.Guide; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Toolkit; ...





17. Regarding MenuItem    coderanch.com

18. How to set Icon on MenuItem    coderanch.com

19. MenuItem eventhandling    coderanch.com

20. Strange MenuItem Behaviour    coderanch.com

When resetting text in my JMenuItem there seems to be white space at the end of the text, even though I have not included it in the text itself. The text starts out alright, it is changed to suit the function, but when changed back to the default menuitem text, it seems longer than the origianl. I have tried using revalidate() ...

21. MenuItem font setting    coderanch.com

Thanks for the responses, The given links contain, the exact problem i am facing. I have expected the swing version of tray icon in jdk7. After the release of JDK7 i have searched javadocs interestingly for that component. Here my application perfectly runs in ubuntu linux with all unicode characters displaying. But of course the look and feel is motif, so ...

22. jmenubar,menuitem    coderanch.com

Michael Dunn wrote:> sir i have a problem probably just me, but your desciption gives me no idea what the problem is. if you post your code and explain what it does do vs what you want it to do, we/i might get a better grasp of the problem. ok sir just wait i am sending my code package hospital; import ...

23. How to add different menuitems to child node    java-forums.org

09-11-2009 12:39 PM #1 sudhakar.cheru Member Join Date Sep 2009 Posts 2 Rep Power 0 How to add different menuitems to child node Hi All, I have 2 Swing files 1 is Sync7000_SubChildConfTool.java (main file) and 2nd file is SerialPortSubChild.java (it has only 5 ComboBox fields and ok and cancel button). After running the main file SYNC7000 (root node) ...

24. How to create ActionListners for dynamically created MenuItem?    java-forums.org

Hi Friends, I have to create menuitems dynamacally. I need help regaurding with how to create actionlistner for this menu item. my code is for (int i = 0; i < scanEntryList.size(); i++) { scanTmpl = (Notice) scanEntryList.get(i); //String senderid = scanTmpl.senderId; notices = new MenuItem(scanTmpl.senderId + ":" + scanTmpl.subject); ActionListener actionOnNoticeListner = new ActionListener() { public void actionPerformed(ActionEvent e) { ...

25. How to enable MenuItem Onclicking handeling in this case    java-forums.org

public class test extends Frame implements ActionListener { public static void main(String[] args) {new test();} test() { super("Rubik's Cube"); MenuBar mb; Menu m1; MenuItem mi1_1,mi1_2,mi1_3; addWindowListener(new WindowAdapter() {public void windowClosing( WindowEvent e){System.exit(0);}}); //Build the menu bar mb = new MenuBar(); setMenuBar(mb); //Build menus in the menu bar m1 = new Menu("Menu 1"); mb.add(m1); mi1_1 = new MenuItem("initialise"); m1.add(mi1_1); mi1_2 = new ...

26. user enable MenuItem    java-forums.org

Hi, guys! I'm programming to solve a 3X3 Rubik's Cube using Evolutionary Algorithm. Now there's another problem with GUI. I want to enable MenuItem mi1_3 (back) after MenuItem mi1_1(initialise) is clicked. Thanks! The structure of my program: Java Code: public class test extends Frame implements ActionListener { public static void main(String[] args) {new test();} test() { super("Rubik's Cube"); AnimCube obj = ...

27. Connect MenuItem to status bar text    java-forums.org

Hi all, I have an application with a JMenuBar. To every MenuItem I added a MouseListener that will change the status bar text to show a description of the MenuItem. I'd like to have this behavior also when navigating the menu with the keyboard. I have no idea how to do it as a KeyListener won't provide the functionality needed. Your ...