JDK-6505027 : terminateEditOnFocusLost making problems for table in JDesktopPane
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-12-15
  • Updated: 2018-09-12
  • Resolved: 2009-08-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b68Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0-rc"
Java(TM) SE Runtime Environment (build 1.6.0-rc-b104)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b104, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
In 6.0, first I focused the TextField, and then I tried to focus on the second columns of the table which contain JComboBox. I was not able to perform this action on the second column.

In order to focus it first I have to focus the first columns and only the the table is focused then I can go to the second columns. This implies that the JComboBox can't get focus in the JTable when we using the command row:
Jtable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);.

Note :
I havn't tried this with other components such as JCheckBox in the table.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expect to get the same results that I got when I used the previous version!

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;

class test extends JInternalFrame{

    public JTable tableView;
	public testModels testD;
	public test Test;

	public test() {
		setBounds(10,10,450,200);
//------------------------------------------------------------------------------------------
//					 SET HEADER AND DATABASE TO THE TABLE
//------------------------------------------------------------------------------------------
        Test  = this;
		Object[] val = {"",""};
		Object[] val1 = {"",""};
		Object[][] data = {val,val1};
		final String[] names = {"Size","Shape"};
//------------------------------------------------------------------------------------------
//						 CREATE A MODEL OF THE DATA.
//------------------------------------------------------------------------------------------

		testD = new testModels(names,data);

	    Container contentPane = getContentPane();
		contentPane.setLayout(null);

		Insets insets = contentPane.getInsets();

		tableView = new JTable();
		tableView.setModel(testD);

		tableView.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);//This row is the one that making the problem

        JScrollPane sp = new JScrollPane(tableView);
		sp.setBounds(20,50,400,100);
		getContentPane().add(sp);
//------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------
   		JComboBox ShapeComboBox = new JComboBox();
		ShapeComboBox.addItem("a");
    	ShapeComboBox.addItem("b");
    	ShapeComboBox.addItem("c");
    	ShapeComboBox.addItem("d");
    	TableColumn shapeColumn = tableView.getColumn("Shape");
        // Use the combo box as the editor in the "column" column.
        shapeColumn.setCellEditor(new DefaultCellEditor(ShapeComboBox));
//------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------
    	JPanel textPanel = new JPanel();
		TextField size = new TextField(30);
		textPanel.add(size);
		textPanel.setBounds(125,5,100,30);
		getContentPane().add(textPanel);
    }
}
class testModels extends AbstractTableModel
{
	public String[] names;
	public Object[][] data;
	testModels(String[] Names,Object[][] Data)
	{
		names 	  = Names;
		data 	  = Data;
	}
	public String[] getNames() {return names;}
	public int getColumnCount() { return (getNames()).length; }
	public String getColumnName(int column)
	{
    	String str = getNames()[column];
    	return str;
  	}
  	public int getRowCount()
	{
		try
		{
			return data.length;
		}
		catch(Exception e)
		{
			return 0;
		}
	}
	public Object getValueAt(int row, int col)
	{
		return data[row][col];
	}
	public boolean isCellEditable(int row, int col)
	{
		return true;
	}
	public void setValueAt(Object aValue, int row, int column)
	{
	}
}
class testMain extends JFrame
{
	testMain()
	{
    	JDesktopPane desk = new JDesktopPane();
    	test JIF = new test();
		desk.add(JIF, new Integer(1));
		try
		{
	    	((JInternalFrame)JIF).setSelected(true);
		}
		catch (java.beans.PropertyVetoException e2) {}
		JIF.show();
		getContentPane().add(desk);
	}
	public static void main(String args[])
	{
		testMain main = new testMain();
		main.setSize(500,250);
		main.setVisible(true);
	}
}
---------- END SOURCE ----------

Release Regression From : 5.0u9
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

Comments
EVALUATION The bug started in jdk6 b46.
08-08-2007

EVALUATION Regression From : 5.0u9
12-07-2007

EVALUATION This appears to be a regression caused by the addition of code to JInternalFrame to restore focus on selection. Re-assigning to the JInternalFrame owner.
21-03-2007

EVALUATION This may be the same problem as 6210779.
18-12-2006