我添加panel4
到 scrollPane,但我的应用程序没有改变。这是我的代码:
public class Bill extends JPanel {
//some Jlabels, JComboBox......
public Bill(){
JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayout(7,1,10,20));
//add some labels to panel
JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayout(7,4,10,10 ));
//add some components to panel
JPanel panel3=new JPanel(new GridLayout(4,1,10,10));
panel3.add(CRTA);
panel3.add(UKUPNO);
panel3.add(jbtView);
panel3.add(jbtCancel);
最后是 panel4
JPanel panel4=new JPanel();
panel4.add(panel1, BorderLayout.WEST);
panel4.add(panel2, BorderLayout.CENTER);
JScrollPane scrollPane = new JScrollPane();
scrollPane.getViewport().add( panel4 );
add(scrollPane,BorderLayout.CENTER);
add(panel3, BorderLayout.SOUTH);
这就是我得到的
矩形内是 panel4(带有数字和组合框的面板)
这是我改变尺寸的时候
没有滚动显示