【发布时间】:2010-07-19 09:50:25
【问题描述】:
我正在构建一个充满标签的网格。其中之一包含 html-text 并且应该调整到最大格式并且可以滚动。我找到了如何添加 JScrollPane 但它保持一个行高,即使我给它一个 400x400 的大小,我也找不到如何调整它的大小......
删除 getViewport() 得到相同的结果。
JPanel grid = new JPanel(new GridLayout(1,2));
// first cell of the grid
grid.add(new JLabel("title"));
// second cell of the grid, this should be the scrollable one
JScrollPane scroll = new JScrollPane();
scroll.getViewport().setSize(400, 400);
scroll.getViewport().add(new JLabel("<html>long<br>html<br>text</html>"));
grid.add(scrollVersion, BorderLayout.CENTER);
有什么想法吗?
非常感谢...
【问题讨论】:
-
我猜你试过'setMinimumSize'?
标签: java swing jpanel jscrollpane