Board index » jbuilder » Enable and disable in ComboDelegateAction failed!

Enable and disable in ComboDelegateAction failed!


2003-12-01 10:20:13 AM
jbuilder19
I am going to do a toolbar that will follow some other action to make
toolbar button become enable or disable.
updateaction is woke fine.
but ComboDelegateAction can not work properly.
i set the enable and disable inside the update method. Is that any thing
wrong?
Each time after it become disable, it cannot enable again whatever i set
enable to true.
public void update(Object arg0) {
if (isshow()) {
setEnabled(false);
} else {
setEnabled(true);
}
}
Thx
 
 

Re:Enable and disable in ComboDelegateAction failed!

Seems like it should work though your implemented logic
seems reversed. Try something like:
public void update(Object source) {
Browser browser = Browser.findBrowser(source);
setEnabled(browser.getActiveNode() != null);
System.out.println("enabled " + isEnabled());
}
Now see if it becomes enabled with there is a file open, and
disabled when no files are open.
"Micky_sun" < XXXX@XXXXX.COM >wrote in message
I am going to do a toolbar that will follow some other
action to make
toolbar button become enable or disable.
updateaction is woke fine.
but ComboDelegateAction can not work properly.
i set the enable and disable inside the update method. Is
that any thing
wrong?
Each time after it become disable, it cannot enable again
whatever i set
enable to true.
public void update(Object arg0) {
if (isshow()) {
setEnabled(false);
} else {
setEnabled(true);
}
}
Thx
 

Re:Enable and disable in ComboDelegateAction failed!

Not work too... i am using JB9
"Bill Joy" < XXXX@XXXXX.COM >wrote in message
Quote
Seems like it should work though your implemented logic
seems reversed. Try something like:

public void update(Object source) {
Browser browser = Browser.findBrowser(source);
setEnabled(browser.getActiveNode() != null);
System.out.println("enabled " + isEnabled());
}

Now see if it becomes enabled with there is a file open, and
disabled when no files are open.


"Micky_sun" < XXXX@XXXXX.COM >wrote in message
news:3fcaa52b$ XXXX@XXXXX.COM ...
I am going to do a toolbar that will follow some other
action to make
toolbar button become enable or disable.

updateaction is woke fine.
but ComboDelegateAction can not work properly.
i set the enable and disable inside the update method. Is
that any thing
wrong?
Each time after it become disable, it cannot enable again
whatever i set
enable to true.

public void update(Object arg0) {
if (isshow()) {
setEnabled(false);
} else {
setEnabled(true);
}
}


Thx



 

{smallsort}

Re:Enable and disable in ComboDelegateAction failed!

What about the output?
Are you seeing it constantly being output and did it report
true or false matching the expected state as you
opened/closed a file?
If the above checks out, then I would just use the de{*word*81}
and step into the setEnabled() and see if it is working when
the state changes. Another approach would be to override
some AbstractAction methods to make sure things are hooked
up correctly:
static int counter;
public synchronized void
addPropertyChangeListener(PropertyChangeListener listener) {
super.addPropertyChangeListener(listener);
counter++;
}
public synchronized void
removePropertyChangeListener(PropertyChangeListener
listener) {
super.removePropertyChangeListener(listener);
counter--;
}
protected void firePropertyChange(String propertyName,
Object oldValue, Object newValue) {
System.out.println("firing " + propertyName + " " +
newValue + " listeners=" + counter);
super.firePropertyChange(propertyName, oldValue,
newValue);
}
ActionCombo should be listening for property changes and
enabling itself based on the "enabled" property of your
ComboDelegateAction.
"Micky_sun" < XXXX@XXXXX.COM >wrote in message
Not work too... i am using JB9
"Bill Joy" < XXXX@XXXXX.COM >wrote in message
Quote
Seems like it should work though your implemented logic
seems reversed. Try something like:

public void update(Object source) {
Browser browser = Browser.findBrowser(source);
setEnabled(browser.getActiveNode() != null);
System.out.println("enabled " + isEnabled());
}

Now see if it becomes enabled with there is a file open,
and
disabled when no files are open.


"Micky_sun" < XXXX@XXXXX.COM >wrote in message
news:3fcaa52b$ XXXX@XXXXX.COM ...
I am going to do a toolbar that will follow some other
action to make
toolbar button become enable or disable.

updateaction is woke fine.
but ComboDelegateAction can not work properly.
i set the enable and disable inside the update method. Is
that any thing
wrong?
Each time after it become disable, it cannot enable again
whatever i set
enable to true.

public void update(Object arg0) {
if (isshow()) {
setEnabled(false);
} else {
setEnabled(true);
}
}


Thx



 

Re:Enable and disable in ComboDelegateAction failed!

i found th problem..
i have set the enable to false;
but the output of isEnable() still return true.
SO i just override isEnable is ok now. thx
"Bill Joy" < XXXX@XXXXX.COM >wrote in message
Quote
What about the output?

Are you seeing it constantly being output and did it report
true or false matching the expected state as you
opened/closed a file?

If the above checks out, then I would just use the de{*word*81}
and step into the setEnabled() and see if it is working when
the state changes. Another approach would be to override
some AbstractAction methods to make sure things are hooked
up correctly:

static int counter;

public synchronized void
addPropertyChangeListener(PropertyChangeListener listener) {
super.addPropertyChangeListener(listener);
counter++;
}

public synchronized void
removePropertyChangeListener(PropertyChangeListener
listener) {
super.removePropertyChangeListener(listener);
counter--;
}

protected void firePropertyChange(String propertyName,
Object oldValue, Object newValue) {
System.out.println("firing " + propertyName + " " +
newValue + " listeners=" + counter);
super.firePropertyChange(propertyName, oldValue,
newValue);
}

ActionCombo should be listening for property changes and
enabling itself based on the "enabled" property of your
ComboDelegateAction.


"Micky_sun" < XXXX@XXXXX.COM >wrote in message
news:3fcabf56$ XXXX@XXXXX.COM ...
Not work too... i am using JB9

"Bill Joy" < XXXX@XXXXX.COM >wrote in message
news:3fcab257$ XXXX@XXXXX.COM ...
>Seems like it should work though your implemented logic
>seems reversed. Try something like:
>
>public void update(Object source) {
>Browser browser = Browser.findBrowser(source);
>setEnabled(browser.getActiveNode() != null);
>System.out.println("enabled " + isEnabled());
>}
>
>Now see if it becomes enabled with there is a file open,
and
>disabled when no files are open.
>
>
>"Micky_sun" < XXXX@XXXXX.COM >wrote in message
>news:3fcaa52b$ XXXX@XXXXX.COM ...
>I am going to do a toolbar that will follow some other
>action to make
>toolbar button become enable or disable.
>
>updateaction is woke fine.
>but ComboDelegateAction can not work properly.
>i set the enable and disable inside the update method. Is
>that any thing
>wrong?
>Each time after it become disable, it cannot enable again
>whatever i set
>enable to true.
>
>public void update(Object arg0) {
>if (isshow()) {
>setEnabled(false);
>} else {
>setEnabled(true);
>}
>}
>
>
>Thx
>
>
>