JTables中的JScrollPane [英] JScrollPane in JTables

查看:96
本文介绍了JTables中的JScrollPane的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道你们是否遇到问题,例如是否有一些JPanel拥有自己的JScrollPane,并且在您的面板中,您正在使用很多JTable和自己的JScrollPane,上/下滚动面板时出现问题?

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?

我的意思是,当您的鼠标位于某个表的视口上时,JTableJScrollPane正在滚动浏览,因此当我有很多JTable时,我只能在面板的几个位置滚动,太烦人了...

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...

JTable滚动未显示时,是否有一些功能会将我的滚动事件发送给父级JPanel JScrollPane?我的意思是,每当某些JTable不需要使用滚动(隐藏时,由于记录太少),我都想禁用JScrollPane.

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).

推荐答案

是的,JTable可以理解几种命名的滚动键绑定,但是您可以想到如以下相关的示例所示,该示例命令为滚动窗格定义的操作.

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));

滚动JTable的相关动作名称:

scrollDownChangeSelection
scrollDownExtendSelection
scrollLeftChangeSelection
scrollLeftExtendSelection
scrollRightChangeSelection
scrollRightExtendSelection
scrollUpChangeSelection
scrollUpExtendSelection

这篇关于JTables中的JScrollPane的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