AWT doesn't draw rectangle after applet loading
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Dmitry_Zakharov
Posted On:   Sunday, November 17, 2002 09:29 PM

I create component (the code below) which draw filled green rectangle. When I run this Applet in IE with Sun Java Plug-in 1.4.0, I see white screen without green rectangle. I see on console start painting painting is finished That is MyComp.paint(Graphics) method was invoked. When I place mouse over applet the green rectangle is appeared (and there is no new messages on console). What's wrong with my code ? Why is there such strange behaviour ? How can I correct this problem ? I doesn't see this problem on MS JVM and Sun Java Plug-n 1.3. Thanks beforhand Here is code of applet and the component: import java.awt.*; public class Test extends java.applet.Applet {    More>>

I create component (the code below) which draw filled green rectangle. When I run this Applet in IE with Sun Java Plug-in 1.4.0, I see white screen without green rectangle. I see on console

			
start painting
painting is finished

That is MyComp.paint(Graphics) method was invoked. When I place mouse over applet the green rectangle is appeared (and there is no new messages on console).


What's wrong with my code ? Why is there such strange behaviour ? How can I correct this problem ?


I doesn't see this problem on MS JVM and Sun Java Plug-n 1.3.


Thanks beforhand


Here is code of applet and the component:


			
import java.awt.*;

public class Test extends java.applet.Applet {

public void init() {
setLayout(new BorderLayout());
add (new MyComp(),BorderLayout.CENTER);
}

}

class MyComp extends Component {

public void paint(Graphics g) {
System.out.println("start painting");
super.paint(g);
g.setColor(Color.green);
g.fillRect(10,10,30,30);
System.out.println("painting is finished");
}

public Dimension getPreferredSize() {
return new Dimension(100,100);
}

}
   <<Less
About | Sitemap | Contact