• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simulate mouse click

 
Harsha Jay
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I simulate a mouse click on JTabbedPane?

similar to the JMenuItem.doClick().

Thanks
 
Craig Wood
Ranch Hand
Pie
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic