-
Notifications
You must be signed in to change notification settings - Fork 5.9k
8353007: Open some JComboBox bugs 2 #24496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3b3429e
opening tests
alisenchung babbf9d
add rows
alisenchung e5a9f29
add rows, remove headful key
alisenchung 97c86bb
update jtreg
alisenchung 24f40dd
update tests
alisenchung ea99d06
update to PassFailJFrame.forceFail
alisenchung d7bba18
update to PassFailJFrame.forceFail
alisenchung e53b046
reduce number of rows
alisenchung 233430f
Merge branch 'master' of https://github.com/openjdk/jdk into 2025tsb_2
alisenchung 453a0e6
update tests
alisenchung a4471e5
manual tag
alisenchung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,110 @@ | ||
/* | ||
* Copyright (c) 1998, 2025, 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. | ||
*/ | ||
|
||
import java.awt.BorderLayout; | ||
import java.awt.Point; | ||
import javax.swing.JComboBox; | ||
import javax.swing.JComponent; | ||
import javax.swing.JDesktopPane; | ||
import javax.swing.JFrame; | ||
import javax.swing.JInternalFrame; | ||
import javax.swing.JPanel; | ||
|
||
/* | ||
* @test | ||
* @bug 4185024 | ||
* @summary Tests that Heavyweight combo boxes on JDesktop work correctly | ||
* @library /java/awt/regtesthelpers | ||
* @build PassFailJFrame | ||
* @run main/manual bug4185024 | ||
*/ | ||
|
||
public class bug4185024 { | ||
private static final String INSTRUCTIONS = """ | ||
Click on the JComboBox button inside the JInternalFrame to bring up the menu. | ||
Select one of the menu items and verify that the choice is highlighted correctly. | ||
Click on the menu's scroll bar and verify that it causes the menu to scroll down. | ||
|
||
Inside JInternalFrame: | ||
This test is for the JComboBox in the JInternalFrame. | ||
To test, please click on the combobox and check the following: | ||
Does the selection in the popup list follow the mouse? | ||
Does the popup list respond to clicking and dragging the scroll bar? | ||
If so, press PASS, otherwise, press FAIL. | ||
"""; | ||
|
||
public static void main(String[] args) throws Exception { | ||
PassFailJFrame.builder() | ||
.instructions(INSTRUCTIONS) | ||
.columns(50) | ||
.testUI(bug4185024::createTestUI) | ||
.build() | ||
.awaitAndCheck(); | ||
} | ||
|
||
public static JFrame createTestUI() { | ||
JFrame frame = new JFrame("bug4185024"); | ||
JPanel p = new JPanel(); | ||
p.setLayout(new BorderLayout()); | ||
JDesktopPane desktop = new JDesktopPane(); | ||
p.add(desktop); | ||
frame.add(p); | ||
|
||
JComboBox months = new JComboBox(); | ||
months.addItem("January"); | ||
months.addItem("February"); | ||
months.addItem("March"); | ||
months.addItem("April"); | ||
months.addItem("May"); | ||
months.addItem("June"); | ||
months.addItem("July"); | ||
months.addItem("August"); | ||
months.addItem("September"); | ||
months.addItem("October"); | ||
months.addItem("November"); | ||
months.addItem("December"); | ||
months.getAccessibleContext().setAccessibleName("Months"); | ||
months.getAccessibleContext().setAccessibleDescription("Choose a month of the year"); | ||
|
||
// Set this to true and the popup works correctly... | ||
months.setLightWeightPopupEnabled(false); | ||
|
||
addFrame("Months", desktop, months); | ||
|
||
frame.setSize(300, 300); | ||
frame.setLocationRelativeTo(null); | ||
return frame; | ||
} | ||
|
||
private static void addFrame(String title, JDesktopPane desktop, JComponent component) { | ||
JInternalFrame jf = new JInternalFrame(title); | ||
Point newPos = new Point(20, 20); | ||
jf.setResizable(true); | ||
jf.getContentPane().add(component); | ||
jf.setLocation(newPos); | ||
desktop.add(jf); | ||
|
||
jf.pack(); | ||
jf.show(); | ||
} | ||
} |
This file contains hidden or 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,80 @@ | ||
/* | ||
* Copyright (c) 1999, 2025, 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. | ||
*/ | ||
|
||
import javax.swing.JComboBox; | ||
import javax.swing.JFrame; | ||
import javax.swing.JPanel; | ||
import javax.swing.UIManager; | ||
|
||
/* | ||
* @test | ||
* @bug 4201964 | ||
* @summary Tests that JComboBox's arrow button isn't drawn too wide in Windows Look&Feel | ||
* @requires (os.family == "windows") | ||
* @library /java/awt/regtesthelpers | ||
* @build PassFailJFrame | ||
* @run main/manual bug4201964 | ||
*/ | ||
|
||
public class bug4201964 { | ||
private static final String INSTRUCTIONS = """ | ||
Does the arrow look too large? If not, it passes. | ||
Since we can't use real html in here, I can't give you | ||
any pictures to compare against. | ||
"""; | ||
|
||
public static void main(String[] args) throws Exception { | ||
try { | ||
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); | ||
} catch (Exception e) { | ||
PassFailJFrame.forceFail("Couldn't load the Windows look and feel."); | ||
} | ||
|
||
PassFailJFrame.builder() | ||
.instructions(INSTRUCTIONS) | ||
.rows(30) | ||
.columns(30) | ||
.testUI(bug4201964::createTestUI) | ||
.build() | ||
.awaitAndCheck(); | ||
} | ||
|
||
public static JFrame createTestUI() { | ||
JFrame frame = new JFrame("bug4201964"); | ||
JPanel panel = new JPanel(); | ||
JComboBox comboBox; | ||
|
||
comboBox = new JComboBox(new Object[]{ | ||
"Coma Berenices", | ||
"Triangulum", | ||
"Camelopardis", | ||
"Cassiopea"}); | ||
|
||
panel.add(comboBox); | ||
|
||
frame.add(panel); | ||
frame.pack(); | ||
alisenchung marked this conversation as resolved.
Show resolved
Hide resolved
|
||
frame.setLocationRelativeTo(null); | ||
return frame; | ||
} | ||
} |
This file contains hidden or 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,74 @@ | ||
/* | ||
* Copyright (c) 1999, 2025, 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. | ||
*/ | ||
|
||
import java.awt.BorderLayout; | ||
import javax.swing.JComboBox; | ||
import javax.swing.JFrame; | ||
import javax.swing.UIManager; | ||
|
||
import jtreg.SkippedException; | ||
|
||
/* | ||
* @test | ||
* @bug 4249732 | ||
* @requires (os.family == "windows") | ||
* @summary Tests that Windows editable combo box selects text picked from its list | ||
* @library /java/awt/regtesthelpers /test/lib | ||
* @build PassFailJFrame | ||
* @run main bug4249732 | ||
*/ | ||
|
||
public class bug4249732 { | ||
private static final String INSTRUCTIONS = """ | ||
Click on combo box arrow button to open its dropdown list, and | ||
select an item from there. The text in the combo box editor should | ||
be selected, otherwise test fails. | ||
"""; | ||
|
||
public static void main(String[] args) throws Exception { | ||
try { | ||
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); | ||
} catch (Exception e) { | ||
throw new jtreg.SkippedException("Couldn't load the Windows look and feel."); | ||
} | ||
PassFailJFrame.builder() | ||
.instructions(INSTRUCTIONS) | ||
.rows(30) | ||
.columns(40) | ||
.testUI(bug4249732::createTestUI) | ||
.build() | ||
.awaitAndCheck(); | ||
} | ||
alisenchung marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public static JFrame createTestUI() { | ||
JFrame frame = new JFrame("bug4249732"); | ||
|
||
JComboBox cb = new JComboBox(new Object[]{"foo", "bar", "baz"}); | ||
cb.setEditable(true); | ||
|
||
frame.add(cb, BorderLayout.NORTH); | ||
frame.pack(); | ||
frame.setLocationRelativeTo(null); | ||
return frame; | ||
} | ||
} |
This file contains hidden or 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,125 @@ | ||
/* | ||
* Copyright (c) 2000, 2025, 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. | ||
*/ | ||
|
||
import javax.swing.DefaultCellEditor; | ||
import javax.swing.JComboBox; | ||
import javax.swing.JFrame; | ||
import javax.swing.JScrollPane; | ||
import javax.swing.JTable; | ||
import javax.swing.table.AbstractTableModel; | ||
|
||
/* | ||
* @test | ||
* @bug 4368848 | ||
* @summary Tests that mouse wheel events cancel popups | ||
* @library /java/awt/regtesthelpers | ||
* @build PassFailJFrame | ||
* @run main bug4368848 | ||
*/ | ||
|
||
public class bug4368848 { | ||
static final String[] names = {"First Name", "Last Name", "Veggy"}; | ||
static Object[][] data = { | ||
{"Mark", "Andrews", false}, | ||
{"Tom", "Ball", false}, | ||
{"Alan", "Chung", false}, | ||
{"Jeff", "Dinkins", false}, | ||
{"Amy", "Fowler", false}, | ||
{"Brian", "Gerhold", false}, | ||
{"James", "Gosling", false}, | ||
{"David", "Karlton", false}, | ||
{"Dave", "Kloba", false}, | ||
{"Peter", "Korn", false}, | ||
{"Phil", "Milne", false}, | ||
{"Dave", "Moore", false}, | ||
{"Hans", "Muller", false}, | ||
{"Rick", "Levenson", false}, | ||
{"Tim", "Prinzing", false}, | ||
{"Chester", "Rose", false}, | ||
{"Ray", "Ryan", false}, | ||
{"Georges", "Saab", false}, | ||
{"Willie", "Walker", false}, | ||
{"Kathy", "Walrath", false}, | ||
{"Arnaud", "Weber", false} | ||
}; | ||
|
||
private static final String INSTRUCTIONS = """ | ||
Click any cell in the 'Veggy' column, so that combo box appears. | ||
Make sure mouse pointer is over the table, but _not_ over the combo | ||
box. Try scrolling the table using the mouse wheel. The combo popup | ||
should disappear. If it stays visible, test fails. | ||
"""; | ||
|
||
public static void main(String[] args) throws Exception { | ||
PassFailJFrame.builder() | ||
.instructions(INSTRUCTIONS) | ||
.columns(50) | ||
.testUI(bug4368848::createTestUI) | ||
.build() | ||
.awaitAndCheck(); | ||
} | ||
|
||
public static JFrame createTestUI() { | ||
JFrame frame = new JFrame("bug4368848"); | ||
ExampleTableModel dataModel = new ExampleTableModel(); | ||
|
||
JComboBox _editor = new JComboBox(); | ||
_editor.addItem(false); | ||
_editor.addItem(true); | ||
|
||
JTable tableView = new JTable(dataModel); | ||
tableView.setDefaultEditor(Boolean.class, new DefaultCellEditor(_editor)); | ||
|
||
frame.getContentPane().add(new JScrollPane(tableView)); | ||
frame.setSize(200, 200); | ||
frame.setLocationRelativeTo(null); | ||
return frame; | ||
} | ||
|
||
static class ExampleTableModel extends AbstractTableModel { | ||
// These methods always need to be implemented. | ||
public int getColumnCount() { | ||
return names.length; | ||
} | ||
|
||
public int getRowCount() { | ||
return data.length; | ||
} | ||
|
||
public Object getValueAt(int row, int col) { | ||
return data[row][col]; | ||
} | ||
|
||
public boolean isCellEditable(int row, int col) { | ||
return true; | ||
} | ||
|
||
public String getColumnName(int column) { | ||
return names[column]; | ||
} | ||
|
||
public Class getColumnClass(int col) { | ||
return getValueAt(0, col).getClass(); | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.