aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JButton action not called Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JButton action not called" Watch "JButton action not called" New topic
Author

JButton action not called

Imran Vohra
Ranch Hand

Joined: Dec 12, 2005
Posts: 77

Hi I have added JButton in my panel. Further I have added actionlistener for that button as well.
My problem is when I click on the button actionPerformed() method is not called. And if I move to that button using keyboard and press space, at that time actionPerformed() method is called.
I am executing the program from Eclipse. I tried with rebuilding, cleaning option of eclipse
Even I restarted eclipse and my machine but could not get rid of this problem
Can anyone help me out?

Thanks
Imran
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> Can anyone help me out?

create a new project
add a button to a frame
add an actionListener to the button
compile run
if it has the same problem, post that code

if it compiles/runs OK, keep adding things until it displays the problem
Imran Vohra
Ranch Hand

Joined: Dec 12, 2005
Posts: 77

Hi
I had created sample application but its working absolutely fine.

Thanks
Imran
Imran Vohra
Ranch Hand

Joined: Dec 12, 2005
Posts: 77

I found something else to add.
Its not only about button action thing.
Even I click on textfield, focus is not coming on textfield.
When I click on combo box, its not showing the values it has
But when I take control from key board its working.

So, with mouse there is some problem in accessing controls but I can access easily with key board.

One more thing, it was working fine earlier and stopped working one day when I start my eclipse.

Thanks
Imran
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
if you're sure it's a program problem, and not that your mouse is erratic i.e. other programs work fine with mouse,
write a small program, just a JFrame with panel, panel with button/textfield and listeners.
make sure it displays the problem you've described, then post that code so we can see/test it.
Imran Vohra
Ranch Hand

Joined: Dec 12, 2005
Posts: 77

I am sure it's not program problem but some other issue. May be some setting issue. Because the same code is working fine on my peer's machine.
I expect some hint from you that what could be wrong on my machine? Like version mismatch or something like that

Thank
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> May be some setting issue

can only help if it's a swing problem
if you think it may be an eclipse issue, perhaps the IDE forum might be worth posting in
if its an OS problem, General Computing might be the Forum
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Imran Vohra wrote:I am sure it's not program problem but some other issue. May be some setting issue. Because the same code is working fine on my peer's machine.
I expect some hint from you that what could be wrong on my machine? Like version mismatch or something like that


My guess: you have a bug in your code. We'll probably be able to give you better help if you can create and post an SSCCE.
Imran Vohra
Ranch Hand

Joined: Dec 12, 2005
Posts: 77

I got the solution
It was JRE version issue.
I was executing project with JRE6 and it was giving me the problem.
Once I change it to JRE5, my problem is solved

Thanks for your help

Thanks
Imran
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
thanks for posting the eventual solution - hopefully others with similar problems will be able to find this thread.

I know I'll point them here if I come across similar sounding problems
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JButton action not called