On Wed, 4 Oct 2023 05:48:59 GMT, Prasanta Sadhukhan <[email protected]> wrote:
>> SwingNode does not update its internal cache of Swing pref/max/min height >> and widths when its JComponent content's corresponding size constraints are >> updated. As such, it isn't resized to honor those size constraints. >> >> JLightweightFrame does install a PropertyChangeListener for "preferredSize", >> "maximumSize", and "minimumSize" properties, but this only happens via a >> ContainerListener which is not added until after the content has already >> been added to the content pane, and since the application cannot call this >> methods directly as per the documentation for the SwingNode.resize() method: >> `Applications should not invoke this method directly. If an application >> needs to directly set the size of the SwingNode, it should set the Swing >> component's minimum/preferred/maximum size constraints which will be >> propagated correspondingly to the SwingNode and it's parent will honor those >> settings during layout.` >> >> so the fix is to add the listener as soon as the component is added to the >> JLightweightFrame's content. > > Prasanta Sadhukhan has updated the pull request incrementally with one > additional commit since the last revision: > > Register listener before component add > What puzzles me is that I am getting inconsistent results. Run the test, see > the button, clicked once - the button disappears. Moved the window to another > sceen - the button appears in the corner. Clicked on the button - now I see > two buttons (corrupted screen buffer)? > > Of course, I might be doing something wrong. My command line: > > ``` > /Users/angorya/Projects/jdk/build/macosx-aarch64-client-release/jdk/bin/java > -XX:+ShowCodeDetailsInExceptionMessages -ea > -Djava.library.path=/Users/angorya/Projects/jfx3/jfx/rt/build/sdk/lib > -Dfile.encoding=UTF-8 -p > /Users/angorya/Projects/Test3/Test/bin:/Users/angorya/Projects/jfx3/jfx/rt/modules/javafx.base/bin:/Users/angorya/Projects/jfx3/jfx/rt/modules/javafx.controls/bin:/Users/angorya/Projects/jfx3/jfx/rt/modules/javafx.graphics/bin:/Users/angorya/Projects/jfx3/jfx/rt/modules/javafx.fxml/bin:/Users/angorya/Projects/jfx3/jfx/rt/modules/javafx.media/bin:/Users/angorya/Projects/jfx3/jfx/rt/modules/javafx.swing/bin:/Users/angorya/Projects/jfx3/jfx/rt/modules/javafx.web/bin > -classpath > /Applications/Eclipse.app/Contents/Eclipse/plugins/junit-jupiter-api_5.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-jupiter-engine_5.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-jupiter-migrationsupport_5.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugi ns/junit-jupiter-params_5.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-platform-commons_1.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-platform-engine_1.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-platform-launcher_1.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-platform-runner_1.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-platform-suite-api_1.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-platform-suite-engine_1.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-platform-suite-commons_1.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-vintage-engine_5.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/org.opentest4j_1.2.0.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/org.apiguardian.api_1.1.2.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/org.junit_4.13.2.v20211018-1956.jar:/Applications/Eclipse.app/Contents/Ec lipse/plugins/org.hamcrest.core_1.3.0.v20180420-1519.jar --add-reads javafx.base=java.management --add-reads javafx.base=jdk.management --add-exports javafx.graphics/test.com.sun.javafx.pgstub=javafx.controls --add-exports javafx.base/test.com.sun.javafx.binding=javafx.controls --add-exports javafx.base/test.util.memory=javafx.controls --add-exports javafx.base/test.javafx.collections=javafx.controls --add-exports javafx.base/com.sun.javafx.property=javafx.graphics --add-exports javafx.base/test.util.memory=javafx.graphics --add-exports java.base/sun.security.util=javafx.graphics --add-reads javafx.base=java.management --add-reads javafx.base=jdk.management --add-reads javafx.base=java.management --add-reads javafx.base=jdk.management --add-reads javafx.fxml=javafx.controls --add-exports javafx.base/com.sun.javafx.collections=javafx.fxml --add-exports javafx.graphics/test.com.sun.javafx.pgstub=javafx.controls --add-exports javafx.base/test.com.sun.javafx.binding=javafx.controls --ad d-exports javafx.base/test.util.memory=javafx.controls --add-exports javafx.base/test.javafx.collections=javafx.controls --add-exports javafx.base/com.sun.javafx.property=javafx.graphics --add-exports javafx.base/test.util.memory=javafx.graphics --add-exports java.base/sun.security.util=javafx.graphics --add-reads javafx.base=java.management --add-reads javafx.base=jdk.management --add-exports javafx.base/com.sun.javafx=javafx.web --add-exports javafx.base/test.util.memory=javafx.web --add-reads javafx.web=java.management --add-reads javafx.base=java.management --add-reads javafx.base=jdk.management -m andy_test/goryachev.apps.AppTestLauncher > ``` > >  Button appear at the corner existed before the fix also as I see in this screenshot... (SInce the size was not updated before the fix, the label was truncated but it is moved to the corner as you can see)  disappear and reappear issue seems to be due to [JDK-8298796](https://bugs.openjdk.org/browse/JDK-8298796) SwingNode rendering issue as I mentioned earlier in this PR...so I think we can ignore the unsolved rendering issue for now and see it as size update fix (although it may alleviate rendering issue to the user but maybe one fix at a time) I normally test with this command ./jdk/bin/java @E://ade//javafx//jfx//rt//build//run.args SwingNodeResize where run.args is --module-path="E:/ade/javafx/jfx/rt/build/sdk/lib" --add-modules=javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web ------------- PR Comment: https://git.openjdk.org/jdk/pull/15960#issuecomment-1750015938
