1 |
/* JLabel.java -- |
/* JLabel.java -- |
2 |
Copyright (C) 2002, 2004 Free Software Foundation, Inc. |
Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
92 |
private transient int iconTextGap = 4; |
private transient int iconTextGap = 4; |
93 |
|
|
94 |
/** |
/** |
|
* Fired in a PropertyChangeEvent when the "disabledIcon" property changes. |
|
|
*/ |
|
|
public static final String DISABLED_ICON_CHANGED_PROPERTY = "disabledIcon"; |
|
|
|
|
|
/** |
|
|
* Fired in a PropertyChangeEvent when the "displayedMnemonic" property |
|
|
* changes. |
|
|
*/ |
|
|
public static final String DISPLAYED_MNEMONIC_CHANGED_PROPERTY = "displayedMnemonic"; |
|
|
|
|
|
/** |
|
|
* Fired in a PropertyChangeEvent when the "displayedMnemonicIndex" property |
|
|
* changes. |
|
|
*/ |
|
|
public static final String DISPLAYED_MNEMONIC_INDEX_CHANGED_PROPERTY = "displayedMnemonicIndex"; |
|
|
|
|
|
/** |
|
|
* Fired in a PropertyChangeEvent when the "horizontalAlignment" property |
|
|
* changes. |
|
|
*/ |
|
|
public static final String HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY = "horizontalAlignment"; |
|
|
|
|
|
/** |
|
|
* Fired in a PropertyChangeEvent when the "horizontalTextPosition" property |
|
|
* changes. |
|
|
*/ |
|
|
public static final String HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY = "horizontalTextPosition"; |
|
|
|
|
|
/** Fired in a PropertyChangeEvent when the "icon" property changes. */ |
|
|
public static final String ICON_CHANGED_PROPERTY = "icon"; |
|
|
|
|
|
/** Fired in a PropertyChangeEvent when the "iconTextGap" property changes. */ |
|
|
public static final String ICON_TEXT_GAP_CHANGED_PROPERTY = "iconTextGap"; |
|
|
|
|
|
/** Fired in a PropertyChangeEvent when the "labelFor" property changes. */ |
|
|
public static final String LABEL_FOR_CHANGED_PROPERTY = "labelFor"; |
|
|
|
|
|
/** Fired in a PropertyChangeEvent when the "text" property changes. */ |
|
|
public static final String TEXT_CHANGED_PROPERTY = "text"; |
|
|
|
|
|
/** |
|
|
* Fired in a PropertyChangeEvent when the "verticalAlignment" property |
|
|
* changes. |
|
|
*/ |
|
|
public static final String VERTICAL_ALIGNMENT_CHANGED_PROPERTY = "verticalAlignment"; |
|
|
|
|
|
/** |
|
|
* Fired in a PropertyChangeEvent when the "verticalTextPosition" property |
|
|
* changes. |
|
|
*/ |
|
|
public static final String VERTICAL_TEXT_POSITION_CHANGED_PROPERTY = "verticalTextPosition"; |
|
|
|
|
|
/** |
|
95 |
* Creates a new horizontally and vertically centered JLabel object with no |
* Creates a new horizontally and vertically centered JLabel object with no |
96 |
* text and no icon. |
* text and no icon. |
97 |
*/ |
*/ |
236 |
{ |
{ |
237 |
String oldText = text; |
String oldText = text; |
238 |
text = newText; |
text = newText; |
239 |
firePropertyChange(TEXT_CHANGED_PROPERTY, oldText, newText); |
firePropertyChange("text", oldText, newText); |
240 |
|
|
241 |
if (text != null && text.length() <= displayedMnemonicIndex) |
if (text != null && text.length() <= displayedMnemonicIndex) |
242 |
setDisplayedMnemonicIndex(text.length() - 1); |
setDisplayedMnemonicIndex(text.length() - 1); |
266 |
{ |
{ |
267 |
Icon oldIcon = icon; |
Icon oldIcon = icon; |
268 |
icon = newIcon; |
icon = newIcon; |
269 |
firePropertyChange(ICON_CHANGED_PROPERTY, oldIcon, newIcon); |
firePropertyChange("icon", oldIcon, newIcon); |
270 |
} |
} |
271 |
} |
} |
272 |
|
|
299 |
{ |
{ |
300 |
Icon oldIcon = disabledIcon; |
Icon oldIcon = disabledIcon; |
301 |
disabledIcon = newIcon; |
disabledIcon = newIcon; |
302 |
firePropertyChange(DISABLED_ICON_CHANGED_PROPERTY, oldIcon, newIcon); |
firePropertyChange("disabledIcon", oldIcon, newIcon); |
303 |
} |
} |
304 |
} |
} |
305 |
|
|
314 |
{ |
{ |
315 |
if (displayedMnemonic != mnemonic) |
if (displayedMnemonic != mnemonic) |
316 |
{ |
{ |
317 |
firePropertyChange(DISPLAYED_MNEMONIC_CHANGED_PROPERTY, |
firePropertyChange("displayedMnemonic", |
318 |
displayedMnemonic, mnemonic); |
displayedMnemonic, mnemonic); |
319 |
displayedMnemonic = mnemonic; |
displayedMnemonic = mnemonic; |
320 |
|
|
371 |
{ |
{ |
372 |
int oldIndex = displayedMnemonicIndex; |
int oldIndex = displayedMnemonicIndex; |
373 |
displayedMnemonicIndex = newIndex; |
displayedMnemonicIndex = newIndex; |
374 |
firePropertyChange(DISPLAYED_MNEMONIC_INDEX_CHANGED_PROPERTY, |
firePropertyChange("displayedMnemonicIndex", |
375 |
oldIndex, newIndex); |
oldIndex, newIndex); |
376 |
} |
} |
377 |
} |
} |
448 |
{ |
{ |
449 |
if (iconTextGap != newGap) |
if (iconTextGap != newGap) |
450 |
{ |
{ |
451 |
firePropertyChange(ICON_TEXT_GAP_CHANGED_PROPERTY, iconTextGap, newGap); |
firePropertyChange("iconTextGap", iconTextGap, newGap); |
452 |
iconTextGap = newGap; |
iconTextGap = newGap; |
453 |
} |
} |
454 |
} |
} |
478 |
|
|
479 |
int oldAlignment = verticalAlignment; |
int oldAlignment = verticalAlignment; |
480 |
verticalAlignment = checkVerticalKey(alignment, "verticalAlignment"); |
verticalAlignment = checkVerticalKey(alignment, "verticalAlignment"); |
481 |
firePropertyChange(VERTICAL_ALIGNMENT_CHANGED_PROPERTY, |
firePropertyChange("verticalAlignment", oldAlignment, verticalAlignment); |
|
oldAlignment, verticalAlignment); |
|
482 |
} |
} |
483 |
|
|
484 |
/** |
/** |
504 |
|
|
505 |
int oldAlignment = horizontalAlignment; |
int oldAlignment = horizontalAlignment; |
506 |
horizontalAlignment = checkHorizontalKey(alignment, "horizontalAlignment"); |
horizontalAlignment = checkHorizontalKey(alignment, "horizontalAlignment"); |
507 |
firePropertyChange(HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, oldAlignment, |
firePropertyChange("horizontalAlignment", oldAlignment, |
508 |
horizontalAlignment); |
horizontalAlignment); |
509 |
} |
} |
510 |
|
|
532 |
int oldPos = verticalTextPosition; |
int oldPos = verticalTextPosition; |
533 |
verticalTextPosition = checkVerticalKey(textPosition, |
verticalTextPosition = checkVerticalKey(textPosition, |
534 |
"verticalTextPosition"); |
"verticalTextPosition"); |
535 |
firePropertyChange(VERTICAL_TEXT_POSITION_CHANGED_PROPERTY, oldPos, |
firePropertyChange("verticalTextPosition", oldPos, |
536 |
verticalTextPosition); |
verticalTextPosition); |
537 |
} |
} |
538 |
} |
} |
561 |
int oldPos = horizontalTextPosition; |
int oldPos = horizontalTextPosition; |
562 |
horizontalTextPosition = checkHorizontalKey(textPosition, |
horizontalTextPosition = checkHorizontalKey(textPosition, |
563 |
"horizontalTextPosition"); |
"horizontalTextPosition"); |
564 |
firePropertyChange(HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, oldPos, |
firePropertyChange("horizontalTextPosition", oldPos, |
565 |
horizontalTextPosition); |
horizontalTextPosition); |
566 |
} |
} |
567 |
} |
} |
617 |
{ |
{ |
618 |
if (c != labelFor) |
if (c != labelFor) |
619 |
{ |
{ |
620 |
firePropertyChange(LABEL_FOR_CHANGED_PROPERTY, labelFor, c); |
Component oldLabelFor = labelFor; |
621 |
labelFor = c; |
labelFor = c; |
622 |
|
firePropertyChange("labelFor", oldLabelFor, labelFor); |
623 |
} |
} |
624 |
} |
} |
625 |
|
|