aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes tray icon Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "tray icon" Watch "tray icon" New topic
Author

tray icon

Domenic Horner
Greenhorn

Joined: Aug 21, 2009
Posts: 2
hey, guys, my first thread here

okay i am tryign to make a tray Menu, and i have somethign like this:

to listen for my actions
as we all know that created another class file called [classname$1.class,

is there any way to make anothher class to deal with the events and implement actionlistner there instead of creating sub-classes?

i tried this but faild


and then this in my other class (that implements actionlistner)


thanks guys

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19722
    
  20

Any class can implement ActionListener, as long as they implement the actionPerformed method. The following (ugly) way is too often used:
However, the ActionListener per, well, action is a lot better.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Domenic Horner
Greenhorn

Joined: Aug 21, 2009
Posts: 2
but is there any way of putting it so that the class does not create a sub-class (cuz its gets messy when you have 10+ listners)
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19722
    
  20

My example code will work without any other classes. However, what do you prefer - 10 if-statements, or 10 classes that are each specialized to do only one single task?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

Please use real words when posting to the forums. Abbreviations such as "coz" in place of "because" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please read this for more information.

thanks,
bear
JavaRanch sheriff

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: tray icon