-
Bug
-
Resolution: Fixed
-
P3
-
1.4.2
-
tiger
-
x86
-
windows_2000
Name: rmT116609 Date: 07/31/2003
FULL PRODUCT VERSION :
ava version "1.4.2"
ava(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
ava HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)
FULL OS VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
in table cells the Strings starting with 'W' are truncated when using a specific Cell Renderer
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
just run the code under 1.4.2
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected String 'Wine'
ACTUAL -
Got 'Wi...'
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.util.*;
public class TableTest extends javax.swing.JFrame {
/** Creates new form TableTest */
public TableTest() {
jTable1 = new JTable();
DefaultTableModel def= new DefaultTableModel(
new Object [][] {
{"Fine", "Wine"}
},
new String [] {
"OK", "Truncated"
}
);
jTable1.setModel(def);
getContentPane().removeAll();
JScrollPane jp = new JScrollPane(jTable1);
getContentPane().add(jp);
TableModel dtb = jTable1.getModel();
ColorCellRenderer cctl = new ColorCellRenderer();
for (int i =0; i<dtb.getColumnCount();i++) {
jTable1.setDefaultRenderer(jTable1.getColumnClass(i),
cctl);
}
pack();
}
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {
System.exit(0);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
new TableTest().show();
}
// Variables declaration - do not modify
private javax.swing.JTable jTable1;
// End of variables declaration
}
class ColorCellRenderer extends JPanel implements TableCellRenderer {
private JLabel label;
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col)
{
String text="";
if (value!=null)
text = value.toString();
label.setText(text);
return this;
}
public ColorCellRenderer()
{
label = new JLabel();
label.setHorizontalTextPosition(JLabel.LEFT);
setLayout(new BorderLayout());
add(label, BorderLayout.WEST);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Modify the last line to
add(label, BorderLayout.CENTER);
(Incident Review ID: 193226)
======================================================================
- relates to
-
JDK-4716362 Capital W cut off if first character in a JLabel or a JTextField
-
- Resolved
-