Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

MouseEvent not firing in Obuntu  RSS feed

 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
i have a JMenu

over a JPlane which also have the MouseEvent.
i added a listner like

its calling the method aboutBoxClicked() in Windows XP
but in Ubuntu its not firing this event but its going to panel Mouse event
Why how can i fix this?
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use JMenuItem instead with Actions or ActionListeners.
 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then we cannot use the single Menu itself?

Because its the "About" Application and its not having Help option.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chiru Raj:

Because its the "About" Application and its not having Help option.


What's that got to do with JMenuItem?
You can have a class which extends AbstractAction and pass it in the constructor of JMenuItem. In the actionPerformed you can do whatever stuff you want to do.
 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i used the JMenuItem but its giving lot of space between other jmenu.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chiru Raj:
i used the JMenuItem but its giving lot of space between other jmenu.


Take out the spaces then!

On a more serious note, how do you think people will be able to help you out without seeing your code? Post the relevant code.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are two ways to do this which have already been said but I'm going to try and clear it up a bit.

1. JMenu - You can use a JMenu without any children (JMenuItem's). If you do this you'll need to attach a MenuListener and override its three methods. The one you are concerned with is going to be menuSelected(MenuEvent m). The downside to this is that you will get some UI carnage because it will attempt to show JMenuItem's even though none exist.

2. JMenuItem - If you go this route then simply attach an ActionListener and override its actionPerformed(ActionEvent e) method or attach an AbstractAction implementation to it. The problem with this approach is, as you said, you are going to have extra space. I tried looking for ways to knock it down but couldn't as of yet.

So that sums up your options thus far.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gregg Bolinger:
.. The problem with this approach is, as you said, you are going to have extra space.


Doh! I really don't get it. What is this space problem if you use AbstractAction? I never encountered it before.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Maneesh Godbole:


Doh! I really don't get it. What is this space problem if you use AbstractAction? I never encountered it before.


It has nothing to do with the action. It is the UI. You end up with something like:



Notice the extra space between View and About.
[ August 29, 2008: Message edited by: Gregg Bolinger ]
 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes "Gregg Bolinger" same Problem
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!