Jim C. wrote: > OK, so there is this bug in Sun's JTable. > Calling JTable.setEnabled(false) doesn't also cause the table header's > appearance to changed. It functions properly but there is no visible > change in the header. > > Question: > > What are some good ways to change appearance based on enabled/disabled > state? I.E. how should the foreground/background colors change? I > would think that they should have White added to them if they are disabled.
Today, I have an answer for this. Observe this clip which I found at http://www.chka.de/swing/table/faq.html : > Why doesn't the JTable appear "greyed-out" when it is set to disabled? > > The default renderers don't react to the JTable's enabled state. Since the > renderers don't react to user input anyway, it is only a matter of > apperarance. It is not possible to adjust the default renderers (those for > Numbers, Booleans, Date, the header renderer) in any way. Custom renderers > should always adjust the renderer components like this: > > class FixedTableCellRenderer > extends DefaultTableCellRenderer > { > public Component getTableCellRendererComponent > (JTable table, Object value, boolean selected, boolean focused, int > row, int column) > { > setEnabled(table == null || table.isEnabled()); > > super.getTableCellRendererComponent(table, value, selected, focused, > row, column); > > return this; > } > } Since we were using the TableSorter example provided by Sun for tables that can sort themselves by columns, all that was required was the addition of a single line from the above: setEnabled(table == null || table.isEnabled()); This was added to our implementation of getTableCellRendererComponent and viola! Now the table header looks disabled when it has been. :-) Jim. ---------------------------------------------------------------------- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]