[英]Stretching out JScrollPane - Java
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? 我如何在不使用setSize的情况下将ScrollPane拉伸为覆盖整个窗口? This is how it looks like now: alt text http://img22.imageshack.us/img22/8491/17747996.png
这是现在的样子: 替代文字http://img22.imageshack.us/img22/8491/17747996.png
Thanks! 谢谢!
Mmmph! ! Nobody offered a simple solution such as using BorderLayout as layout manager for my JScrollpane container!
没有人提供简单的解决方案,例如使用BorderLayout作为JScrollpane容器的布局管理器!
Use setPreferredScrollableViewportSize()
and a suitable layout. 使用
setPreferredScrollableViewportSize()
和合适的布局。
Edit: You'll also need setFillsViewportHeight()
, as discussed in Adding a Table to a Container . 编辑:您还需要
setFillsViewportHeight()
,如将表添加到容器中所述 。
I am not familiar with the XML file format. 我不熟悉XML文件格式。
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.