Results 1 to 9 of 9
Thread: Action Listener
- 03-23-2010, 06:00 PM #1
Member
- Join Date
- Mar 2010
- Posts
- 23
- Rep Power
- 0
Action Listener
Sorry I am new to this forum so please tell me how to use code tags.
Following are my code
static JMenuItem c = new JMenuItem("Hye");
public static void one
{
c.addActionListener(null);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == m11)
JOptionPane.showMessageDialog(null,"Hye");
}
My problem is that it is not taking any action even i press any key. Some on told me to add "this" instead of "null", but i cant do it when i have static specifier. Hope you understand and help me.
- 03-23-2010, 07:27 PM #2
Senior Member
- Join Date
- Mar 2010
- Posts
- 266
- Rep Power
- 4
you can do this:
Java Code:c.addActionListener (new ActionListener () { public void actionPerformed(ActionEvent e) { if(e.getSource() == m11) JOptionPane.showMessageDialog(null,"Hye"); } });
- 03-23-2010, 08:21 PM #3
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
Same as any other forum or word processor.Sorry I am new to this forum so please tell me how to use code tags.
You paste your code and then select it. Then you click on a button that looks like it will do what you want.
-
- 03-24-2010, 04:13 PM #5
Member
- Join Date
- Mar 2010
- Posts
- 23
- Rep Power
- 0
Because it is shared by other outer classes. That's Why i kept it static. By the way i have solved my problem , Thanx for the code tags help.
-
Last edited by Fubarable; 03-24-2010 at 09:07 PM.
- 03-25-2010, 04:14 PM #7
Member
- Join Date
- Mar 2010
- Posts
- 23
- Rep Power
- 0
Then how can i share one data type among different running threads simultaneously , Correct me Please if I am wrong. Also Extend your post with reason's.
-
By creating and sharing objects, passing objects as parameters, using design patterns in appropriate situations. That's what OOPS is all about.
How can you do it specifically in your situation? Hard to say without seeing your program structure/UML diagram.
- 03-25-2010, 05:39 PM #9
Member
- Join Date
- Mar 2010
- Posts
- 23
- Rep Power
- 0
Similar Threads
-
Accessing objects from within Action listener
By cog in forum New To JavaReplies: 4Last Post: 12-24-2009, 08:17 PM -
Action Listener? how to use this?
By jeffrey in forum New To JavaReplies: 2Last Post: 10-12-2009, 08:51 AM -
Listener for action "team->commit"
By feva in forum EclipseReplies: 0Last Post: 07-27-2009, 07:40 PM -
action listener on jcombobox
By chkm8 in forum New To JavaReplies: 2Last Post: 02-05-2009, 10:14 AM -
[SOLVED] action listener and Jtextfield
By tOpach in forum AWT / SwingReplies: 4Last Post: 12-16-2008, 01:02 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks