-
Bug
-
Resolution: Fixed
-
P3
-
8u20
-
b65
-
x86_64
-
windows_7
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8084890 | emb-9 | Alexandr Scherbatiy | P3 | Resolved | Fixed | team |
JDK-8268550 | openjdk8u312 | Alexandr Scherbatiy | P3 | Resolved | Fixed | b01 |
JDK-8259280 | 8u291 | Suman Rajkumaar Kodandarama | P3 | Closed | Fixed | b01 |
JDK-8262637 | emb-8u291 | Suman Rajkumaar Kodandarama | P3 | Resolved | Fixed | team |
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
Recent implementation of JComboBox.actionPerformed(ActionEvent e) in Java 1.8 checks that the given ActionEvent source is identical with ComboBoxEditor editor returned by getEditor().
In the same Java version EditorDelegate implementation used in DefaultCellEditor(final JComboBox comboBox) generates ActionEvent using DefaultCellEditor.this as its source in its method stopCellEditing()
comboBox.actionPerformed(new ActionEvent(
DefaultCellEditor.this, 0, ""));
ComboBoxEditor and DefaultCellEditor are different things.
Therefore this call is ignored by JComboBox in the recent Java version. Implementation of stopCellEditing in this EditorDelegate should be fixed.
REGRESSION. Last worked in version 7u75
ADDITIONAL REGRESSION INFORMATION:
java version "1.7.0_75"
Java(TM) SE Runtime Environment (build 1.7.0_75-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the following application.
Click at cell "Kathy" , replace its content by text "Andrew". Do not hit "Enter".
Then click at cell "Smith" and replace its content by text "Brown" . Do not hit "Enter".
Then click at cell "John", and replace its content by text "Robert" . Press TAB.
// CODE BEGIN
/*
* Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
* Modified by Dimitry Polivaev, 2015
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of Oracle or the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package components;
/*
* SimpleTableDemo.java requires no other files.
*/
import javax.swing.DefaultCellEditor;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class SimpleTableDemo extends JPanel {
public SimpleTableDemo() {
super(new GridLayout(1,0));
String[] columnNames = {"First Name",
"Last Name"};
Object[][] data = {
{"Kathy", "Smith"},
{"John", "Doe"}};
final JTable table = new JTable(data, columnNames);
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
table.setFillsViewportHeight(true);
final JComboBox<Object> comboBox = new JComboBox<>();
comboBox.setEditable(true);
table.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(comboBox));
table.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(new JTextField()));
//Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);
//Add the scroll pane to this panel.
add(scrollPane);
}
/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
*/
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("SimpleTableDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create and set up the content pane.
SimpleTableDemo newContentPane = new SimpleTableDemo();
newContentPane.setOpaque(true); //content panes must be opaque
frame.setContentPane(newContentPane);
//Display the window.
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
// CODE END
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The first table row should contain cells with content "Andrew" and "Brown".
The second line should contain cells with content "Robert" and "Doe".
ACTUAL -
The first table row contains cells with content "Smith" and "Brown".
The second line should contain cells with content "John" and "Doe
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
Use following combobox implementation:
final JComboBox<Object> comboBox = new JComboBox(){
@Override
public void actionPerformed(ActionEvent e) {
if(e != null && e.getSource() == table.getCellEditor())
super.actionPerformed(new ActionEvent(getEditor(), e.getID(), e.getActionCommand(),e.getWhen(),e.getModifiers()));
else
super.actionPerformed(e);
};
- backported by
-
JDK-8084890 DefaultCellEditor for comboBox creates ActionEvent with wrong source object
-
- Resolved
-
-
JDK-8262637 DefaultCellEditor for comboBox creates ActionEvent with wrong source object
-
- Resolved
-
-
JDK-8268550 DefaultCellEditor for comboBox creates ActionEvent with wrong source object
-
- Resolved
-
-
JDK-8259280 DefaultCellEditor for comboBox creates ActionEvent with wrong source object
-
- Closed
-
- duplicates
-
JDK-8068047 JTable - JComboBox edit problem
-
- Closed
-
-
JDK-8144765 DefaultCellEditor doesn't save edited JComboBox value on focus lost
-
- Closed
-
-
JDK-8243282 Enter some text and click into another cell,it reverts to the old, unedited text
-
- Closed
-
- relates to
-
JDK-8019180 Use JComboBox as it's own ActionListener leads to unexpected behaviour
-
- Resolved
-
-
JDK-8057893 JComboBox actionListener never receives "comboBoxEdited" from getActionCommand
-
- Resolved
-
-
JDK-8196093 javax/swing/JComboBox/8072767/bug8072767.java fails
-
- Resolved
-
-
JDK-8264327 Add "headful" to javax/swing/JComboBox/8072767/bug8072767.java
-
- Resolved
-