-
Bug
-
Resolution: Fixed
-
P2
-
6
-
b86
-
b94
-
x86
-
windows_xp
FULL PRODUCT VERSION :
1.6.0-rc-b87
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP Professional Version 2002 SP2 with all updates applied.
A DESCRIPTION OF THE PROBLEM :
When a JTable has a column with a width of 0 clicking on one row isn't highliting the row itself but some of the columns instead.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.Create a JTable with a column that has a JTable header set to 0 using table.getTableHeader().getColumnModel().getColumn(col).setMaxWidth(0);
table.getTableHeader().getColumnModel().getColumn(col.setPreferredWidth(0);
2. Set the size of the column to the minimum size using the GUI.
3. Click on any row you will see that not all the row is being highlited
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The expected result when clicking on a row in a JTable is to highlite the whole row.
ACTUAL -
A highlite of some of the columns.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;
/*
* Created on 19-Jun-06
*
* Copyright (c) Carl Antaki. All rights reserved
*
*/
public class JTableHighliteBug extends JPanel{
JTable table;
DefaultTableModel model;
String[] col = {"One","Two","Hidden"};
public JTableHighliteBug(){
setLayout(new BorderLayout());
model = new DefaultTableModel();
table = new JTable(model);
model.setColumnIdentifiers(col);
Object[] obj= new Object[3];
obj[0]="1";
obj[1]="2";
obj[2]="3";
model.addRow(obj);
model.addRow(obj);
table.getTableHeader().getColumnModel().getColumn(2).setMinWidth(0);
table.getTableHeader().getColumnModel().getColumn(2).setPreferredWidth(0);
add(new JScrollPane(table),BorderLayout.CENTER);
}
public static void main(String[] args){
SwingUtilities.invokeLater(new Runnable(){
public void run(){
createAndShowGUI();
}
});
}
public static void createAndShowGUI(){
JFrame frame = new JFrame("JTable Highlite Bug");
frame.setContentPane(new JTableHighliteBug());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
Release Regression From : 5.0u7
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.
1.6.0-rc-b87
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP Professional Version 2002 SP2 with all updates applied.
A DESCRIPTION OF THE PROBLEM :
When a JTable has a column with a width of 0 clicking on one row isn't highliting the row itself but some of the columns instead.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.Create a JTable with a column that has a JTable header set to 0 using table.getTableHeader().getColumnModel().getColumn(col).setMaxWidth(0);
table.getTableHeader().getColumnModel().getColumn(col.setPreferredWidth(0);
2. Set the size of the column to the minimum size using the GUI.
3. Click on any row you will see that not all the row is being highlited
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The expected result when clicking on a row in a JTable is to highlite the whole row.
ACTUAL -
A highlite of some of the columns.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;
/*
* Created on 19-Jun-06
*
* Copyright (c) Carl Antaki. All rights reserved
*
*/
public class JTableHighliteBug extends JPanel{
JTable table;
DefaultTableModel model;
String[] col = {"One","Two","Hidden"};
public JTableHighliteBug(){
setLayout(new BorderLayout());
model = new DefaultTableModel();
table = new JTable(model);
model.setColumnIdentifiers(col);
Object[] obj= new Object[3];
obj[0]="1";
obj[1]="2";
obj[2]="3";
model.addRow(obj);
model.addRow(obj);
table.getTableHeader().getColumnModel().getColumn(2).setMinWidth(0);
table.getTableHeader().getColumnModel().getColumn(2).setPreferredWidth(0);
add(new JScrollPane(table),BorderLayout.CENTER);
}
public static void main(String[] args){
SwingUtilities.invokeLater(new Runnable(){
public void run(){
createAndShowGUI();
}
});
}
public static void createAndShowGUI(){
JFrame frame = new JFrame("JTable Highlite Bug");
frame.setContentPane(new JTableHighliteBug());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
Release Regression From : 5.0u7
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.
- duplicates
-
JDK-6442400 JTable select highlights random cells if zero column width present
- Closed