将图像缩略图添加到网格中的布局中?
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(); }}
相关分类