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; |
242 |
public void paint(Graphics g, Shape s) |
public void paint(Graphics g, Shape s) |
243 |
{ |
{ |
244 |
if (view != null) |
if (view != null) |
245 |
view.paint(g, s); |
view.paint(g, s); |
246 |
} |
} |
247 |
|
|
248 |
|
|
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("editable")) |
351 |
|
{ |
352 |
|
if (textComponent.isEditable()) |
353 |
|
textComponent.setBackground(background); |
354 |
|
else |
355 |
|
textComponent.setBackground(inactiveBackground); |
356 |
|
} |
357 |
} |
} |
358 |
} |
} |
359 |
|
|
433 |
DocumentHandler documentHandler = new DocumentHandler(); |
DocumentHandler documentHandler = new DocumentHandler(); |
434 |
|
|
435 |
/** |
/** |
436 |
|
* The standard background color. This is the color which is used to paint |
437 |
|
* text in enabled text components. |
438 |
|
*/ |
439 |
|
Color background; |
440 |
|
|
441 |
|
/** |
442 |
|
* The inactive background color. This is the color which is used to paint |
443 |
|
* text in disabled text components. |
444 |
|
*/ |
445 |
|
Color inactiveBackground; |
446 |
|
|
447 |
|
/** |
448 |
* Creates a new <code>BasicTextUI</code> instance. |
* Creates a new <code>BasicTextUI</code> instance. |
449 |
*/ |
*/ |
450 |
public BasicTextUI() |
public BasicTextUI() |
527 |
|
|
528 |
String prefix = getPropertyPrefix(); |
String prefix = getPropertyPrefix(); |
529 |
UIDefaults defaults = UIManager.getLookAndFeelDefaults(); |
UIDefaults defaults = UIManager.getLookAndFeelDefaults(); |
|
textComponent.setBackground(defaults.getColor(prefix + ".background")); |
|
|
textComponent.setForeground(defaults.getColor(prefix + ".foreground")); |
|
530 |
textComponent.setMargin(defaults.getInsets(prefix + ".margin")); |
textComponent.setMargin(defaults.getInsets(prefix + ".margin")); |
531 |
textComponent.setBorder(defaults.getBorder(prefix + ".border")); |
textComponent.setBorder(defaults.getBorder(prefix + ".border")); |
532 |
textComponent.setFont(defaults.getFont(prefix + ".font")); |
textComponent.setFont(defaults.getFont(prefix + ".font")); |
533 |
|
|
534 |
caret.setBlinkRate(defaults.getInt(prefix + ".caretBlinkRate")); |
caret.setBlinkRate(defaults.getInt(prefix + ".caretBlinkRate")); |
535 |
|
|
536 |
|
// Fetch the colors for enabled/disabled text components. |
537 |
|
background = defaults.getColor(prefix + ".background"); |
538 |
|
inactiveBackground = defaults.getColor(prefix + ".inactiveBackground"); |
539 |
|
textComponent.setForeground(defaults.getColor(prefix + ".foreground")); |
540 |
|
textComponent.setDisabledTextColor |
541 |
|
(defaults.getColor(prefix + ".inactiveForeground")); |
542 |
} |
} |
543 |
|
|
544 |
/** |
/** |
822 |
*/ |
*/ |
823 |
protected void paintBackground(Graphics g) |
protected void paintBackground(Graphics g) |
824 |
{ |
{ |
825 |
g.setColor(textComponent.getBackground()); |
// This method does nothing. All the background filling is done by the |
826 |
g.fillRect(0, 0, textComponent.getWidth(), textComponent.getHeight()); |
// ComponentUI update method. However, the method is called by paint |
827 |
|
// to provide a way for subclasses to draw something different (e.g. background |
828 |
|
// images etc) on the background. |
829 |
} |
} |
830 |
|
|
831 |
/** |
/** |