Add setBackground to richtext JTextPanel

X-SVN-Rev: 3933
This commit is contained in:
Doug Felt 2001-03-07 02:39:01 +00:00
parent 4a1fd4d968
commit 1cd9fd50b6
2 changed files with 20 additions and 4 deletions

View File

@ -1,5 +1,5 @@
/*
* @(#)$RCSfile: JTextPanel.java,v $ $Revision: 1.2 $ $Date: 2000/04/22 17:10:10 $
* @(#)$RCSfile: JTextPanel.java,v $ $Revision: 1.3 $ $Date: 2001/03/07 02:39:01 $
*
* (C) Copyright IBM Corp. 1998-1999. All Rights Reserved.
*
@ -15,6 +15,7 @@
package com.ibm.richtext.textpanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.lang.reflect.InvocationTargetException;
@ -568,4 +569,14 @@ public final class JTextPanel extends JPanel implements MTextPanel {
return fImpl;
}
public void setBackground(Color color) {
super.setBackground (color);
java.awt.Component[] compList = getComponents();
for (int i = 0; i < compList.length; i++) {
if (!(compList[i] instanceof JScrollBar)) {
compList[i].setBackground (color);
}
}
}
}

View File

@ -1,5 +1,5 @@
/*
* @(#)$RCSfile: TextComponent.java,v $ $Revision: 1.2 $ $Date: 2000/04/22 17:10:10 $
* @(#)$RCSfile: TextComponent.java,v $ $Revision: 1.3 $ $Date: 2001/03/07 02:39:01 $
*
* (C) Copyright IBM Corp. 1998-1999. All Rights Reserved.
*
@ -764,7 +764,12 @@ class TextComponent extends FakeComponent
TextOffset selEnd,
Color hiliteColor) {
g.clearRect(drawRect.x, drawRect.y, drawRect.width, drawRect.height);
Color oldColor = g.getColor();
g.setColor(fHost.getHost().getBackground());
g.fillRect(drawRect.x, drawRect.y, drawRect.width, drawRect.height);
g.setColor(oldColor);
// g.clearRect(drawRect.x, drawRect.y, drawRect.width, drawRect.height);
if (selectionVisible) {
fFormatter.draw(g, drawRect, fOrigin, selStart, selEnd, hiliteColor);
@ -974,4 +979,4 @@ class TextComponent extends FakeComponent
result, initialOffset, previousOffset, direction);
}
}
}
}