Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I wonder if you guys had problem such if you got some JPanel which got his own JScrollPane and in your panel you are using a lot of JTables with their own JScrollPanes, there is a problem to scroll up/down your panel?

I mean when your mouse is on viewport of some table, then JScrollPane of JTable is listening on scroll, so when I got many JTables I am able to scroll only in a few places of the panel, it's so annoying...

Are there some functions which will send my scroll event to parent JPanel JScrollPane when the JTable scroll is even not shown? I mean I want to disable JScrollPane whenever some JTable don't need to use scroll (when it is hidden, cause there are too less records).

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
593 views
Welcome To Ask or Share your Answers For Others

1 Answer

Yes, JTable understands several named scrolling actions, listed below. They are normally used in key bindings, but you can evoke them yourself, as shown in this related example that commandeers the actions defined for a scroll pane.

Addendum: In outline, get the named action from the component's action map:

Action action = table.getActionMap().get(name);

Evoke the action by name when needed:

action.actionPerformed(new ActionEvent(table, 0, name));

Scrolling related action names for JTable:

scrollDownChangeSelection
scrollDownExtendSelection
scrollLeftChangeSelection
scrollLeftExtendSelection
scrollRightChangeSelection
scrollRightExtendSelection
scrollUpChangeSelection
scrollUpExtendSelection

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...