Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Methods of JButton  RSS feed

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where should I look for the methods of a JButton that control Pressed, released, clicked, etc painting?
Are they part of the JButton class, JComponent, Component???
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what about clicking through the API and reading the source?
setSelected(), isSelected() control the pressed state of a button. the graphical reflection of a jbutton (not radio or checkbox) is more or less a label with two special borders that depend on the selection state. there are methods isBorderPainted(), setBorderPainted in AbstractButton.
I don't think there are any more methods that tell you whether the button is actually pressed at the moment. that is of no interest to the button, you would have to catch the mouse event to know about that.
what exactly do you want to do?
chantal
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am actually trying to find out the methods that get called through the entire click process.
I want to start making some custom components and I have been through all the options I have for doing so except digging deep into the components methods to see how they are drawn by default. I overroad the paint() method of the JButton and drew my own button but when I click it, strange things happened with the painting. So basically I am just bored and like to tear things apart. Ha.
Thanks for your help though.
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a little help might provide:

I found this method quite usefull while reflection does not provide any means to find out what object called the current method.
In your case, IMHO code digging, copy+pasting seems the best. I've done that lately for some custom JTables and it's quite enlightening (or, well, whatever...)
Chantal
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thread.dumpStack() proved very helpful, but now I need some source code.
What JAR file includes all the JAVA source code for SWING components, AWT Components, etc. When I installed the JDK, I had include source checked so that it got installed. I just don't know where it is.
Thanks.
 
Josh Rehman
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The classes are generally in rt.jar, and the source usually comes in a zip file.
JButton is deep in the hierarchy, but a lot of what your looking for appears to be in AbstractButton.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!