-
Bug
-
Resolution: Fixed
-
P4
-
1.1.4
-
1.1.8
-
sparc
-
solaris_2.5.1
-
Verified
This problem was raised by a 1.1.x licensee.
If a lightweight component within a lightweight container is moved
to the right it fails to delete itself from its previous position.
If the entire window is covered then uncovered then the subsequent
paint() removes this overdraw.
The following example (mostly copied from the JCK) shows the problem
------ LWComponentDisplayer.java -----------------------
/* LWComponentDisplayer.java
* Lightweight Component displayer
* This applet displays a lightweight component in a lightweight container
*/
//package javasoft.sqe.tests.api.java.awt.interactive.LWComponent;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class LWComponentDisplayer extends Panel implements ActionListener
{
static Frame theFrame;
static Panel buttonPanel; // Panel for user interface
Panel containerPanel; // Panel for lightweight container
ctr container1 = null; // Lightweight container
btn lwcomponent = null; // Lightweight component
public LWComponentDisplayer() {
theFrame = new Frame();
setLayout(new BorderLayout());
buttonPanel = new Panel();
containerPanel = new Panel();
container1 = new ctr("Lightweight Container");
lwcomponent = new btn("Lightweight Component");
containerPanel.add(container1);
add("Center", containerPanel);
add("North", buttonPanel);
}
// Add lightweight component to lightweight container
public void addLWComponent() {
container1.add(lwcomponent);
container1.validate();
container1.repaint();
}
// Move lightweight component
public void moveLWComponent() {
if (lwcomponent != null) {
int currentX = lwcomponent.getLocation().x;
int currentY = lwcomponent.getLocation().y;
lwcomponent.setLocation(currentX+15, currentY);
// RDAC container1.repaint();
}
}
// Add button for user interface
public void addButton(String s)
{
Button b = new Button(s);
buttonPanel.add(b);
b.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if (e.getActionCommand() == "Move lightweight component")
moveLWComponent();
}
public static void main( String args[] )
{
LWComponentDisplayer displayer = new LWComponentDisplayer();
buttonPanel.setLayout(new GridLayout(0,4));
displayer.addButton("Move lightweight component");
displayer.addLWComponent();
theFrame.add("Center", displayer);
theFrame.pack();
theFrame.setVisible(true);
theFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
// Lightweight container
class ctr extends Container
{
String text;
int prefWidth;
int prefHeight;
Color backgroundColor;
Color foregroundColor;
public ctr(String text) {
this.text = text;
this.prefWidth = 300;
this.prefHeight = 300;
this.backgroundColor = Color.cyan;
this.foregroundColor = Color.black;
setLayout(new FlowLayout());
}
public ctr(String text, int prefWidth, int prefHeight, Color backgroundColor, Color foregroundColor)
{
this.text = text;
this.prefWidth = prefWidth;
this.prefHeight = prefHeight;
this.backgroundColor = backgroundColor;
this.foregroundColor = foregroundColor;
setLayout(new FlowLayout());
}
public void paint(Graphics g)
{
g.setColor(backgroundColor);
g.fill3DRect(0,0,getSize().width-1, getSize().height-1, true);
g.setColor(foregroundColor);
g.drawString(text, 0, getSize().height/2);
super.paint(g);
System.out.println("Container Paint called");
}
public void update(Graphics g)
{
}
public Dimension getPreferredSize()
{
return new Dimension(prefWidth, prefHeight);
}
public Dimension getMinimumSize()
{
return new Dimension(prefWidth, prefHeight);
}
}
// Lightweight component
class btn extends Component
{
String text;
public btn(String text)
{
this.text = text;
}
public void paint(Graphics g)
{
g.setColor(Color.white);
g.fill3DRect(0,0,getSize().width-1, getSize().height-1, true);
g.setColor(Color.lightGray);
g.drawRect(0,0,getSize().width+2, getSize().height+2);
g.setColor(Color.black);
g.drawString(text, 0, getSize().height/2);
System.out.println("Component Paint called");
}
public void update(Graphics g)
{
}
public Dimension getPreferredSize()
{
return new Dimension(165, 20);
}
}
}
If a lightweight component within a lightweight container is moved
to the right it fails to delete itself from its previous position.
If the entire window is covered then uncovered then the subsequent
paint() removes this overdraw.
The following example (mostly copied from the JCK) shows the problem
------ LWComponentDisplayer.java -----------------------
/* LWComponentDisplayer.java
* Lightweight Component displayer
* This applet displays a lightweight component in a lightweight container
*/
//package javasoft.sqe.tests.api.java.awt.interactive.LWComponent;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class LWComponentDisplayer extends Panel implements ActionListener
{
static Frame theFrame;
static Panel buttonPanel; // Panel for user interface
Panel containerPanel; // Panel for lightweight container
ctr container1 = null; // Lightweight container
btn lwcomponent = null; // Lightweight component
public LWComponentDisplayer() {
theFrame = new Frame();
setLayout(new BorderLayout());
buttonPanel = new Panel();
containerPanel = new Panel();
container1 = new ctr("Lightweight Container");
lwcomponent = new btn("Lightweight Component");
containerPanel.add(container1);
add("Center", containerPanel);
add("North", buttonPanel);
}
// Add lightweight component to lightweight container
public void addLWComponent() {
container1.add(lwcomponent);
container1.validate();
container1.repaint();
}
// Move lightweight component
public void moveLWComponent() {
if (lwcomponent != null) {
int currentX = lwcomponent.getLocation().x;
int currentY = lwcomponent.getLocation().y;
lwcomponent.setLocation(currentX+15, currentY);
// RDAC container1.repaint();
}
}
// Add button for user interface
public void addButton(String s)
{
Button b = new Button(s);
buttonPanel.add(b);
b.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if (e.getActionCommand() == "Move lightweight component")
moveLWComponent();
}
public static void main( String args[] )
{
LWComponentDisplayer displayer = new LWComponentDisplayer();
buttonPanel.setLayout(new GridLayout(0,4));
displayer.addButton("Move lightweight component");
displayer.addLWComponent();
theFrame.add("Center", displayer);
theFrame.pack();
theFrame.setVisible(true);
theFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
// Lightweight container
class ctr extends Container
{
String text;
int prefWidth;
int prefHeight;
Color backgroundColor;
Color foregroundColor;
public ctr(String text) {
this.text = text;
this.prefWidth = 300;
this.prefHeight = 300;
this.backgroundColor = Color.cyan;
this.foregroundColor = Color.black;
setLayout(new FlowLayout());
}
public ctr(String text, int prefWidth, int prefHeight, Color backgroundColor, Color foregroundColor)
{
this.text = text;
this.prefWidth = prefWidth;
this.prefHeight = prefHeight;
this.backgroundColor = backgroundColor;
this.foregroundColor = foregroundColor;
setLayout(new FlowLayout());
}
public void paint(Graphics g)
{
g.setColor(backgroundColor);
g.fill3DRect(0,0,getSize().width-1, getSize().height-1, true);
g.setColor(foregroundColor);
g.drawString(text, 0, getSize().height/2);
super.paint(g);
System.out.println("Container Paint called");
}
public void update(Graphics g)
{
}
public Dimension getPreferredSize()
{
return new Dimension(prefWidth, prefHeight);
}
public Dimension getMinimumSize()
{
return new Dimension(prefWidth, prefHeight);
}
}
// Lightweight component
class btn extends Component
{
String text;
public btn(String text)
{
this.text = text;
}
public void paint(Graphics g)
{
g.setColor(Color.white);
g.fill3DRect(0,0,getSize().width-1, getSize().height-1, true);
g.setColor(Color.lightGray);
g.drawRect(0,0,getSize().width+2, getSize().height+2);
g.setColor(Color.black);
g.drawString(text, 0, getSize().height/2);
System.out.println("Component Paint called");
}
public void update(Graphics g)
{
}
public Dimension getPreferredSize()
{
return new Dimension(165, 20);
}
}
}