扩展 JScrollPane - Java

发布于 2024-09-06 12:18:28 字数 501 浏览 1 评论 0原文

我有这样的结构:

<JFrame>
         <JPanel backgroundcolor = "pink">
            <JScrollPane>
                <JTable>!!!Data here !!!</JTable>
            </JScrollPane>
         </JPanel>
</JFrame>

如何在不使用 setSize 的情况下拉伸 ScrollPane 以覆盖整个窗口? 现在是这样的: 替代文本 http://img22.imageshack.us/img22/8491/17747996.png< /a>

谢谢!

I have this structure:

<JFrame>
         <JPanel backgroundcolor = "pink">
            <JScrollPane>
                <JTable>!!!Data here !!!</JTable>
            </JScrollPane>
         </JPanel>
</JFrame>

How do i stretch the ScrollPane it to cover the full window without using setSize?
This is how it looks like now:
alt text http://img22.imageshack.us/img22/8491/17747996.png

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

偷得浮生 2024-09-13 12:18:28

嗯!没有人提供简单的解决方案,例如使用 BorderLayout 作为我的 JScrollpane 容器的布局管理器!

Mmmph! Nobody offered a simple solution such as using BorderLayout as layout manager for my JScrollpane container!

浪漫之都 2024-09-13 12:18:28

我不熟悉 XML 文件格式。

如果它是编码的,您可能需要编写如下代码:

JScrollPane1 = new JScrollPane();
JPanel1.add(JscrollPane1);
JScrollPane1.setBounds(5,29,636,122);

JTable1 = new JTable();    
JPanel1.add(JTable1);
JScrollPane1.setBounds(5,434,553,3097);
JScrollPane1.setViewportView(JTable1);

I am not familiar with the XML file format.

If it is coded, you may need to code something like this:

JScrollPane1 = new JScrollPane();
JPanel1.add(JscrollPane1);
JScrollPane1.setBounds(5,29,636,122);

JTable1 = new JTable();    
JPanel1.add(JTable1);
JScrollPane1.setBounds(5,434,553,3097);
JScrollPane1.setViewportView(JTable1);
花海 2024-09-13 12:18:28

使用 < code>setPreferredScrollableViewportSize() 和合适的布局。

编辑:您还需要 setFillsViewportHeight(),如 将表添加到容器

Use setPreferredScrollableViewportSize() and a suitable layout.

Edit: You'll also need setFillsViewportHeight(), as discussed in Adding a Table to a Container.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文