Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 6
    • Fix Version/s: None
    • Component/s: tools
    • Labels:

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0"
      Java(TM) SE Runtime Environment (build 1.6.0-b105)
      Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Windows XP Professional Service Pack 2.0

      A DESCRIPTION OF THE PROBLEM :
      I have included the code in the box below. The bug happens when on appletViwer I click on maximize button on the upper right corner hand of the screen next to X and then click on the maximize button again to resize the appletViewer back its initial state. The bug is; some textboxes become garbled. Actually, I still see textboxes. But, on the right border of some textboxes I see garbled extra textboxes. There is no problems when applet is accessed through Internet Explorer browser.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      - Run the test case
      - Maximize the window
      - Reduce window to original size & see that some compenets are not painted correctly.
      - Change the size of the window by dragging the windows corner & realize the components show somtimes.


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.applet.*;
      import java.net.*;
      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      import java.awt.event.ItemListener;
      import java.awt.event.ItemEvent;


      public class A5GUI extends JApplet implements ActionListener, ItemListener{
          
          String choiceStr[]={" Apartment","House","Condo","RentableHouse","RentableCondo"};
          JRadioButton choice[]=new JRadioButton[choiceStr.length];
          JButton add=new JButton("Add");
          JButton list=new JButton("List");

          GridBagConstraints cns=new GridBagConstraints();
          
          GridBagLayout layout1, layout2;
          
          JPanel topPanel = new JPanel();
          JPanel bottomPanel = new JPanel();
          
          {
              layout1 = new GridBagLayout();
              layout2 = new GridBagLayout();
          }
          
          public void init() {
              resize(400,400);
              
              try {
                  SwingUtilities.invokeAndWait(new Runnable() {
                      public void run() {
                          createGUI();
                      }
                  });
                  
              } catch (Exception e) {
                  System.err.println("createGUI didn't successfully complete");
              }
              
          }
          
          public void paint() {
              createGUI();
          }
          
          public void createGUI() {
              this.setLayout(new BorderLayout());
              topPanel.setLayout(layout1);
              bottomPanel.setLayout(layout2);

              JLabel label1 = new JLabel(" Select one of the real estate");
              JLabel label2 = new JLabel(" ");
              JLabel label3 = new JLabel(" ");
              JLabel label4 = new JLabel(" ");
              JLabel label5 = new JLabel(" ");
              JLabel label6 = new JLabel(" ");
              cns.fill = GridBagConstraints.HORIZONTAL;
              cns.weightx = 1;
              
              addComponent1(label6, 0, 0, 7, 1);
              addComponent1(label1, 1, 0, 3, 1);
              addComponent1(label2, 2, 0, 4, 1);
              addComponent1(label3, 4, 0, 4, 1);
              ButtonGroup bg = new ButtonGroup();
              for(int i=0;i<choice.length;i++){
                  choice[i]=new JRadioButton(choiceStr[i]);
                  choice[i].setHorizontalTextPosition(JRadioButton.LEADING);
                  bg.add(choice[i]);
                  addComponent1(choice[i], 3, i, 1, 1);
                  choice[i].addItemListener(this);
                  
              }
              choice[0].setSelected(true);
              addComponent1(add, 1, 3, 1, 1);
              addComponent1(list, 1, 4, 1, 1);
              this.add(topPanel,BorderLayout.NORTH);
              JTextArea area = new JTextArea(15,1);
              area.setFont(new Font("Serif", Font.BOLD, 18));
              area.setForeground(Color.RED);
              area.setText(" \n\n List of the entered estates and their properties...\n\n\n " + " Business Logic is NOT Linked in this HomeWork.");
              addComponent2(label4, 5, 0, 1, 1);
              addComponent2(area, 6, 0, 1, 1);
              addComponent2(label5, 7, 0, 1, 1);
              topPanel.setBackground(Color.LIGHT_GRAY);
              bottomPanel.setBackground(Color.LIGHT_GRAY);
              this.add(bottomPanel, BorderLayout.SOUTH);
              
          }
          private void addComponent1(Component c, int row,int col,int w,int h){
              cns.gridx=col;
              cns.gridy=row;
              cns.gridwidth=w;
              cns.gridheight=h;
              layout1.setConstraints(c,cns);
              topPanel.add(c);
          }

          private void addComponent2(Component c, int row,int col,int w,int h){
              cns.gridx=col;
              cns.gridy=row;
              cns.gridwidth=w;
              cns.gridheight=h;
              layout2.setConstraints(c,cns);
              bottomPanel.add(c);
          }
          public void actionPerformed(ActionEvent e) {
              
              
              
          }

          public void itemStateChanged(ItemEvent e) {
              if (e.getStateChange() == ItemEvent.SELECTED && e.getSource().equals(choice[0])) {
                  
                  JPanel p=new JPanel();
                  GridLayout g=new GridLayout(5,4);
                  p.setLayout(g);
                  
                  p.add(new JLabel(" Location" ));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.add(new JLabel(" Living Area"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.add(new JLabel(" Price"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.add(new JLabel(" Number Of Stories"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" "));
                  p.add(new JLabel(" " ));
                  
                  p.add(new JLabel(" Maintenance Fee"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.setMaximumSize(new Dimension(200,200));
                  this.add(p,BorderLayout.CENTER);
                  this.validate();
                  
              }
              
              
              if (e.getStateChange() == ItemEvent.SELECTED && e.getSource().equals(choice[1])) {
                  
                  JPanel p=new JPanel();
                  GridLayout g=new GridLayout(4,4);
                  p.setLayout(g);
                  
                  p.add(new JLabel(" Location"));
                  p.add(new JTextField("" ));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.add(new JLabel(" Living Area"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.add(new JLabel(" Price"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.add(new JLabel(" Yard"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.setMaximumSize(new Dimension(200,200));
                  this.add(p,BorderLayout.CENTER);
                  this.validate();
                  
              }
              
              if (e.getStateChange() == ItemEvent.SELECTED && e.getSource().equals(choice[2])) {
                  
                  
                  JPanel p=new JPanel();
                  GridLayout g=new GridLayout(5,4);
                  p.setLayout(g);
                  
                  p.add(new JLabel(" Location"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.add(new JLabel(" Living Area"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.add(new JLabel(" Price"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.add(new JLabel(" Yard"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.add(new JLabel(" Monthly Condo Fee"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.setMaximumSize(new Dimension(200,200));
                  this.add(p,BorderLayout.CENTER);
                  this.validate();
              }
              
              if (e.getStateChange() == ItemEvent.SELECTED && e.getSource().equals(choice[3])) {
                  
                  JPanel p=new JPanel();
                  GridLayout g=new GridLayout(5,4);
                  p.setLayout(g);
                  
                  p.add(new JLabel(" Location"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.add(new JLabel(" Living Area"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.add(new JLabel(" Price"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.add(new JLabel(" Yard"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.add(new JLabel(" Rent Fee"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.setMaximumSize(new Dimension(200,200));
                  this.add(p,BorderLayout.CENTER);
                  this.validate();
                  
                  
              }
              
              if (e.getStateChange() == ItemEvent.SELECTED && e.getSource().equals(choice[4])) {
                  
                  JPanel p=new JPanel();
                  GridLayout g=new GridLayout(7,4);
                  p.setLayout(g);
                  
                  p.add(new JLabel(" Location"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.add(new JLabel(" Living Area"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.add(new JLabel(" Price"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.add(new JLabel(" Yard"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.add(new JLabel(" Monthly Condo Fee"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.add(new JLabel(" Rent Fee"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.add(new JLabel(" Time Of Rent (In Months)"));
                  p.add(new JTextField(""));
                  p.add(new JLabel(" " ));
                  p.add(new JLabel(" " ));
                  
                  p.setMaximumSize(new Dimension(200,200));
                  this.add(p,BorderLayout.CENTER);
                  this.validate();
              }
          }
          
          public void start(){
              
              System.out.println("Applet starting.");
          }
          
          
          /** Stops the applet from executing. */
          public void stop() {
              // Stop the applet
              System.out.println("stop method called");
          }
          
          /** Free up any applet resources such as images or network connections*/
          public void destroy() {
              // Dispose resources that take up memory that the applet was using
              System.out.println("destroy method called" + threadInfo(Thread.currentThread()));
              
              
              //Execute a job on the event-dispatching thread:
              //destroying this applet's GUI.
              try {
                  SwingUtilities.invokeAndWait(new Runnable() {
                      public void run() {
                          getContentPane().removeAll();
                          System.out.println("doing removeAll: " + threadInfo(Thread.currentThread())); //on event-dispatching thread
                      }
                  });
              } catch (Exception e) { }
          }
          
          String threadInfo(Thread t) {
              return "thread=" + t.getName() + ", "
                      + "thread group=" + t.getThreadGroup().getName();
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use Internet Explorer browser.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ryeung Roger Yeung (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: