38 |
|
|
39 |
package javax.swing.plaf.basic; |
package javax.swing.plaf.basic; |
40 |
|
|
41 |
|
import java.awt.Color; |
42 |
import java.awt.Container; |
import java.awt.Container; |
43 |
import java.awt.Dimension; |
import java.awt.Dimension; |
44 |
import java.awt.Graphics; |
import java.awt.Graphics; |
343 |
public void propertyChange(PropertyChangeEvent event) |
public void propertyChange(PropertyChangeEvent event) |
344 |
{ |
{ |
345 |
if (event.getPropertyName().equals("document")) |
if (event.getPropertyName().equals("document")) |
346 |
{ |
{ |
347 |
// Document changed. |
// Document changed. |
348 |
modelChanged(); |
modelChanged(); |
349 |
} |
} |
350 |
|
else if (event.getPropertyName().equals("enabled")) |
351 |
|
{ |
352 |
|
updateComponentColors(); |
353 |
|
} |
354 |
} |
} |
355 |
} |
} |
356 |
|
|
430 |
DocumentHandler documentHandler = new DocumentHandler(); |
DocumentHandler documentHandler = new DocumentHandler(); |
431 |
|
|
432 |
/** |
/** |
433 |
|
* The standard foreground color. This is the color which is used to paint |
434 |
|
* text in enabled text components. |
435 |
|
*/ |
436 |
|
Color foreground; |
437 |
|
|
438 |
|
/** |
439 |
|
* The standard background color. This is the color which is used to paint |
440 |
|
* text in enabled text components. |
441 |
|
*/ |
442 |
|
Color background; |
443 |
|
|
444 |
|
/** |
445 |
|
* The inactive foreground color. This is the color which is used to paint |
446 |
|
* text in disabled text components. |
447 |
|
*/ |
448 |
|
Color inactiveForeground; |
449 |
|
|
450 |
|
/** |
451 |
|
* The inactive background color. This is the color which is used to paint |
452 |
|
* text in disabled text components. |
453 |
|
*/ |
454 |
|
Color inactiveBackground; |
455 |
|
|
456 |
|
/** |
457 |
* Creates a new <code>BasicTextUI</code> instance. |
* Creates a new <code>BasicTextUI</code> instance. |
458 |
*/ |
*/ |
459 |
public BasicTextUI() |
public BasicTextUI() |
536 |
|
|
537 |
String prefix = getPropertyPrefix(); |
String prefix = getPropertyPrefix(); |
538 |
UIDefaults defaults = UIManager.getLookAndFeelDefaults(); |
UIDefaults defaults = UIManager.getLookAndFeelDefaults(); |
|
textComponent.setBackground(defaults.getColor(prefix + ".background")); |
|
|
textComponent.setForeground(defaults.getColor(prefix + ".foreground")); |
|
539 |
textComponent.setMargin(defaults.getInsets(prefix + ".margin")); |
textComponent.setMargin(defaults.getInsets(prefix + ".margin")); |
540 |
textComponent.setBorder(defaults.getBorder(prefix + ".border")); |
textComponent.setBorder(defaults.getBorder(prefix + ".border")); |
541 |
textComponent.setFont(defaults.getFont(prefix + ".font")); |
textComponent.setFont(defaults.getFont(prefix + ".font")); |
542 |
|
|
543 |
caret.setBlinkRate(defaults.getInt(prefix + ".caretBlinkRate")); |
caret.setBlinkRate(defaults.getInt(prefix + ".caretBlinkRate")); |
544 |
|
|
545 |
|
// Fetch the colors for enabled/disabled text components. |
546 |
|
foreground = defaults.getColor(prefix + ".foreground"); |
547 |
|
background = defaults.getColor(prefix + ".background"); |
548 |
|
inactiveForeground = defaults.getColor(prefix + ".inactiveForeground"); |
549 |
|
inactiveBackground = defaults.getColor(prefix + ".inactiveBackground"); |
550 |
|
updateComponentColors(); |
551 |
} |
} |
552 |
|
|
553 |
/** |
/** |
1077 |
View view = factory.create(elem); |
View view = factory.create(elem); |
1078 |
setView(view); |
setView(view); |
1079 |
} |
} |
1080 |
|
|
1081 |
|
/** |
1082 |
|
* Updates the colors of the text component according to its enabled |
1083 |
|
* state. |
1084 |
|
*/ |
1085 |
|
void updateComponentColors() |
1086 |
|
{ |
1087 |
|
if (textComponent.isEnabled()) |
1088 |
|
{ |
1089 |
|
textComponent.setForeground(foreground); |
1090 |
|
textComponent.setBackground(background); |
1091 |
|
} |
1092 |
|
else |
1093 |
|
{ |
1094 |
|
textComponent.setForeground(inactiveForeground); |
1095 |
|
textComponent.setBackground(inactiveBackground); |
1096 |
|
} |
1097 |
|
} |
1098 |
} |
} |