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

Textfield blanks out due to the "repaint" method call in JDK 1.1.1 on Sparc

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.5.1

      Description

      Cust states:
      When running the following code, I select "time" in the Available Names
      list and then click the <- button. This should put "time" in the
      Independent Variable field which it does. However it also causes the
      field to blank out. This is due to the "repaint" method call. Removing
      the "repaint" causes things to work. However I would like to change the
      properties of the field, for example flipping the background and
      foreground colors to make the field stand out. I would think this would
      call for repainting the field.



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

      public final class listprob extends Dialog
            implements ActionListener {
         String independent_variable = null;
         Button ok, setIndependentVariable;
         List available_list;
         TextField independent_variable_field;
         TextField start_field, end_field;
         TextField run_number_field;

      public listprob (Frame parent) {
         super (parent, "Data Selection", true);
         Label l;
         Panel p, panel_button;
         setLayout (new BorderLayout ());
         p = new Panel ();
         p.setLayout (new GridBagLayout ());
         l = new Label ("Run Number");
         constrain (p, l, 0, 0, GridBagConstraints.EAST);
         run_number_field = new TextField ();
         constrain (p, run_number_field, 1, 0,
            GridBagConstraints.WEST);
         l = new Label (" ");
         constrain (p, l, 0, 1, GridBagConstraints.WEST);
         l = new Label ("Independent Variable");
         constrain (p, l, 0, 2,
            GridBagConstraints.WEST);
         independent_variable_field = new TextField (12);
         constrain (p, independent_variable_field, 0, 3,
            GridBagConstraints.WEST);
         setIndependentVariable = new Button ("<-");
         setIndependentVariable.addActionListener (this);
         constrain (p, setIndependentVariable, 1, 3,
            GridBagConstraints.CENTER);
         l = new Label ("Available Names");
         constrain (p, l, 2, 3, GridBagConstraints.CENTER);
         l = new Label ("Dependent Variables");
         available_list = new List (5, true);
         constrain (p, available_list, 2, 4,
            GridBagConstraints.CENTER);
         l = new Label (" ");
         constrain (p, l, 0, 9, GridBagConstraints.WEST);
         l = new Label ("Input Range");
         constrain (p, l, 0, 10, GridBagConstraints.EAST);
         l = new Label ("(optional)");
         constrain (p, l, 1, 10, GridBagConstraints.WEST);
         add ("North", p);
         p = new Panel ();
         p.setLayout (new FlowLayout ());
         l = new Label ("Range Start");
         p.add (l);
         start_field = new TextField ();
         p.add (start_field);
         l = new Label (" Range End");
         p.add (l);
         end_field = new TextField ();
         p.add (end_field);
         add ("Center", p);
         p = new Panel ();
         p.setLayout (new FlowLayout ());
         ok = new Button ("Ok");
         ok.addActionListener (this);
         p.add (ok);
         add ("South", p);
         pack ();
         available_list.add("time");
         available_list.add("X");
      }

      public void constrain (Container container, Component component,
                             int grid_x, int grid_y, int anchor) {
         GridBagConstraints c = new GridBagConstraints ();
         c.gridx = grid_x;
         c.gridy = grid_y;
         c.anchor = anchor;
         if (grid_x == 2 && grid_y == 4)
            c.gridheight = 3;
         if (grid_x == 0 && grid_y == 5)
            c.gridheight = 3;
         ((GridBagLayout)container.getLayout()).setConstraints (component,
            c);
         container.add (component);
      }

      public void actionPerformed (ActionEvent e) {
         int i;
         int [] iselections;
         if (e.getActionCommand().equals("Ok"))
            System.exit (0);
         else if (e.getSource() == setIndependentVariable) {
            iselections = available_list.getSelectedIndexes();
            if (iselections.length <= 0)
      return;
            if (iselections.length > 1) {
      System.out.println (
      "Independent variable may only have 1 selection");
            }
            available_list.deselect (iselections[0]);
            independent_variable_field.setText (
      available_list.getItem(iselections[0]));
      // Problem statement follows:
            independent_variable_field.repaint ();
         }
      }

      public static void main (String[] args) {
         Frame f = new Frame ("Test listprob");
         listprob d = new listprob (f);
         d.show ();
      }

      }

        Attachments

          Activity

            People

            Assignee:
            mbronsonsunw Mike Bronson (Inactive)
            Reporter:
            jbenoit Jonathan Benoit (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: