简体   繁体   English

JTable标头包含图像,在该图像的顶部,我想在单个标头中放置3个按钮

[英]JTable Header contains Image and on top of that image I want to place 3 buttons in a single header

JTable Header contains Image and on top of that image I want to place 3 buttons in a single header. JTable标头包含图像,在该图像的顶部,我想在单个标头中放置3个按钮。 My requirement is to Create a "Play List" table in which user can add their favourite songs. 我的要求是创建一个“播放列表”表,用户可以在其中添加自己喜欢的歌曲。

So in the header I want to put a "Play List" title and "+" button to insert new playlists and "Export" and "Import" buttons. 因此,在标题中,我想放置“播放列表”标题和“ +”按钮以插入新的播放列表,并插入“导出”和“导入”按钮。

How I can do that? 我怎么能这样做? Thanks in Advance. 提前致谢。

I doubt (1) this use-case actually calls for cramming extra components into a JTable header. 我怀疑(1)这种用例实际上需要将多余的组件塞入JTable标头中。 EG Take the UI of DukeBox. EG以DukeBox的UI为准。

DukeBox

We can see the play list on the left (a JTable ) with a Filter text field and Random check-box above it, and the Enqueue & History buttons below. 我们可以在左侧看到一个播放列表( JTable ),在其上方有一个Filter文本字段和Random复选框,并在下面有Enqueue&History按钮。

This was created with a nested layout. 这是使用嵌套布局创建的。 The 'outer layout' is BorderLayout , that panel has the table in the CENTER , and nested panels in the NORTH & SOUTH . “外部布局”是BorderLayout ,该面板在CENTER有表格,而在NORTHSOUTH嵌套的面板。 The NORTH panel has another BorderLayout , while the SOUTH uses a GridLayout . NORTH面板具有另一个BorderLayout ,而SOUTH面板具有GridLayout

If using a nested layout does not give you some ideas, I suggest you post a drawing or better, ASCII art, of the UI as it should appear at the smallest size, as well as a representation of it when it is resized (where is the extra width/height assigned?). 如果使用嵌套布局无法给您带来一些想法,建议您发布UI的图形或更佳的ASCII艺术作品,因为它应该以最小的尺寸显示,并在调整尺寸时显示它(分配的额外宽度/高度?)。

1) I have that suspicion every time I hear words to the effect "Wouldn't it be great if we had a component that..?" 1)每当我听到这样的声音时,我都会感到怀疑: “如果我们有一个组成部分……那不是很好吗?” . Of course, there are some classic counter-examples where the standard widget tool-kit seems lacking (eg a date picker or switch list), but these are common components to which a name can be put. 当然,有一些经典的反例,其中似乎缺少标准的小部件工具包(例如,日期选择器或切换列表),但是这些是可以放置名称的常见组件。 If the person asking cannot put a 'catchy name' to the custom component, there is a good chance they are over (or under) thinking the matter. 如果询问的人不能在自定义组件中添加“醒目的名称”,则很有可能他们对此事过度(或不充分)考虑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM