-
Bug
-
Resolution: Fixed
-
P2
-
6
-
b68
-
x86
-
windows_xp
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2150960 | 6-pool | Unassigned | P4 | Closed | Won't Fix |
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.
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.
- backported by
-
JDK-2150960 terminateEditOnFocusLost making problems for table in JDesktopPane
- Closed
- relates to
-
JDK-8039793 Focused component is in a different frame than the selected frame
- Open
-
JDK-6865565 Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
- Resolved
-
JDK-6210779 Auto transfer of focus when removing component causes problems in JTable
- Closed