It's not a secret anymore!
The moose likes Swing / AWT / SWT and the fly likes Simulate mouse click Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Simulate mouse click" Watch "Simulate mouse click" New topic

Simulate mouse click

Harsha Jay
Ranch Hand

Joined: Jul 23, 2001
Posts: 177
Can I simulate a mouse click on JTabbedPane?

similar to the JMenuItem.doClick().

Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
doClick causes the "clicked-on" component to generate an ActionEvent. So the component
must have a way to generate ActionEvents for this to work. Actually, doClick is a method of
AbstractButton. You can find this out by following the Index link at the top of any page
in the javadocs and looking the method up in the index; it lists the classes that have a
doClick method.
The JTabbedPane class does not have any methods that support ActionEvents. It uses a
ChangeListener to listen for tab selections. And it has a method for setting the selected
index. You could use this to programatically make tab selections:
edit: Correct illogical statement.
[ April 13, 2007: Message edited by: Craig Wood ]
Harsha Jay
Ranch Hand

Joined: Jul 23, 2001
Posts: 177
yeah, I thought of that, but never mind, I figured out other way to meet the requirement. I spent little time on this anyways.. alls well for the weekend. I really appreciate your reply and your time
I agree. Here's the link:
subject: Simulate mouse click
It's not a secret anymore!