Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4177948

On Windows 95, Graphics objects draws incorrect object.



    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 1.1.6
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
    • OS:


      Several of many Graphic objects draw incorrect objects after boot Windows 95.

      I attach a reproducible sample applet which consists of five Labels, five extended TextFields, and five Buttons on a Panel. The extended TextField calls repaint() method at the timing when focus is lost from it, and overrides paint() method to clear its text by using clearRect() method in Graphics class in case that it doesn't have focus. In short, text in the TextFiled should be cleared when it lost focus. But just after boot Windows 95, two or three TextFields are not cleared, and instead of them, Button objects are cleared.

      How to reproduce:
      1) Boot Windows 95.
      2) Compile Applet1.java and ExTextField.java.
             javac -d . Applet1.java ExTextField.java
      3) Run the sample applet with appletviewer.
             appletviewer Applet1.html
      4) Click all TextFields from TextField1 to TextField5.
      5) Probably, you can see that 2 or 3 Buttons are cleared instead of TextFields.

      This problem occors only on Windows 95.
      On Solaris or Windows NT, it doesn't occur.

      The damage is severe when one runs the applet first after boot Widows 95. If one runs the same applet several times after boot, the damage becomes smaller, and eventually it disappears.

      <APPLET CODE="Sample.Applet1.class" WIDTH=400 HEIGHT=150></APPLET>

      package Sample;

      import java.awt.*;
      import java.awt.event.*;
      import java.applet.*;

      public class Applet1 extends Applet {
        Panel panel = new Panel();
        ExTextField textField1 = new ExTextField();
        ExTextField textField2 = new ExTextField();
        ExTextField textField3 = new ExTextField();
        ExTextField textField4 = new ExTextField();
        ExTextField textField5 = new ExTextField();
        Button button1 = new Button();
        Button button2 = new Button();
        Button button3 = new Button();
        Button button4 = new Button();
        Button button5 = new Button();

        public Applet1() {

        public void init() {
          try { jbInit(); } catch (Exception e) { e.printStackTrace(); }

        public void jbInit() throws Exception{
          panel.setLayout(new GridLayout(5,3));
          this.setLayout(new GridLayout(1,1));
          this.add(panel, null);
          panel.add(new Label("TextField1 -> ",Label.CENTER));
          panel.add(textField1, null);
          panel.add(button1, null);
          panel.add(new Label("ExTextField -> ",Label.CENTER));
          panel.add(textField2, null);
          panel.add(button2, null);
          panel.add(new Label("TextField3 -> ",Label.CENTER));
          panel.add(textField3, null);
          panel.add(button3, null);
          panel.add(new Label("TextField4 -> ",Label.CENTER));
          panel.add(textField4, null);
          panel.add(button4, null);
          panel.add(new Label("TextField5 -> ",Label.CENTER));
          panel.add(textField5, null);
          panel.add(button5, null);

      package Sample;

      import java.awt.*;
      import java.awt.event.*;

      public class ExTextField extends TextField{ //Extended TextField Class
        boolean focus = false;

        public ExTextField() {

        public void paint(Graphics g) {
          if (focus == false) {

        private void clearString(Graphics g) {
          Rectangle rect = this.getBounds();
          g.clearRect(0, 0, rect.width, rect.height);

        public void processFocusEvent (FocusEvent e) {
          switch (e.getID()) {
            case FocusEvent.FOCUS_GAINED:
      focus = true;
            case FocusEvent.FOCUS_LOST:
      focus = false;





            bchristi Brent Christian
            ksaso Koichi Saso (Inactive)
            0 Vote for this issue
            0 Start watching this issue