【问题标题】:jtable and intellij - how do i set the columns to appear next to the the right sidejtable 和 intellij - 如何设置列显示在右侧
【发布时间】:2011-07-01 14:22:23
【问题描述】:
在 intellij 上,我在 JPanel 上创建了一个 JXTable。
我添加了两列并设置了它们的宽度。
我希望面板比 jxtable 长得多,因此我将其大小设置为非常大。
问题是列被添加到左侧。
有没有办法让它们添加到表格区域的右侧?
我试过了
jxtable.setAlignment(JComponent.RIGHT_ALIGNMENT)
但没有成功
谢谢。
【问题讨论】:
标签:
java
swing
intellij-idea
jxtable
【解决方案2】:
我可能不理解您的问题,但您可以通过以下方式将表格放置在比表格更大的面板中:
final JPanel bigPanel = new JPanel(new BorderLayout());
// initialize your panel with stuff
final JXTable smallTable = new JXTable(...);
bigPanel.add( smallTable, BorderLayout.LINE_START ); // Left side of panel
bigPanel.add( smallTable, BorderLayout.LINE_END ); // Right side of panel
bigPanel.add( smallTable, BorderLayout.PAGE_START ); // Top of panel
bigPanel.add( smallTable, BorderLayout.PAGE_END); // Bottom of panel
bigPanel.add( smallTable, BorderLayout.CENTER ); // Center of panel