mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-27 10:40:29 +00:00
8353007: Open some JComboBox bugs 2
Reviewed-by: kizune, honkar
This commit is contained in:
parent
477da161e6
commit
1889dacb19
109
test/jdk/javax/swing/JComboBox/bug4185024.java
Normal file
109
test/jdk/javax/swing/JComboBox/bug4185024.java
Normal file
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* 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 and drag the menu's scroll bar down 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);
|
||||
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.add(component);
|
||||
jf.setLocation(newPos);
|
||||
desktop.add(jf);
|
||||
|
||||
jf.pack();
|
||||
jf.show();
|
||||
}
|
||||
}
|
||||
77
test/jdk/javax/swing/JComboBox/bug4201964.java
Normal file
77
test/jdk/javax/swing/JComboBox/bug4201964.java
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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.
|
||||
""";
|
||||
|
||||
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(8)
|
||||
.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();
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
72
test/jdk/javax/swing/JComboBox/bug4249732.java
Normal file
72
test/jdk/javax/swing/JComboBox/bug4249732.java
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4249732
|
||||
* @requires (os.family == "windows")
|
||||
* @summary Tests that Windows editable combo box selects text picked from its list
|
||||
* @library /java/awt/regtesthelpers
|
||||
* @build PassFailJFrame
|
||||
* @run main/manual 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) {
|
||||
PassFailJFrame.forceFail("Couldn't load the Windows look and feel.");
|
||||
}
|
||||
|
||||
PassFailJFrame.builder()
|
||||
.instructions(INSTRUCTIONS)
|
||||
.rows(8)
|
||||
.columns(40)
|
||||
.testUI(bug4249732::createTestUI)
|
||||
.build()
|
||||
.awaitAndCheck();
|
||||
}
|
||||
|
||||
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();
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
129
test/jdk/javax/swing/JComboBox/bug4368848.java
Normal file
129
test/jdk/javax/swing/JComboBox/bug4368848.java
Normal file
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* 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/manual 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.add(new JScrollPane(tableView));
|
||||
frame.setSize(200, 200);
|
||||
return frame;
|
||||
}
|
||||
|
||||
static class ExampleTableModel extends AbstractTableModel {
|
||||
// These methods always need to be implemented.
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return names.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return data.length;
|
||||
}
|
||||
|
||||
public Object getValueAt(int row, int col) {
|
||||
return data[row][col];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellEditable(int row, int col) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnName(int column) {
|
||||
return names[column];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getColumnClass(int col) {
|
||||
return getValueAt(0, col).getClass();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user