You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Dmitry A. Durnev (JIRA)" <ji...@apache.org> on 2006/10/10 10:37:19 UTC

[jira] Created: (HARMONY-1801) [classlib][swing] JComponent.setBounds() should not cause revalidation

[classlib][swing] JComponent.setBounds() should not cause revalidation
----------------------------------------------------------------------

                 Key: HARMONY-1801
                 URL: http://issues.apache.org/jira/browse/HARMONY-1801
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Dmitry A. Durnev
            Priority: Minor


Validation process should not be initiated by component reshaping to avoid too
many re-validations while doing layout (layout usually causes reshape).
Therefore JComponent.setBounds() should not call revalidate. 
Compile & run the following test:

import java.awt.EventQueue;
import java.lang.reflect.InvocationTargetException;

import javax.swing.JButton;
import javax.swing.JFrame;


public class SetBoundsTest {
    
    public static void main(String[] args) throws InterruptedException, InvocationTargetException {
        final JFrame jf = new JFrame("test");
        final JButton jb = new JButton("1");        
        jf.getContentPane().add(jb);
        jf.setSize(200, 200);
        EventQueue.invokeAndWait(new Runnable(){

            public void run() {
                jf.show();                
            }
            
        });
        EventQueue.invokeAndWait(new Runnable(){

            public void run() {
                jb.setSize(150, 500);                
            }
            
        });
        

        EventQueue.invokeAndWait(new Runnable(){

            public void run() {
                System.out.println(jb.getSize());
                jf.dispose();           
            }
            
        });
        

    }

}

On RI button size set by user(150, 500) is printed. On Harmony some other size (set by layout) is printed.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (HARMONY-1801) [classlib][swing] JComponent.setBounds() should not cause revalidation

Posted by "Dmitry A. Durnev (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1801?page=all ]

Dmitry A. Durnev updated HARMONY-1801:
--------------------------------------

    Attachment: H1801-BasicTabbedPaneUI.patch

BasicTabbedPaneUI was relying on JComponent revalidate on any resize, so it was broken. Simple fix is attached which adds necessary revalidate() call...

> [classlib][swing] JComponent.setBounds() should not cause revalidation
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-1801
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1801
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Dmitry A. Durnev
>            Priority: Minor
>         Attachments: H1801-BasicTabbedPaneUI.patch, H1801-fix.patch, H1801-tests.patch
>
>
> Validation process should not be initiated by component reshaping to avoid too
> many re-validations while doing layout (layout usually causes reshape).
> Therefore JComponent.setBounds() should not call revalidate. 
> Compile & run the following test:
> import java.awt.EventQueue;
> import java.lang.reflect.InvocationTargetException;
> import javax.swing.JButton;
> import javax.swing.JFrame;
> public class SetBoundsTest {
>     
>     public static void main(String[] args) throws InterruptedException, InvocationTargetException {
>         final JFrame jf = new JFrame("test");
>         final JButton jb = new JButton("1");        
>         jf.getContentPane().add(jb);
>         jf.setSize(200, 200);
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 jf.show();                
>             }
>             
>         });
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 jb.setSize(150, 500);                
>             }
>             
>         });
>         
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 System.out.println(jb.getSize());
>                 jf.dispose();           
>             }
>             
>         });
>         
>     }
> }
> On RI button size set by user(150, 500) is printed. On Harmony some other size (set by layout) is printed.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (HARMONY-1801) [classlib][swing] JComponent.setBounds() should not cause revalidation

Posted by "Alexey A. Ivanov (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-1801?page=comments#action_12450703 ] 
            
Alexey A. Ivanov commented on HARMONY-1801:
-------------------------------------------

No, the problem hasn't been fixed. At least the test application from description doesn't work as it is supposed.

