/[classpath]/classpath/javax/swing/DefaultButtonModel.java
ViewVC logotype

Diff of /classpath/javax/swing/DefaultButtonModel.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.20 by mark, Sat Jul 2 20:32:46 2005 UTC revision 1.21 by abalkiss, Tue Jul 12 20:19:08 2005 UTC
# Line 318  public class DefaultButtonModel implemen Line 318  public class DefaultButtonModel implemen
318    {    {
319      int oldstate = stateMask;      int oldstate = stateMask;
320      int newstate;      int newstate;
321        boolean toggle = (this instanceof JToggleButton.ToggleButtonModel);
322    
323      if (b)      if (b)
324        newstate = oldstate | stateflag;        newstate = oldstate | stateflag;
# Line 339  public class DefaultButtonModel implemen Line 340  public class DefaultButtonModel implemen
340        {        {
341          fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED,          fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED,
342                                             null, ItemEvent.SELECTED));                                             null, ItemEvent.SELECTED));
343            // If the button is a toggle button then we fire action performed when
344            // the button changes state (selected/deselected), not when it changes
345            // from pressed to unpressed
346            if (toggle)
347              fireActionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
348                                                  actionCommand));
349          if (group != null)          if (group != null)
350            group.setSelected(this, true);            group.setSelected(this, true);
351        }        }
# Line 347  public class DefaultButtonModel implemen Line 354  public class DefaultButtonModel implemen
354        {        {
355          fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED,          fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED,
356                                             null, ItemEvent.DESELECTED));                                             null, ItemEvent.DESELECTED));
357            // If the button is a toggle button then we fire action performed when
358            // the button changes state (selected/deselected), not when it changes
359            // from pressed to unpressed
360            if (toggle)
361              fireActionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
362                                                  actionCommand));
363          if (group != null)          if (group != null)
364            group.setSelected(this, false);            group.setSelected(this, false);
365        }        }
366    
367      else if (((oldstate & ARMED) == ARMED && (oldstate & PRESSED) == PRESSED)      else if (((oldstate & ARMED) == ARMED && (oldstate & PRESSED) == PRESSED)
368               && ((newstate & ARMED) == ARMED && (newstate & PRESSED) == 0))               && ((newstate & ARMED) == ARMED && (newstate & PRESSED) == 0) && (!toggle))
369        fireActionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED,        fireActionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
370                                            actionCommand));                                            actionCommand));
371    }    }

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.21

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26