Event « Menu « Java Swing Q&A





1. JPopupMenu getParent() returning a null?    stackoverflow.com

Ok so I'm working on an Eclipse plugin based on the JGraph example. The problem is I can't really get the "save" method to work, here's how the program works in ...

2. How do I implement a good game menu in Java?    stackoverflow.com

I have been working on a Java game for a while that I started back in my college days. After taking considerable breaks due to my professional career, I'm getting back ...

3. Java GUI Menu Issues    stackoverflow.com

statCl.addActionListener(new ActionListener(){
        public void actionPerformed (ActionEvent e) {
            try {
    ...

4. Add functionality to a menu button in java    stackoverflow.com

I am new to Java and I was wondering how to add functionality to menu item?
What I would like it to do, is to set two values to 0. This is the ...

5. Java unable to open pdf using Runtime    stackoverflow.com

I have to open a pdf on clicking a JMenuItem. I can open the pdf on click the menu item if i run my program from netbeans. But when i run ...

6. Getting notified when a JMenu is opened? (eg: File, Edit, View)    stackoverflow.com

What I want to do is, when my Edit JMenu is clicked on, before it appears I want to set enabled on the undo / redo commands based on whether or ...

7. Swing menus not going away after actionPerformed()    coderanch.com

Dear Lola, yes, we have encountered this problem quite often and the cause we found out was the jre used during runtime, would not be jre1.3 but instead a lower version. Hence ensure that the path variable points to and picks up the jre1.3 version. Swing components work fine with jre1.3 and this problem occurs with lower jre versions. You can ...

8. Menu Events    coderanch.com

hi friends, i have doubt on how to give a events to the menu driven applications. Example: in File MenuBar haveing New,Open,Save,SaveAs,Exit Menus. suppose i want to save my typed informations which is available in a textarea . hear how i can get that Save DialogBox and how to get a file name which is typed in the textfield. After that ...

9. Handling menu events    coderanch.com

Prudent, Couple of things: 1. You can do it by saving the file name in a member variable in the class and modifying the code like: private String fileName = null; //..... FileDialog fd2 = null; if(fileName == null) { fd2 = new FileDialog (this, "Save file", FileDialog.SAVE); } FileWriter fw; if(ae.getActionCommand().equals("Save")) { fd2.setVisible(true); String st,sn; try { if(fileName == null) ...





10. adding actionlistener to jmenu    coderanch.com

11. How to use menu event    coderanch.com

Hi i am a basic leaner in java. Anyone please help me how can i change the colour when i choose the coloritem from menubar. May be my OOPs comcept is wrong. But i should keep 4 different programs. Please tell me how i have to use the OOP concept to keep 4 programs and do this work. My 4 programes ...

12. How to get parent frame of a JMenuItem (or its ActionListener)    coderanch.com

Something I generally do in my applications is keep an instance of my main window in a static instance class. I usually just call this Application so that I can do things like: Application.getInstance().getMainFrame() I use it for all sorts of application wide data that I need so that I don't have to pass objects around as much. It also is ...

13. Menu Item Event    coderanch.com

14. JMenu and ActionListener    java-forums.org

15. ActionListener for Menu Items    java-forums.org

import java.awt.*; import javax.swing.*; public class fileMenu extends JMenu { public static JMenuItem n; // New public static JMenuItem o; // Open public static JMenuItem s; // Save public static JMenuItem sa; // Save As public static JMenuItem e; // Exit public fileMenu() { super("File"); n = new JMenuItem("New"); add(n); o = new JMenuItem("Open"); add(o); addSeparator(); s = new JMenuItem("Save"); add(s); ...

16. jMenu - actionListeners    forums.oracle.com

Does your code compile? Ie have you figured out the final business? Any way, another approach might be to recognise that a JMenuItem IS-A button. So it has an "action command" with methods to [set|http://java.sun.com/javase/6/docs/api/javax/swing/AbstractButton.html#setActionCommand(java.lang.String)] and [get|http://java.sun.com/javase/6/docs/api/javax/swing/AbstractButton.html#getActionCommand()] this command. The command (just a string) could be set when you create the JMenuItem and that way all the menu items could share ...





17. Get JFrame from JMenuItem's ActionListener    forums.oracle.com

Hi all, I have a bit difficulty with swing package. I have JFrame, that is composed from JMenuBar, JMenu, and JMenuItem. I want to separate the GUI creation (the view), and its handler (the controller). So, the JMenuItem's ActionListener is assigned in different class that contains no information about JFrame. My question is : How do I know the JMenuItem's JFrame ...