将图像缩略图添加到网格中的布局中?我有一张照片清单。我需要添加一个小缩略图到一个框架。我现在有框架SpringLayout..如何在某些网格中添加缩略图,比如带有滚动窗格的时尚。照片列表可能很大,所以我需要一个滚动窗格。我不知道如何处理这件事SpringLayout..我知道如何添加缩略图;真正的问题是如何在SpringLayout.import java.awt.Color;import java.awt.Container;import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.JScrollPane;
import javax.swing.SpringLayout;public class grid {
/**
* @param args
*/
public grid() {
JFrame frame = new JFrame("Hello");
Container pane = frame.getContentPane();
pane.setBackground(Color.WHITE);
SpringLayout layout = new SpringLayout();
pane.setLayout(layout);
JPanel photoPanel = new JPanel();
JScrollPane photoScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
photoPanel.add(photoScroll);
pane.add(photoPanel);
layout.putConstraint(SpringLayout.WEST, photoPanel, 260, SpringLayout.WEST, pane);
layout.putConstraint(SpringLayout.NORTH, photoPanel, 40, SpringLayout.SOUTH, pane);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.pack();
//frame.setSize(frame.getMaximumSize());
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setLocationRelativeTo(null);
frame.setResizable(true);
frame.setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new grid();
}}
添加回答
举报
0/150
提交
取消