> [classlib][swing] JComponent.setBounds() should not cause revalidation
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-1801
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1801
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Dmitry A. Durnev
>         Assigned To: Mikhail Loenko
>            Priority: Minor
>         Attachments: H1801-BasicTabbedPaneUI.patch, H1801-fix.patch, H1801-tests.patch
>
>
> Validation process should not be initiated by component reshaping to avoid too
> many re-validations while doing layout (layout usually causes reshape).
> Therefore JComponent.setBounds() should not call revalidate. 
> Compile & run the following test:
> import java.awt.EventQueue;
> import java.lang.reflect.InvocationTargetException;
> import javax.swing.JButton;
> import javax.swing.JFrame;
> public class SetBoundsTest {
>     
>     public static void main(String[] args) throws InterruptedException, InvocationTargetException {
>         final JFrame jf = new JFrame("test");
>         final JButton jb = new JButton("1");        
>         jf.getContentPane().add(jb);
>         jf.setSize(200, 200);
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 jf.show();                
>             }
>             
>         });
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 jb.setSize(150, 500);                
>             }
>             
>         });
>         
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 System.out.println(jb.getSize());
>                 jf.dispose();           
>             }
>             
>         });
>         
>     }
> }
> On RI button size set by user(150, 500) is printed. On Harmony some other size (set by layout) is printed.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Assigned: (HARMONY-1801) [classlib][swing] JComponent.setBounds() should not cause revalidation

Posted by "Mikhail Loenko (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1801?page=all ]

Mikhail Loenko reassigned HARMONY-1801:
---------------------------------------

    Assignee: Mikhail Loenko

> [classlib][swing] JComponent.setBounds() should not cause revalidation
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-1801
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1801
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Dmitry A. Durnev
>         Assigned To: Mikhail Loenko
>            Priority: Minor
>         Attachments: H1801-BasicTabbedPaneUI.patch, H1801-fix.patch, H1801-tests.patch
>
>
> Validation process should not be initiated by component reshaping to avoid too
> many re-validations while doing layout (layout usually causes reshape).
> Therefore JComponent.setBounds() should not call revalidate. 
> Compile & run the following test:
> import java.awt.EventQueue;
> import java.lang.reflect.InvocationTargetException;
> import javax.swing.JButton;
> import javax.swing.JFrame;
> public class SetBoundsTest {
>     
>     public static void main(String[] args) throws InterruptedException, InvocationTargetException {
>         final JFrame jf = new JFrame("test");
>         final JButton jb = new JButton("1");        
>         jf.getContentPane().add(jb);
>         jf.setSize(200, 200);
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 jf.show();                
>             }
>             
>         });
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 jb.setSize(150, 500);                
>             }
>             
>         });
>         
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 System.out.println(jb.getSize());
>                 jf.dispose();           
>             }
>             
>         });
>         
>     }
> }
> On RI button size set by user(150, 500) is printed. On Harmony some other size (set by layout) is printed.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (HARMONY-1801) [classlib][swing] JComponent.setBounds() should not cause revalidation

Posted by "Mikhail Loenko (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-1801?page=comments#action_12450636 ] 
            
Mikhail Loenko commented on HARMONY-1801:
-----------------------------------------

when I apply regression test, it does not fail. 
Was the problem fixed somehow? 

> [classlib][swing] JComponent.setBounds() should not cause revalidation
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-1801
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1801
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Dmitry A. Durnev
>         Assigned To: Mikhail Loenko
>            Priority: Minor
>         Attachments: H1801-BasicTabbedPaneUI.patch, H1801-fix.patch, H1801-tests.patch
>
>
> Validation process should not be initiated by component reshaping to avoid too
> many re-validations while doing layout (layout usually causes reshape).
> Therefore JComponent.setBounds() should not call revalidate. 
> Compile & run the following test:
> import java.awt.EventQueue;
> import java.lang.reflect.InvocationTargetException;
> import javax.swing.JButton;
> import javax.swing.JFrame;
> public class SetBoundsTest {
>     
>     public static void main(String[] args) throws InterruptedException, InvocationTargetException {
>         final JFrame jf = new JFrame("test");
>         final JButton jb = new JButton("1");        
>         jf.getContentPane().add(jb);
>         jf.setSize(200, 200);
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 jf.show();                
>             }
>             
>         });
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 jb.setSize(150, 500);                
>             }
>             
>         });
>         
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 System.out.println(jb.getSize());
>                 jf.dispose();           
>             }
>             
>         });
>         
>     }
> }
> On RI button size set by user(150, 500) is printed. On Harmony some other size (set by layout) is printed.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (HARMONY-1801) [classlib][swing] JComponent.setBounds() should not cause revalidation

Posted by "Alexey A. Ivanov (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1801?page=all ]

Alexey A. Ivanov updated HARMONY-1801:
--------------------------------------

    Attachment: H1801-tests.patch

