gpt4 book ai didi

java - JScrollPane 列标题未采用全尺寸

转载 作者:行者123 更新时间:2023-11-29 07:53:47 25 4
gpt4 key购买 nike

这是截图。

enter image description here

这是我构建和设置 header 的代码。

private void buildHeader() {
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));

panel.add(Box.createHorizontalStrut(10));
panel.add(new JLabel("Documents"));
panel.add(Box.createHorizontalGlue());
panel.add(new JButton("View"));
panel.add(new JButton("Print"));

panel.setBorder(BorderFactory.createLineBorder(new Color(210, 210, 210)));
panel.setBackground(new Color(245, 245, 245));
panel.setPreferredSize(new Dimension(panel.getPreferredSize().width, 51));

setColumnHeaderView(panel);
}

但是,我无法让页眉占据整个空间。它正在离开垂直滚动条上方的空间。

那么,我怎样才能让这个列标题占据它的整个宽度。

最佳答案

But, I am not able to make the header to take its whole space. It is leaving the space above vertical scroll bar.

  • 通过放置 JComponent to the Corner (边框可能有问题)

  • 或者通过将 JPanel contians JButton 移出 JScrollPane

关于java - JScrollPane 列标题未采用全尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19353926/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com