单击jtable中的超链接?
如何为 JTable
中的每条记录启用超链接?
我想要做的是,用户可以单击超链接,然后该超链接将显示他们可以编辑/更新的信息。
或者,如何启用表数据的就地编辑?
另一个问题是我目前正在使用以下方式来显示不同的屏幕。但这不是一种优雅的方式,我知道我们应该使用卡片布局,但究竟如何去做呢?
mainPanel.setVisible(false);
createBlogEntryPanel.setVisible(true);
setComponent(createBlogEntryPanel);
How can I enable hyperlink for every record in the JTable
?
What I want to do is such that a user can click on the hyperlink which will then display the information they can edit/update.
Alternatively how can I enable in place editing of the table data?
Another question is i am currently using the following way to display different screen. But this is not an elegant way i understand we should use cardlayout but how exactly to go about it?
mainPanel.setVisible(false);
createBlogEntryPanel.setVisible(true);
setComponent(createBlogEntryPanel);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要解决
JTable
消耗事件的问题,您可以将自己的MouseListener
(或MouseAdapter
)添加到JTable 并在此侦听器中进行操作。以下是您可以实现的目标的示例:
To address the problem with
JTable
consuming the events, you can add your ownMouseListener
(or aMouseAdapter
) to theJTable
and do your manipulation inside this listener. Here is an example of what you can achieve:(这个问题太模糊,无法简洁/完整地回答它 - 这个答案假设主要部分是 JTable 中的超链接)
考虑使用完全支持集合组件(表、列表、树 ..) - 就像 fi SwingX
有关 SwingX 中的代码示例,请参阅 最近的答案
编辑
正如我的评论中提到的:SwingX 不支持这一点(它是基于单元格的)。
所以它回到了有几个选项的原点
ol' 风格:(误)使用 cellEditor
扩展 SwingX 样式:丰富翻转界面(孵化器可能有示例,但由于尚未准备好,因此未添加到核心 SwingX 中:- )基本思想是
第二个可以独立于 SwingX 实现,当然:一个简单的自定义 mouseListener 和映射逻辑应该做技巧(抱歉,手边没有代码)
(The question is way too vague to answer it concisely/completely - this answer assume the main part to be the hyperlink in JTable)
Consider using a framework that fully supports hyperlinks in collection components (table, list, tree ..) - like f.i. SwingX
For a code example in SwingX, see a recent answer
Edit
As mentioned in my comment: that's not supported in SwingX (it's cell-based).
So it's back to square one with several options
The ol' style: (mis-)use a cellEditor
Extending SwingX style: enrich the rollover interface (the incubator may have examples, but that wasn't added to core SwingX for the reason of not yet being ready :-) The basic idea is to
The second can be implemented independently of SwingX, of course: a plain ol' custom mouseListener and the mapping logic should do the trick (sorry, no code handy)