• Post Reply Bookmark Topic Watch Topic
  • New Topic

JToggleButton - pressing and selecting through software

 
Kurt Peters
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I'm pressing a JToggleButton right, but apparently, I'm not, because it doesn't look the same as one clicked on by a mouse.

How can I select and press a togglebutton through a function call -- and additionally, UNSELECT and Unpress it as well.

Here's the code I'm using:

Kurt
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This should do it, but you can always call doClick().
 
Kurt Peters
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll give that a try. While I do, is there a reverse, doclick(), like "unclick()"?
Kurt
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just press doClick again. doClick emulates a user clicking on the button, and that's how a user toggles a toggle button - by clicking on it.

You may want to check its pressed / selected state before clicking to ensure you don't toggle the wrong way.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!