The Source for Java Technology Collaboration

Home » java.net Forums » Java Desktop Technologies » SwingLabs

Thread: Disabled JXTable now looks ... disabled

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 6 - Last Post: Mar 13, 2007 4:19 AM by: kleopatra
kleopatra

Posts: 1,677
Disabled JXTable now looks ... disabled
Posted: Jan 30, 2007 5:17 AM
  Click to reply to this thread Reply

as a (intended :-) side-effect of the SwingX renderer streamlining cells of a disabled table are disabled. That's a fix for a slightly dated issue

https://swingx.dev.java.net/issues/show_bug.cgi?id=282

in-line with the general quest for consistency across collection views in SwingX.

An open part of that issue is header appearance of a disabled table. Which boils down to whether the header's enabled state should be synched to the table's enabled (if so, the ColumnHeaderRenderer will disable the rendering component) - which I'm strongly in favor of.

Opinions?

Jeanette

srnm

Posts: 7
Re: Disabled JXTable now looks ... disabled
Posted: Feb 25, 2007 4:13 PM   in response to: kleopatra
  Click to reply to this thread Reply

Just updated my swingx weekly and my tables are "visually broken" with some columns drawing text with a disabled appearance and some columns not.

These "broken" tables replace the default renderer for a specific class, or sometimes a column. The replacement renderers all subclass DefaultTableCellRenderer but don't draw with a disabled appearance.

What's the recommendation for custom renderers?

Thanks for the original email. Definitely helpful to have a record of these types of changes.

Kleopatra
Re: Disabled JXTable now looks ... disabled
Posted: Feb 26, 2007 2:30 AM   in response to: srnm
  Click to reply to this thread Reply

jdnc-interest@javadesktop.org wrote:
> Just updated my swingx weekly and my tables are "visually broken" with some columns drawing text with a disabled appearance and some columns not.
>
> These "broken" tables replace the default renderer for a specific class, or sometimes a column. The replacement renderers all subclass DefaultTableCellRenderer but don't draw with a disabled appearance.
>
> What's the recommendation for custom renderers?
>

The basic recommendation is to _not_ subclass DefaultTableCellRenderer
but start from SwingX renderers :-) There's a page in the SwingX wiki
with a couple of why's and links to relevant discussions here on the
forum. If you insist going the Default-path, be sure to fix its bugs -
see ComponentProvider api doc for a list of state which it is
responsible to reset reliably on each call to getXXComponent.

> Thanks for the original email. Definitely helpful to have a record of these types of changes.

ehem ... we should do a better change documentation, but not sure how.
Currently the only place where all is caught is CVS history.

Thanks for bringing this up!
Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net


srnm

Posts: 7
Re: Disabled JXTable now looks ... disabled
Posted: Mar 6, 2007 6:59 PM   in response to: Kleopatra
  Click to reply to this thread Reply

Thanks for the reply.

I read the wiki, browsed the forum messages and (mostly) fixed my code.

The things I always want to do with table cells are:

1) change the text alignment (covered by LabelProvider)
2) change the font (usually to a monospaced font)
3) set the tooltip

and a rare 4th
4) change the background cell colour to highlight the cell (covered by Highlighters)

Can someone help with how to accomplish 2 and 3 cleanly with the new renderer architecture?

TIA!

kleopatra

Posts: 1,677
Re: Disabled JXTable now looks ... disabled
Posted: Mar 10, 2007 7:39 AM   in response to: srnm
  Click to reply to this thread Reply

Cool to get feedback on the SwingX renderers at last <g> Or in other words: it's definitely work-in-progress - one open point (I think it's a bullet on the wiki page) is to which cover methods to configure visual properties we want/need and where to put them.
Currently there's horizontal alignment and background/foreground (the latter probably at wrong place - the factoring is drifting to separate the "default visuals" and allow overruling config on the xProvider level).

From this thread and the other (about the triangle marker) there seems to be a need for
- font
- painter
- ??

> 2) change the font (usually to a monospaced font)

just curious: do you need it on a per-application or a per-table basis?

> 3) set the tooltip
>

yeah, that's an old quibble - the base question is where do they come from? If the tooltip is somehow deducted from the value, we could add something similar as the StringValue into the componentProvider... If it's unrelated and needs some lookup, hmm .. we need to do better than that...

Anyway, would you please add your requirements to the wiki page, so we don't forget?

Thanks, and keep it coming - I love it!
Jeanette

srnm

Posts: 7
Re: Disabled JXTable now looks ... disabled
Posted: Mar 12, 2007 7:27 PM   in response to: kleopatra
  Click to reply to this thread Reply

Following up to your follow up :)

to 2)
Certain _columns_ in our tables need to be monospaced to look right.

In general mixing fonts in the same table should probably be avoided, except for bold/italic variants of the same family. In our app some columns are more legible in monospaced and we'd prefer to leave the rest of the columns alone because setting the entire table to monospaced makes things worse.

In the past I have either set the column renderer, or the default renderer for a particular class, to achieve this effect. Not sure what to do with the new JXTable approach...

to 3)
Our tooltips tend to be larger than a table cell and use html to re-render the content of a cell in a "rich" and expanded view. So yes they are dependent upon the content of the cell. It always seemed strange to set the tooltip in the renderer, and overriding JTable getTooltip(?) method was unsatisfying too. Once again, not sure what to do with the new JXTable approach...

Which wiki page would you like me to add to?

Thanks again for looking at all this stuff!
Steven

kleopatra

Posts: 1,677
Re: Disabled JXTable now looks ... disabled
Posted: Mar 13, 2007 4:19 AM   in response to: srnm
  Click to reply to this thread Reply

Steven,

>
> to 2)
> Certain _columns_ in our tables need to be monospaced
> to look right.
>

> In the past I have either set the column renderer, or
> the default renderer for a particular class, to
> achieve this effect. Not sure what to do with the new
> JXTable approach...
>

Okay, so you had something like:

class FontRenderer implements TableCellRenderer {
   TableCellRenderer wrappee;
    
     public Component getTableCellRendererComponent(...) {
        comp = wrappee.getTableCellRendererComponent....
        comp.setFont(monospaced);
        return comp;
     }
};
 
TableCellRenderer numberRenderer = table.getDefaultRenderer(Number.class);
table.setDefaultRenderer(Number.class, new FontRenderer(numberRenderer);
// or
table.getColumnExt(viewIndex).setCellRenderer(
  new FontRenderer(new JXTable.NumberRenderer());


Currently, my standard answer is "Highlighter" - a not-yet existing FontHighlighter, maybe:

class FontHighlighter extends ConditionalHighlighter {
     List<Integer> highlightColumns;
     Component doHighlight(Component renderer, Adapter adapter) {
         comp.setFont(myFont);
     }
    boolean needsHighlight(...) {
       return highlightColumns.contains(adapter.viewToModel(adapter.column));
    }
}
 
FontHighlighter highlighter = new FontHighlighter(font, modelColumn1, modelColumn2);
table.addHighlighter(highlighter);


Which would cover the per-column, but not the per-type: the latter would require additional logic to test against the actual type of the value or the column class ... hmmm. Need to think about it a bit more - some time ago we had a discussion (in fact not only one, the highlighter wiki page has some links :) about refactoring the conditional highlighting to make it more "pluggable", f.i. add a Rule to decide about on/off.

Alternatively, we could add api on the level of the ComponentProvider for visual config ... but I'm a bit reluctant (yet, may swing around if you yell loud enough <g>) to mixin more visuals again. Though .. it might be convenient ... and there is a precedent (alignment config)

then the custom config would be:

ComponentProvider provider = new LabelProvider(
  FormatStringValue.NUMBER_TO_STRING);
provider.setFont(monoSpaced);
table.setDefaultRenderer(new DefaultTableRenderer(provider));


As to the tooltip - don't have an answer yet. Open to suggestions ;-)

> Which wiki page would you like me to add to?

http://wiki.java.net/bin/view/Javadesktop/SwingLabsRenderer

maybe under the open questions paragraph? Or add a new one - after all, it's a wiki!

Thanks for your valuable feedback
Jeanette




 XML java.net RSS