I'm trying to create a sub-class of the JButton component that will enable or disable itself based on a condition (which looks like below)
public interface Condition {
public static final Condition TRUE = new Condition() {
public boolean test() {
return true;
} };
public static final Condition FALSE = new Condition() {
public boolean test() {
return false;
} };
public boolean test();
}
However, the JButton code is all based on the actual boolean value stored privately in the JButton class. My question is: which method of JButton can be overridden to update its stored isEnabled boolean (via setEnabled(boolean))? Would it be update(Graphics)? or repaint()? OR some other function?
Edit: Realized that what I'm trying to create is actually impossible, unless you have a separate thread that waits short periods of time and forces the button to check its status (which is gross and I don't want to do that). The fact is, buttons are reactive only. It would be possible to accomplish this with some overhead by whoever uses the button class, but at that point it'd be easier to just write listeners on whatever is actually changing and toggle the button at that point. Woops.