Re: how do I veto a setSelected() on JCheckBox
- From: Knute Johnson <nospam@xxxxxxxxxxxxxxxxx>
- Date: Fri, 24 Feb 2006 09:20:40 -0800
rob wrote:
Hello all, I am confused as to how to do this?
I would like the change to veto a setSelected
when the event happens but not sure how to go about this.
If I am in the actionPerformed of a JCheckBox, I guess
at that point it is to late to veto right? I would liek to check
some business logic before allowing the check to take place
by using contstrained properties.
I was thinking I would have define my own checkbox like
MyVetoableCheckBox extends JCheckBox
{
void public setSelected(booleand b) { setVetableSelected(b); }
void public setVetableSelected(boolean b) throws
ProvertyVetoException
{
if( some business logic tells me not to allow the check )
{
Boolean oldValue = isSelected ? Boolean.TRUE : Boolean.FALSE;
Boolean newValue = selected ? Boolean.TRUE : Boolean.FALSE;
fireVetoableChange("selected", oldValue, newValue);
}
else
{
super.setSelected(b);
}
}
am I even approaching this right?
Another option to consider is to disable the check box if it is not a valid time to check it.
--
Knute Johnson
email s/nospam/knute/
.
- Follow-Ups:
- References:
- Prev by Date: Re: how do I veto a setSelected() on JCheckBox
- Next by Date: Writing to a file and a TextArea
- Previous by thread: Re: how do I veto a setSelected() on JCheckBox
- Next by thread: Re: how do I veto a setSelected() on JCheckBox
- Index(es):
Relevant Pages
|