JButton problem

is it possible to check if a button is click in the paintComponent()? eg. if(leftButton.isSelected()){System.out.println("yeah"); }or it can only be checked in the ActionPerformed().
[231 byte] By [blura] at [2007-11-26 15:58:16]
# 1
Why don't you try it and see what happens?
es5f2000a at 2007-7-8 22:19:18 > top of Java-index,Desktop,Core GUI APIs...
# 2
i tried it already. but nothing happened. however, i not sure is becos of my coding or becos it doesn't work this way.
blura at 2007-7-8 22:19:18 > top of Java-index,Desktop,Core GUI APIs...
# 3
post your code, and please use the code tags when you do (as described here: http://forum.java.sun.com/help.jspa?sec=formatting )
macrules2a at 2007-7-8 22:19:18 > top of Java-index,Desktop,Core GUI APIs...
# 4

> i tried it already. but nothing happened. however, i not sure is becos

> of my coding or becos it doesn't work this way.

So post the code you tried so we can see if there are any obvious mistakes. Don't make use guess what your did.

When you press down a the mouse button a mousePressed event is generated which causes the button look to change to a pressed state. This means that the paintComponent() event for the button must be invoked. So the answer would be yes.

Although maybe what you are really trying to do is:

System.out.println(getModel().isArmed());

camickra at 2007-7-8 22:19:18 > top of Java-index,Desktop,Core GUI APIs...
# 5
Please spell out words fully.It is possible in theory. As macrules2 says, you should postan sscce.
es5f2000a at 2007-7-8 22:19:18 > top of Java-index,Desktop,Core GUI APIs...