Mikhail,
Try the new regression tests. It is explicitly checked that revalidate() is not called. I've also added a test case to JInternalFrameTest, since JInternalFrame code is modified.

Both tests fail without fix and pass successfully with the fix. (The tests pass when run against RI.)

The problem with original test, as I see it, is that re-layout might be in progress when comp.getSize is called, thus comp still has the size unchanged.

> [classlib][swing] JComponent.setBounds() should not cause revalidation
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-1801
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1801
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Dmitry A. Durnev
>         Assigned To: Mikhail Loenko
>            Priority: Minor
>         Attachments: H1801-BasicTabbedPaneUI.patch, H1801-fix.patch, H1801-tests.patch, H1801-tests.patch
>
>
> Validation process should not be initiated by component reshaping to avoid too
> many re-validations while doing layout (layout usually causes reshape).
> Therefore JComponent.setBounds() should not call revalidate. 
> Compile & run the following test:
> import java.awt.EventQueue;
> import java.lang.reflect.InvocationTargetException;
> import javax.swing.JButton;
> import javax.swing.JFrame;
> public class SetBoundsTest {
>     
>     public static void main(String[] args) throws InterruptedException, InvocationTargetException {
>         final JFrame jf = new JFrame("test");
>         final JButton jb = new JButton("1");        
>         jf.getContentPane().add(jb);
>         jf.setSize(200, 200);
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 jf.show();                
>             }
>             
>         });
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 jb.setSize(150, 500);                
>             }
>             
>         });
>         
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 System.out.println(jb.getSize());
>                 jf.dispose();           
>             }
>             
>         });
>         
>     }
> }
> On RI button size set by user(150, 500) is printed. On Harmony some other size (set by layout) is printed.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (HARMONY-1801) [classlib][swing] JComponent.setBounds() should not cause revalidation

Posted by "Dmitry A. Durnev (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1801?page=all ]

Dmitry A. Durnev updated HARMONY-1801:
--------------------------------------

    Patch Info: [Patch Available]

> [classlib][swing] JComponent.setBounds() should not cause revalidation
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-1801
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1801
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Dmitry A. Durnev
>            Priority: Minor
>         Attachments: H1801-BasicTabbedPaneUI.patch, H1801-fix.patch, H1801-tests.patch
>
>
> Validation process should not be initiated by component reshaping to avoid too
> many re-validations while doing layout (layout usually causes reshape).
> Therefore JComponent.setBounds() should not call revalidate. 
> Compile & run the following test:
> import java.awt.EventQueue;
> import java.lang.reflect.InvocationTargetException;
> import javax.swing.JButton;
> import javax.swing.JFrame;
> public class SetBoundsTest {
>     
>     public static void main(String[] args) throws InterruptedException, InvocationTargetException {
>         final JFrame jf = new JFrame("test");
>         final JButton jb = new JButton("1");        
>         jf.getContentPane().add(jb);
>         jf.setSize(200, 200);
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 jf.show();                
>             }
>             
>         });
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 jb.setSize(150, 500);                
>             }
>             
>         });
>         
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 System.out.println(jb.getSize());
>                 jf.dispose();           
>             }
>             
>         });
>         
>     }
> }
> On RI button size set by user(150, 500) is printed. On Harmony some other size (set by layout) is printed.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (HARMONY-1801) [classlib][swing] JComponent.setBounds() should not cause revalidation

Posted by "Alexey A. Ivanov (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1801?page=all ]

Alexey A. Ivanov updated HARMONY-1801:
--------------------------------------

    Attachment: HTest1801.java

HTest1801.java is slightly reworked application which was present in description of the bug.
If you run it, you'll see a button which covers all the frame. After a little while a new size is set to this button, and the button must be position of the left top corner with size 150, 50. Without the fix applied, setting its size doesn't change anything -- the button stays unchanged.

