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

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

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

revision 1.1 by rveldema, Mon Mar 11 15:48:06 2002 UTC revision 1.2 by rveldema, Tue Mar 12 11:36:22 2002 UTC
# Line 10  import java.util.*; Line 10  import java.util.*;
10  import java.beans.*;  import java.beans.*;
11    
12    
13    
14    /**
15     * Provides basic button functionality
16     *
17     * @author Ronald Veldema (rveldema@cs.vu.nl)
18     */
19    
20    
21  public abstract class AbstractButton extends JComponent  public abstract class AbstractButton extends JComponent
22                          implements ItemSelectable, SwingConstants                          implements ItemSelectable, SwingConstants
23  {  {
# Line 94  public abstract class AbstractButton ext Line 102  public abstract class AbstractButton ext
102           *           *
103           ****************/           ****************/
104    
105          ButtonModel getModel()          public ButtonModel getModel()
106          {       return model;    }          {       return model;    }
107          void setModel(ButtonModel newModel)          public void setModel(ButtonModel newModel)
108          {       model = newModel;    }          {       model = newModel;    }
109    
110          String getActionCommand()          public String getActionCommand()
111          {       return getModel().getActionCommand();    }          {       return getModel().getActionCommand();    }
112          void setActionCommand(String aCommand)          public void setActionCommand(String aCommand)
113          {   getModel().setActionCommand(aCommand);   }          {   getModel().setActionCommand(aCommand);   }
114    
115          void addActionListener(ActionListener l)          public void addActionListener(ActionListener l)
116          {       getModel().addActionListener(l);    }          {       getModel().addActionListener(l);    }
117          void removeActionListener(ActionListener l)          public void removeActionListener(ActionListener l)
118          {       getModel().removeActionListener(l);    }          {       getModel().removeActionListener(l);    }
119    
120          void addChangeListener(ChangeListener l)          public void addChangeListener(ChangeListener l)
121          {   getModel().addChangeListener(l);     }          {   getModel().addChangeListener(l);     }
122          void removeChangeListener(ChangeListener l)          public void removeChangeListener(ChangeListener l)
123          {  getModel().removeChangeListener(l);    }          {  getModel().removeChangeListener(l);    }
124    
125          public void addItemListener(ItemListener l)          public void addItemListener(ItemListener l)
# Line 119  public abstract class AbstractButton ext Line 127  public abstract class AbstractButton ext
127          public void removeItemListener(ItemListener l)          public void removeItemListener(ItemListener l)
128          {  getModel().removeItemListener(l);  }          {  getModel().removeItemListener(l);  }
129    
130          int getHorizontalAlignment()          public int getHorizontalAlignment()
131          {       return hori_align;    }          {       return hori_align;    }
132          int getHorizontalTextPosition()          public int getHorizontalTextPosition()
133          {       return hori_text_pos;    }          {       return hori_text_pos;    }
134          int getVerticalAlignment()          public int getVerticalAlignment()
135          {       return vert_align;   }          {       return vert_align;   }
136          int getVerticalTextPosition()          public int getVerticalTextPosition()
137          {       return vert_text_pos;  }          {       return vert_text_pos;  }
138    
139    
# Line 136  public abstract class AbstractButton ext Line 144  public abstract class AbstractButton ext
144          protected void fireActionPerformed(ActionEvent event)          protected void fireActionPerformed(ActionEvent event)
145          {       getModel().fireActionPerformed(event);    }          {       getModel().fireActionPerformed(event);    }
146    
147          void setVerticalAlignment(int alignment)          public void setVerticalAlignment(int alignment)
148          {       vert_align = alignment;    }          {       vert_align = alignment;    }
149          void setHorizontalAlignment(int alignment)          public void setHorizontalAlignment(int alignment)
150          {   hori_align = alignment;   }          {   hori_align = alignment;   }
151          void setVerticalTextPosition(int textPosition)          public void setVerticalTextPosition(int textPosition)
152          {       vert_text_pos = textPosition;    }          {       vert_text_pos = textPosition;    }
153          void setHorizontalTextPosition(int textPosition)          public void setHorizontalTextPosition(int textPosition)
154          {   hori_text_pos = textPosition;   }          {   hori_text_pos = textPosition;   }
155    
156          int getMnemonic()          public int getMnemonic()
157          {       return getModel().getMnemonic();    }          {       return getModel().getMnemonic();    }
158          void setMnemonic(char mne)          public void setMnemonic(char mne)
159          {       getModel().setMnemonic(mne);    }          {       getModel().setMnemonic(mne);    }
160          void setMnemonic(int mne)          public void setMnemonic(int mne)
161          {       getModel().setMnemonic(mne);    }          {       getModel().setMnemonic(mne);    }
162    
163          void setRolloverEnabled(boolean b)          public void setRolloverEnabled(boolean b)
164          {    getModel().setRollover(b);    }          {    getModel().setRollover(b);    }
165          boolean isRolloverEnabled()          public boolean isRolloverEnabled()
166          {    return getModel().isRollover();     }          {    return getModel().isRollover();     }
167    
168    
169          boolean isBorderPainted()          public boolean isBorderPainted()
170          {       return paint_border;    }          {       return paint_border;    }
171          void setBorderPainted(boolean b)          public void setBorderPainted(boolean b)
172          {          {
173                  if (b != paint_border)                  if (b != paint_border)
174                  {                  {
# Line 170  public abstract class AbstractButton ext Line 178  public abstract class AbstractButton ext
178                  }                  }
179          }          }
180    
181          Action getAction()          public Action getAction()
182          {       return action_taken;    }          {       return action_taken;    }
183          void setAction(Action a)          public void setAction(Action a)
184          {          {
185                  action_taken = a;                  action_taken = a;
186                  revalidate();                  revalidate();
187                  repaint();                  repaint();
188          }          }
189    
190          void setSelected(boolean b)          public void setSelected(boolean b)
191          {       getModel().setSelected(b);    }          {       getModel().setSelected(b);    }
192          boolean isSelected()          public boolean isSelected()
193          {       return getModel().isSelected();     }          {       return getModel().isSelected();     }
194    
195    
196          Icon getIcon()          public Icon getIcon()
197          {       return default_icon;    }          {       return default_icon;    }
198          void setIcon(Icon defaultIcon)          public void setIcon(Icon defaultIcon)
199          {          {
200                  if (default_icon == defaultIcon)                  if (default_icon == defaultIcon)
201                          return;                          return;
# Line 201  public abstract class AbstractButton ext Line 209  public abstract class AbstractButton ext
209                  repaint();                  repaint();
210          }          }
211    
212          String getText()          public String getText()
213          {       return text;    }          {       return text;    }
214          void setLabel(String label)          public void setLabel(String label)
215          {       setText(label);    }          {       setText(label);    }
216          String getLabel()          public String getLabel()
217          {       return getText();    }          {       return getText();    }
218          void setText(String text)          public void setText(String text)
219          {          {
220                  this.text = text;                  this.text = text;
221                  revalidate();                  revalidate();
# Line 215  public abstract class AbstractButton ext Line 223  public abstract class AbstractButton ext
223          }          }
224    
225    
226          Insets getMargin()          public  Insets getMargin()
227          {      return margin; }          {      return margin; }
228          void setMargin(Insets m)          public void setMargin(Insets m)
229          {          {
230                  margin = m;                  margin = m;
231                  revalidate();                  revalidate();
# Line 231  public abstract class AbstractButton ext Line 239  public abstract class AbstractButton ext
239                  repaint();                  repaint();
240          }          }
241    
242          Icon getPressedIcon()          public Icon getPressedIcon()
243          {       return pressed_button;    }          {       return pressed_button;    }
244          void setPressedIcon(Icon pressedIcon)          public void setPressedIcon(Icon pressedIcon)
245          {          {
246                  pressed_button = pressedIcon;                  pressed_button = pressedIcon;
247                  revalidate();                  revalidate();
# Line 241  public abstract class AbstractButton ext Line 249  public abstract class AbstractButton ext
249          }          }
250    
251    
252          Icon getDisabledIcon()          public Icon getDisabledIcon()
253          {       return disabled_button;    }          {       return disabled_button;    }
254          void setDisabledIcon(Icon disabledIcon)          public void setDisabledIcon(Icon disabledIcon)
255          {          {
256                  disabled_button = disabledIcon;                  disabled_button = disabledIcon;
257                  revalidate();                  revalidate();
# Line 320  public abstract class AbstractButton ext Line 328  public abstract class AbstractButton ext
328          }          }
329    
330    
331          void doClick()          public void doClick()
332          {          {
333                  doClick(100);                  doClick(100);
334          }          }
335          void doClick(int pressTime)          public void doClick(int pressTime)
336          {          {
337                  Toolkit.tlkBeep ();              //Toolkit.tlkBeep ();
338                  //Programmatically perform a "click".                  //Programmatically perform a "click".
339          }          }
340    
341    
342          Icon getDisabledSelectedIcon()          public Icon getDisabledSelectedIcon()
343          {          {
344                  //Returns the icon used by the button when it's disabled and selected.                  //Returns the icon used by the button when it's disabled and selected.
345                  return disabled_selected_button;                  return disabled_selected_button;
346          }          }
347    
348    
349          Icon getRolloverIcon()          public Icon getRolloverIcon()
350          {          {
351                  //       Returns the rollover icon for the button.                  //       Returns the rollover icon for the button.
352                  return null;                  return null;
# Line 369  public abstract class AbstractButton ext Line 377  public abstract class AbstractButton ext
377                  return current_icon == img;                  return current_icon == img;
378          }          }
379    
380          boolean isContentAreaFilled()          public boolean isContentAreaFilled()
381          {          {
382                  //       Checks whether the "content area" of the button should be filled.                  //       Checks whether the "content area" of the button should be filled.
383                  return false;                  return false;
# Line 390  public abstract class AbstractButton ext Line 398  public abstract class AbstractButton ext
398          }          }
399    
400    
401          void setContentAreaFilled(boolean b)          public void setContentAreaFilled(boolean b)
402          {          {
403                  //Sets whether the button should paint the content area or leave it transparent.                  //Sets whether the button should paint the content area or leave it transparent.
404          }          }
405    
406    
407          void setDisabledSelectedIcon(Icon disabledSelectedIcon)          public void setDisabledSelectedIcon(Icon disabledSelectedIcon)
408          {          {
409                  //          Sets the disabled selection icon for the button.                  //          Sets the disabled selection icon for the button.
410          }          }
411    
412          void setRolloverIcon(Icon rolloverIcon)          public void setRolloverIcon(Icon rolloverIcon)
413          {          {
414                  //       Sets the rollover icon for the button.                  //       Sets the rollover icon for the button.
415          }          }
416          void setRolloverSelectedIcon(Icon rolloverSelectedIcon)          public void setRolloverSelectedIcon(Icon rolloverSelectedIcon)
417          {          {
418                  //       Sets the rollover selected icon for the button.                  //       Sets the rollover selected icon for the button.
419          }          }
420    
421    
422          void setSelectedIcon(Icon selectedIcon)          public void setSelectedIcon(Icon selectedIcon)
423          {          {
424                  //       Sets the selected icon for the button.                  //       Sets the selected icon for the button.
425          }          }
# Line 422  public abstract class AbstractButton ext Line 430  public abstract class AbstractButton ext
430                  super.setUI(ui);                  super.setUI(ui);
431          }          }
432    
433          ButtonUI getUI()          public ButtonUI getUI()
434          {          {
435                  //Returns the L&F object that renders this component.                  //Returns the L&F object that renders this component.
436                  return (ButtonUI) ui;                  return (ButtonUI) ui;
437          }          }
438    
439          void updateUI()          public void updateUI()
440          {          {
441                  /*                  /*
442                    //          Notification from the UIFactory that the L&F has changed.                    //          Notification from the UIFactory that the L&F has changed.

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

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