Skip to main content

JXLayer inside a JScrollPane

1 reply [Last post]
newcron
Offline
Joined: 2008-01-14

Hello,
I want to decorate the currently selected row of a JXTable (which is basically a subclassed JTable from the SwingX Project) with some buttons that are kinda flying over the current row. To do so, I wrapped the Table inside a JXLayer and put the Buttons on the layer's glass pane.
Afterwards, I put the layer inside a JScrollPane.

This causes some issues tough:
first, the Table's Header disappears (this however can easily be fixed, by setting the RowHeader of the ScrollPane manually)
secondly, tough scrolling the table via mouse wheel does not work anymore. I tried to override the processMouseWheelEvent to dispatch the Event to the ScrollPane, however, it seems like not all events are delivered correctly.

Of course I could wrap the scrollpane with the JXLayer instead of the table. Then however, I'd have to take care of updating the position and the clipping of the overlayed buttons manually.

Am I missing any better solution for this problem here or is there no other way to got?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
alexfromsun
Offline
Joined: 2005-09-05

Hello Newcron

JXLayer.setLayerEventMask() controls the type of the events for JXLayer to receive,
if you'd like JXLayer to pass through all events including the mouseWheel events,
just do l.setLayerEventMask(0) in LayerUI.installUI() and scrolling will work after that

There may be another problem with scrollable components, please see

http://forums.java.net/jive/thread.jspa?messageID=302931&#302931

feel free to override LayerUI scrollable methods if you need it

Thanks
alexp