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

componentResized not called when snapped

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 7u25, 7u51
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:

      Description

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      method componentResized doesn't called when the frame window after be snapped vertically under MS Windows 7 & Window 8 snapping feature.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1.) after the frame shows, hold the top edge of the frame when the mouse pointer become an arrow (please don't move the bottom edge).
      2.) dragged the edge upward and downward, at this time you can see the output of the frames's width and height created by method componentResize.
      3.) now dragged the top edge to the top of screen and hold, you may see the glass overlay under the frame and the value of height of the frame in the consoleText tab.
      4.) so release to edge so that the frame become as high as the screen

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      method componentResize is called so
      output of height refreshes and the value of height becomes the same as the screen,
      also all the components are repainted.
      ACTUAL -
      method componentResize has not been called
      value of height does not update
      the bottom of the frame become black

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      (actually there is no any error message except other process is using the value of height)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
      public class snapBug extends JPanel implements ComponentListener
      {
      private static final long serialVersionUID=1L;
      private final JFrame frm;
      //for displaying output in frame
      private JTextArea consoleText=new JTextArea();
      private int width,height;
      private int size=10;//it is for the grid
      public snapBug(JFrame frm){
      this.frm=frm;
      this.width=this.frm.getSize().width;
      this.height=this.frm.getSize().height;

      JTabbedPane tab=new JTabbedPane();
      tab.addTab("consoleText",new JScrollPane(this.consoleText));
      tab.addTab("paint",this);

      this.initializeConsoleText();
      this.addComponentListener(this);
      this.frm.add(tab);
      }
      private void initializeConsoleText(){
      this.consoleText.setEditable(false);
      this.consoleText.setFont(new Font("Monospaced",Font.PLAIN,12));
      this.consoleText.setTabSize(4);
      }
      //so that you can see what effect to paint method
      public void paintComponent(Graphics g){
      super.paintComponent(g);
      for(int i=0;i<this.width;i+=this.size){
      g.drawLine(i,0,i,this.height);
      }
      for(int j=0;j<this.height;j+=this.size){
      g.drawLine(0,j,this.width,j);
      }
      }
      public void componentResized(ComponentEvent ce){
      this.width=this.frm.getSize().width;
      this.height=this.frm.getSize().height;
      this.println("width: "+this.width+"\t height: "+this.height);
      }
      public void componentMoved(ComponentEvent ce){}
      public void componentHidden(ComponentEvent ce){}
      public void componentShown(ComponentEvent ce){}
      public <T> void print(T obj){
      this.consoleText.append(obj.toString());
      System.out.print(obj);
      this.consoleText.setCaretPosition(
      this.consoleText.getDocument().getLength());
      }
      public <T> void println(){
      this.consoleText.append("
      ");
      System.out.println();
      this.consoleText.setCaretPosition(
      this.consoleText.getDocument().getLength());
      }
      public <T> void println(T obj){
      this.consoleText.append(obj.toString().concat("
      "));
      System.out.println(obj);
      this.consoleText.setCaretPosition(
      this.consoleText.getDocument().getLength());
      }
      public static void main(String args[])
      {
      JFrame obj=new JFrame("snapBug");
      obj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      int base=350;double ratio=(Math.pow(5,0.5)+1)/2;
      obj.setSize((int)(base*ratio),base);
      obj.setLocationRelativeTo(null);
      new snapBug(obj);
      obj.setVisible(true);
      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      //no solution

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              aivanov Alexey Ivanov
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: