The Source for Java Technology Collaboration

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

Thread: JXTreeTable: Is this possible? Screenshot attached

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
This question is answered. Helpful answers available: 2. Correct answers available: 1.

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 5 - Last Post: Jul 20, 2008 1:53 PM by: kixxass
kixxass

Posts: 3
JXTreeTable: Is this possible? Screenshot attached
Posted: Jul 20, 2008 12:51 AM
 
  Click to reply to this thread Reply

Hello!

is it actually possible to create a JXTreeTable, which looks like the right part of this screenshot?
http://www.midnightbeep.com/images/inbox-pagehead.png

I don't care that much if the enumeration stuff is possible, but i need at least edit capability and the checkboxes should only be shown at each node. The last time i tried with using a custom TreeTableModel and a Boolean column the Checkboxes were in a separate row... I couldn't find out how to attach them to the node only (and have them editable as well).

So is something as shown on the screenshot actually possible with the JXTreeTable component, and if yes, what is the best way to do it? Can you give any examples?

Thanks in advance.

Kind regards,
Andreas

kschaefe

Posts: 1,662
Re: JXTreeTable: Is this possible? Screenshot attached
Posted: Jul 20, 2008 7:57 AM   in response to: kixxass
 
  Click to reply to this thread Reply

It should be possible. Can you give a small demo with what you're currently doing?

Karl

kixxass

Posts: 3
Re: JXTreeTable: Is this possible? Screenshot attached
Posted: Jul 20, 2008 8:43 AM   in response to: kixxass
 
  Click to reply to this thread Reply

I uploaded an Image which shows the problem at
http://files.kuehntopf.org/problem.png

The bottom part is the goal i want to archieve.

It could also be possible that i need to hide the checkbox at each parent node, so only the leafs have checkboxes attached to them.


Any hint how to do that?

Thanks,
Kind regards

Andreas

kschaefe

Posts: 1,662
Re: JXTreeTable: Is this possible? Screenshot attached
Posted: Jul 20, 2008 12:59 PM   in response to: kixxass
 
  Click to reply to this thread Reply

The problem in the renderer/editor. You need to have the hierarchical column contain more than just Boolean data. You need the renderer and editor to understand the combined data and be able to present that data.

So, again, can you please post a small runnable code example with what you're doing?

Karl

Tim Boudreau
Re: JXTreeTable: Is this possible? Screenshot attached
Posted: Jul 20, 2008 12:41 PM   in response to: kixxass
  Click to reply to this thread Reply

On Jul 20, 2008, at 3:51 AM, jdnc-interest@javadesktop.org wrote:

> Hello!
>
> is it actually possible to create a JXTreeTable, which looks like
> the right part of this screenshot?
> http://www.midnightbeep.com/images/inbox-pagehead.png
>
> I don't care that much if the enumeration stuff is possible, but i
> need at least edit capability and the checkboxes should only be
> shown at each node. The last time i tried with using a custom
> TreeTableModel and a Boolean column the Checkboxes were in a
> separate row... I couldn't find out how to attach them to the node
> only (and have them editable as well).
>
> So is something as shown on the screenshot actually possible with
> the JXTreeTable component, and if yes, what is the best way to do
> it? Can you give any examples?

I'd strongly advise against trying to do this with a tree table, or
JTable or similar. Most of the value of components that use the cell-
renderer pattern is to be able to use a single component as a "rubber
stamp" for things that are painted in a uniform way. In the case of
your screen shot, each cell has different and dissimilar contents. So
you're going to need a different renderer for each row, which
basically means you're going to design individual panels for each
cell, and then keep two of them around - one for a renderer and one
for a cell editor, and keep their state in sync.

You're far better off going with live components for this sort of
thing - you can create a generic parent panel with an expand/collapse
button that shows/hides a sub-panel with the additional contents
depending on its state.

Otherwise, you'll find you have weird problems with components not
behaving quite right - for example, have JComboBoxes in two cells;
click one to open its popup (what's really happening under the hood is
the cell editor is instantiated, plopped into the component, and then
the event is [hopefully] forwarded to the right subcomponent); now
click a combo box in a different cell; with live components, one
popup would close and the other would open; due to even ordering
issues and a single shared popup component for combo boxes, you'll
find that's not what happens inside a tree table or JTree; also the
bugs will be different on different look and feels.

While it's technically possible to do this, you will spend a *lot*
more time trying to get it to work right than by just using live
components for this sort of UI - the only thing a tree table is giving
you is an expand button and state notification. That's a not lot of
value in exchange for the increased complexity of dealing with cell
renderers and cell editors. A JToggleButton will give you those same
things and be much simpler code to maintain.

The links below might provide some inspiration - it involves an
expandable panel such as you are using, for a similar UI. In this
case, the code is a little more complex because child panels may
contain their own expansion buttons, so the layout manager looks for a
parent panel that keeps a database of layout data (so the columns of
expandable-panels that are children of other expandable panels all are
vertically aligned:
https://imagine.dev.java.net/source/browse/imagine/misc/ui/src/org/netbeans/paint/api/components/SharedLayoutPanel.java?view=markup
https://imagine.dev.java.net/source/browse/imagine/misc/ui/src/org/netbeans/paint/api/components/LDPLayout.java?rev=1.2&view=log
https://imagine.dev.java.net/source/browse/imagine/misc/ui/src/org/netbeans/paint/api/components/LayoutDataProvider.java?view=markup
https://imagine.dev.java.net/source/browse/imagine/misc/ui/src/org/netbeans/paint/api/components/SharedLayoutData.java?view=markup
https://imagine.dev.java.net/source/browse/imagine/misc/ui/src/org/netbeans/paint/api/components/DefaultSharedLayoutData.java?view=markup

-Tim


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


kixxass

Posts: 3
Re: JXTreeTable: Is this possible? Screenshot attached
Posted: Jul 20, 2008 1:53 PM   in response to: Tim Boudreau
 
  Click to reply to this thread Reply

Thanks, Tim.

That really helped a lot.
I will follow your suggestion and try to implement it using live components.


Andreas




 XML java.net RSS