> [classlib][swing] JComponent.setBounds() should not cause revalidation
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-1801
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1801
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Dmitry A. Durnev
>         Assigned To: Mikhail Loenko
>            Priority: Minor
>         Attachments: H1801-BasicTabbedPaneUI.patch, H1801-fix.patch, H1801-tests.patch, H1801-tests.patch, HTest1801.java
>
>
> Validation process should not be initiated by component reshaping to avoid too
> many re-validations while doing layout (layout usually causes reshape).
> Therefore JComponent.setBounds() should not call revalidate. 
> Compile & run the following test:
> import java.awt.EventQueue;
> import java.lang.reflect.InvocationTargetException;
> import javax.swing.JButton;
> import javax.swing.JFrame;
> public class SetBoundsTest {
>     
>     public static void main(String[] args) throws InterruptedException, InvocationTargetException {
>         final JFrame jf = new JFrame("test");
>         final JButton jb = new JButton("1");        
>         jf.getContentPane().add(jb);
>         jf.setSize(200, 200);
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 jf.show();                
>             }
>             
>         });
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 jb.setSize(150, 500);                
>             }
>             
>         });
>         
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 System.out.println(jb.getSize());
>                 jf.dispose();           
>             }
>             
>         });
>         
>     }
> }
> On RI button size set by user(150, 500) is printed. On Harmony some other size (set by layout) is printed.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (HARMONY-1801) [classlib][swing] JComponent.setBounds() should not cause revalidation

Posted by "Dmitry A. Durnev (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1801?page=all ]

Dmitry A. Durnev updated HARMONY-1801:
--------------------------------------

    Attachment: H1801-tests.patch

Regression test for javax.swing.JComponent is attached.

> [classlib][swing] JComponent.setBounds() should not cause revalidation
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-1801
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1801
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Dmitry A. Durnev
>            Priority: Minor
>         Attachments: H1801-tests.patch
>
>
> Validation process should not be initiated by component reshaping to avoid too
> many re-validations while doing layout (layout usually causes reshape).
> Therefore JComponent.setBounds() should not call revalidate. 
> Compile & run the following test:
> import java.awt.EventQueue;
> import java.lang.reflect.InvocationTargetException;
> import javax.swing.JButton;
> import javax.swing.JFrame;
> public class SetBoundsTest {
>     
>     public static void main(String[] args) throws InterruptedException, InvocationTargetException {
>         final JFrame jf = new JFrame("test");
>         final JButton jb = new JButton("1");        
>         jf.getContentPane().add(jb);
>         jf.setSize(200, 200);
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 jf.show();                
>             }
>             
>         });
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 jb.setSize(150, 500);                
>             }
>             
>         });
>         
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 System.out.println(jb.getSize());
>                 jf.dispose();           
>             }
>             
>         });
>         
>     }
> }
> On RI button size set by user(150, 500) is printed. On Harmony some other size (set by layout) is printed.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (HARMONY-1801) [classlib][swing] JComponent.setBounds() should not cause revalidation

Posted by "Dmitry A. Durnev (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1801?page=all ]

Dmitry A. Durnev updated HARMONY-1801:
--------------------------------------

    Attachment: H1801-fix.patch

Spec of javax.swing.JInternalFrame.reshape() method states:

Unlike other components, this implementation also forces re-layout, so that frame decorations such as the title bar are always redisplayed. 

So the attached  fix makes JComponent not override setBounds() at all, but adds validate() call to JInternalFrame.setBounds() to "force re-layout".

> [classlib][swing] JComponent.setBounds() should not cause revalidation
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-1801
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1801
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Dmitry A. Durnev
>            Priority: Minor
>         Attachments: H1801-fix.patch, H1801-tests.patch
>
>
> Validation process should not be initiated by component reshaping to avoid too
> many re-validations while doing layout (layout usually causes reshape).
> Therefore JComponent.setBounds() should not call revalidate. 
> Compile & run the following test:
> import java.awt.EventQueue;
> import java.lang.reflect.InvocationTargetException;
> import javax.swing.JButton;
> import javax.swing.JFrame;
> public class SetBoundsTest {
>     
>     public static void main(String[] args) throws InterruptedException, InvocationTargetException {
>         final JFrame jf = new JFrame("test");
>         final JButton jb = new JButton("1");        
>         jf.getContentPane().add(jb);
>         jf.setSize(200, 200);
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 jf.show();                
>             }
>             
>         });
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 jb.setSize(150, 500);                
>             }
>             
>         });
>         
>         EventQueue.invokeAndWait(new Runnable(){
>             public void run() {
>                 System.out.println(jb.getSize());
>                 jf.dispose();           
>             }
>             
>         });
>         
>     }
> }
> On RI button size set by user(150, 500) is printed. On Harmony some other size (set by layout) is printed.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira