import javax.swing.*;
import java.awt.*;class ShowImage extends JFrame{
JLabel j;
JPanel top=new JPanel();
JPanel bottom=new JPanel();
JSplitPane jsp=new JSplitPane(JSplitPane.VERTICAL_SPLIT);
ShowImage(){
this.setSize(300,200);
top.setBackground(Color.blue);
bottom.setBackground(Color.red);
jsp.setDividerLocation(0.9);
jsp.setTopComponent(top);
jsp.setBottomComponent(bottom);
this.getContentPane().add(jsp);
}
public static void main(String[] args){
new ShowImage().show();
}
}
帮助里是说jsp.setDividerLocation可以设置Divider在jsplitpane的位置,但必须要在窗体显示之后才有效果,有没有在窗体显示前就可以定位的方法
import java.awt.*;class ShowImage extends JFrame{
JLabel j;
JPanel top=new JPanel();
JPanel bottom=new JPanel();
JSplitPane jsp=new JSplitPane(JSplitPane.VERTICAL_SPLIT);
ShowImage(){
this.setSize(300,200);
top.setBackground(Color.blue);
bottom.setBackground(Color.red);
jsp.setDividerLocation(0.9);
jsp.setTopComponent(top);
jsp.setBottomComponent(bottom);
this.getContentPane().add(jsp);
}
public static void main(String[] args){
new ShowImage().show();
}
}
帮助里是说jsp.setDividerLocation可以设置Divider在jsplitpane的位置,但必须要在窗体显示之后才有效果,有没有在窗体显示前就可以定位的方法
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货