Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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
Author

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().

Thanks
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:
tabbedPane.setSelectedIndex(index);
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: http://aspose.com/file-tools
 
subject: Simulate mouse click
 
Similar Threads
test automatization of menu based midlets
How to trigger a mouse event with out MouseListener
Simulating a click on chkbox
click the mouse in a coordinate
Making a mouse click in Java?