这里是我的问题: 我创建一个窗口,负责在ImageIcon
作为的形式上市层,在此它显示层的 当前图像(现在),图层名称和复选框来更改所述图层的当前开启/关闭状态。整个事情应该是的Paint.NET's Layer Window敲落,如下所示:摇摆:JList的持有多个组件作为单个项目
我的问题是,如何绕过JTable
构建它如此。我想到最后,我可能不得不求助于制作一个动态表格,但我想知道是否有办法制作可单独显示这三个组件的项目/容器。
我得到的最接近的是使用JLabel
及其使用的图标和文本属性,但我无法确定如何添加复选框。
我应该使用布局管理器将标签列表移动到左侧,并在窗格中添加一个填充了复选框的新列表吗?
我的代码大概如下:
public class StudioLayerWindow extends JFrame
{
// Objects
JPanel buttonPanel;
JScrollPane layerScroll;
JButton addNewLayer;
JButton deleteCurrentLayer;
JButton duplicateCurrentLayer;
JButton mergeCurrentLayer;
JButton moveCurrentLayerUp;
JButton moveCurrentLayerDown;
JButton layerProperties;
// Constructors & Initializers
public StudioLayerWindow()
{
// Main Window Initialization
this.setTitle("Layers");
this.setType(Type.UTILITY);
this.setSize(200,200);
this.setResizable(false);
this.setAlwaysOnTop(true);
initButtons();
buttonPanel = new JPanel(new GridLayout(1,7));
buttonPanel.setPreferredSize(new Dimension(this.getWidth(), this.getHeight()/ 7));
buttonPanel.add(addNewLayer);
buttonPanel.add(deleteCurrentLayer);
buttonPanel.add(duplicateCurrentLayer);
buttonPanel.add(mergeCurrentLayer);
buttonPanel.add(moveCurrentLayerUp);
buttonPanel.add(moveCurrentLayerDown);
buttonPanel.add(layerProperties);
// Code for what I'd add here
layerScroll = new JScrollPane();
this.add(layerScroll , BorderLayout.CENTER);
this.add(buttonPanel , BorderLayout.PAGE_END);
}
上面的代码不包含任何尝试我的解决方案,只有基本的模板,我一直在。
有什么办法可以在单一行上制作多个组件吗?
*“我的问题是如何绕过JTable来构造它。”*为什么'绕过'?标准的(3列)'JTable'抑制垂直和水平线可以做到这一点。 –