|
Replies:
0
|
|
|
|
|
|
|
Problem with Windows PLAF when switching PLAF
Posted:
Dec 9, 2006 5:37 AM
|
|
|
I have found that if I use a custom table header then the UI that is selected when switching look and feels is incorrect for the Windows look and feel. Specifically, if I create a JTable using Ocean look and feel and then switch to Windows look and feel on a Windows XP machine at run time, the table header takes on the appearance of a Windows Classic header instead of a Windows XP header. Even when I simplify the custom header to little more than a default header the same problem happens. Here's my stripped-down custom header:
public class MyTableHeader extends JTableHeader { public MyTableHeader(TableColumnModel tableColumnModel) { super(tableColumnModel);
setDefaultRenderer(new MyRenderer(getDefaultRenderer())); }
private class MyRenderer implements TableCellRenderer { private TableCellRenderer tableCellRenderer;
public MyRenderer(TableCellRenderer tcr) { this.tableCellRenderer = getDefaultRenderer(); }
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,int row, int column) { Component c = tableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); return c; } } }
The problem seems to relate to the use of a table cell renderer as if I comment-out the line to set the default renderer then everything is OK (except that I cannot do all the other things that I am trying to do with the header). So I need to be able to set the default renderer to my own renderer and yet not have a Windows Classic UI appear when switching look and feels. If I simply start with Windows look and feel and create the table then it renders the headers correctly; it's only switching look and feels that is a problem.
Can anyone suggest what I am doing wrongly or confirm that it is actually a bug in the JDK? I am using Java 6.0 b104.
-- And loving it,
qu0ll ______________________________________________ qu0llSixFour@gmail.com (Replace the "SixFour" with numbers to email)
|
|
|
|