关与Java,分割面板的BorderLayout出错
检查了好几次,没发现什么问题,一直有红线,代码如下,求解决importjavax.swing.*;importjava.awt.*;publicclassEXP1exte...
检查了好几次,没发现什么问题,一直有红线,代码如下,求解决
import javax.swing.*;
import java.awt.*;
public class EXP1 extends JFrame{
public static void main(String args[]){
EXP1 frame =new EXP1();
frame.setVisible(true);
}
public EXP1(){
super();
setTitle("分割面板");
setBounds(100,100,500,375);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JSplitPane hSplitPane=new JSplitPane();
hSplitPane.setDividerLocation(40);
getContentPane().add(hSplitPane,BorderLayout.CENTER);
hSplitPane.setLeftComponent(new JLabel(" 1"));
final JSplitPane vSplitPane=new JSplitPane(JSplitPane.VERTICAL_SPLIT);
vSplitPane.setDividerLocation(30);
vSplitPane.setDividerSize(8);
vSplitPane.setOneTouchExpandable(true);
vSplitPane.setContinuousLayout(true);
hSplitPane.setRightComponent(vSplitPane);
vSplitPane.setLeftComponent(new JLabel(" 2"));
vSplitPane.setRightComponent(new JLabel(" 3"));
}
} 展开
import javax.swing.*;
import java.awt.*;
public class EXP1 extends JFrame{
public static void main(String args[]){
EXP1 frame =new EXP1();
frame.setVisible(true);
}
public EXP1(){
super();
setTitle("分割面板");
setBounds(100,100,500,375);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JSplitPane hSplitPane=new JSplitPane();
hSplitPane.setDividerLocation(40);
getContentPane().add(hSplitPane,BorderLayout.CENTER);
hSplitPane.setLeftComponent(new JLabel(" 1"));
final JSplitPane vSplitPane=new JSplitPane(JSplitPane.VERTICAL_SPLIT);
vSplitPane.setDividerLocation(30);
vSplitPane.setDividerSize(8);
vSplitPane.setOneTouchExpandable(true);
vSplitPane.setContinuousLayout(true);
hSplitPane.setRightComponent(vSplitPane);
vSplitPane.setLeftComponent(new JLabel(" 2"));
vSplitPane.setRightComponent(new JLabel(" 3"));
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询