我正在构建一个充满标签的网格。其中之一包含 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);
有任何想法吗 ?
非常感谢 ...