-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reviewed-by: honkar, prr
- Loading branch information
Alisen Chung
committed
Sep 23, 2023
1 parent
68a9c81
commit d2d7d9a
Showing
3 changed files
with
228 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
/* | ||
* @test | ||
* @bug 4688907 | ||
* @summary ScrollPaneLayout.minimumLayoutSize incorrectly compares hsbPolicy | ||
*/ | ||
|
||
import java.awt.Dimension; | ||
import javax.swing.JScrollPane; | ||
|
||
public class bug4688907 { | ||
public static void main(String[] args) throws Exception { | ||
JScrollPane sp = new JScrollPane(); | ||
Dimension d1 = sp.getMinimumSize(); | ||
sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); | ||
Dimension d2 = sp.getMinimumSize(); | ||
if (d1.height == d2.height) { | ||
throw new RuntimeException("The scrollbar minimum size doesn't take " + | ||
"into account horizontal scrollbar policy"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
/* | ||
* @test | ||
* @bug 4756178 | ||
* @summary SpringLayout:applyDefaults() discards size information when right-aligning. | ||
* @key headful | ||
*/ | ||
|
||
import java.awt.Dimension; | ||
import java.awt.Robot; | ||
import javax.swing.JButton; | ||
import javax.swing.JFrame; | ||
import javax.swing.JPanel; | ||
import javax.swing.Spring; | ||
import javax.swing.SpringLayout; | ||
import javax.swing.SwingUtilities; | ||
|
||
public class bug4756178 { | ||
static JFrame fr; | ||
static JButton bt; | ||
static volatile Dimension buttonPreferredSize; | ||
static volatile Dimension actualSize; | ||
|
||
public static void main(String[] args) throws Exception { | ||
try { | ||
SwingUtilities.invokeAndWait(() -> { | ||
fr = new JFrame("bug4756178"); | ||
JPanel p = (JPanel) fr.getContentPane(); | ||
SpringLayout layout = new SpringLayout(); | ||
p.setLayout(layout); | ||
|
||
SpringLayout.Constraints cc = new SpringLayout.Constraints(); | ||
cc.setConstraint("East", | ||
Spring.sum(Spring.constant(-20), | ||
layout.getConstraint("East", p))); | ||
cc.setConstraint("South", | ||
Spring.sum(Spring.constant(-20), | ||
layout.getConstraint("South", p))); | ||
|
||
bt = new JButton(); | ||
|
||
buttonPreferredSize = new Dimension(20, 20); | ||
bt.setPreferredSize(buttonPreferredSize); | ||
p.add(bt, cc); | ||
|
||
fr.setSize(200, 200); | ||
fr.setLocationRelativeTo(null); | ||
fr.setVisible(true); | ||
}); | ||
|
||
Robot robot = new Robot(); | ||
robot.waitForIdle(); | ||
robot.delay(1000); | ||
|
||
SwingUtilities.invokeAndWait(() -> { | ||
actualSize = bt.getSize(); | ||
}); | ||
|
||
if (!buttonPreferredSize.equals(actualSize)) { | ||
throw new RuntimeException("Button size is " + actualSize + | ||
", should be " + buttonPreferredSize); | ||
} | ||
} finally { | ||
SwingUtilities.invokeAndWait(() -> { | ||
if (fr != null) { | ||
fr.dispose(); | ||
} | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
/* | ||
* @test | ||
* @bug 4803649 | ||
* @summary setWidth() doesn't work on the container in a SpringLayout | ||
* @key headful | ||
*/ | ||
|
||
import java.awt.Dimension; | ||
import java.awt.Robot; | ||
import javax.swing.JFrame; | ||
import javax.swing.JPanel; | ||
import javax.swing.JTextArea; | ||
import javax.swing.Spring; | ||
import javax.swing.SpringLayout; | ||
import javax.swing.SwingUtilities; | ||
|
||
public class bug4803649 { | ||
static JFrame fr; | ||
static JPanel panel; | ||
|
||
public static void main(String[] args) throws Exception { | ||
try { | ||
SwingUtilities.invokeAndWait(() -> { | ||
fr = new JFrame("bug4803649"); | ||
|
||
panel = new JPanel(); | ||
SpringLayout layout = new SpringLayout(); | ||
panel.setLayout(layout); | ||
|
||
JTextArea textArea = new JTextArea("asasddsa"); | ||
textArea.setPreferredSize(new Dimension(200, 200)); | ||
panel.add(textArea); | ||
SpringLayout.Constraints cCons = layout.getConstraints(textArea); | ||
cCons.setX(Spring.constant(10)); | ||
cCons.setY(Spring.constant(10)); | ||
|
||
SpringLayout.Constraints pCons = layout.getConstraints(panel); | ||
pCons.setWidth(Spring.sum(Spring.constant(10), | ||
cCons.getConstraint("East"))); | ||
pCons.setHeight(Spring.sum(Spring.constant(10), | ||
cCons.getConstraint("South"))); | ||
|
||
fr.getContentPane().add(panel); | ||
|
||
fr.setLocationRelativeTo(null); | ||
fr.pack(); | ||
fr.setVisible(true); | ||
}); | ||
|
||
Robot r = new Robot(); | ||
r.waitForIdle(); | ||
r.delay(1000); | ||
|
||
SwingUtilities.invokeAndWait(() -> { | ||
Dimension d = panel.getSize(); | ||
if (d.width < 220 || d.height < 220) { | ||
throw new RuntimeException("JPanel with the SpringLayout is too small"); | ||
} | ||
}); | ||
} finally { | ||
SwingUtilities.invokeAndWait(() -> { | ||
if (fr != null) { | ||
fr.dispose(); | ||
} | ||
}); | ||
} | ||
} | ||
} |
d2d7d9a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review
Issues
d2d7d9a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/backport jdk21u-dev
d2d7d9a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SoniaZaldana the backport was successfully created on the branch backport-SoniaZaldana-d2d7d9a8-master in my personal fork of openjdk/jdk21u-dev. To create a pull request with this backport targeting openjdk/jdk21u-dev:master, just click the following link:
➡️ Create pull request
The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:
If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u-dev:
d2d7d9a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/backport jdk17u-dev
d2d7d9a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GoeLin the backport was successfully created on the branch backport-GoeLin-d2d7d9a8-master in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:
➡️ Create pull request
The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:
If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev: