public class myFrame extends JFrame {

JInternalFrame jf;
JDesktopPane jp;
public myFrame() {
this.setTitle("myFrame");
this.setSize(350, 300);
this.setLayout(new BorderLayout());

JButton button=new JButton("按钮");
this.add(button,BorderLayout.SOUTH);


JLabel label1=new JLabel("happy new year");
jf=new JInternalFrame();
jf.setSize(100,100);
jf.setVisible(true);
jf.setLocation(20, 20);

JPanel panel=new JPanel();
panel.add(label1);
panel.setVisible(true);

jf.setContentPane(panel);

jp=new JDesktopPane();
jp.setVisible(true);
jp.add(jf);
this.add(jp,BorderLayout.NORTH); }
}
各位大侠帮我看看有什么问题  怎么只能显示 SOUTH 位置的按钮   NORTH 的全都显示不出来呢? 

解决方案 »

  1.   


    public class MyFrame extends JFrame { JInternalFrame jf;
    JDesktopPane jp; public MyFrame() {
    this.setTitle("myFrame");
    this.setSize(350, 300);
    this.setLayout(new BorderLayout()); JButton button = new JButton("按钮");
    this.add(button, BorderLayout.SOUTH); JLabel label1 = new JLabel("happy new year");
    jf = new JInternalFrame();
    jf.setSize(100, 100);
    jf.setVisible(true);
    jf.setLocation(20, 20); JPanel panel = new JPanel();
    jf.add(label1);
    //panel.add(jf);
    panel.setVisible(true); //jf.setContentPane(panel); jp = new JDesktopPane();
    jp.setVisible(true);
    jp.add(jf);
    this.add(jf, BorderLayout.NORTH); }

    public static void main(String[] args) {
    new MyFrame().show();
    }
    }
      

  2.   

    你的代码写得太乱了..帮你改了下可以运行,NORTH有显示.主要问题出在你设置容器.
    public class MyFrame extends JFrame {  JInternalFrame jf; 
    JDesktopPane jp; 
    public MyFrame() { 
    this.setTitle("myFrame"); 
    this.setSize(350, 300); 
    this.setLayout(new BorderLayout());  JButton button=new JButton("按钮"); 
    this.add(button,BorderLayout.SOUTH); 
    JLabel label1=new JLabel("happy new year"); 
    jf=new JInternalFrame(); 
    jf.setSize(100,100); 
    jf.setVisible(true); 
    jf.setLocation(20, 20);  JPanel panel=new JPanel(); 
    panel.add(label1); 
    panel.setVisible(true);  jp=new JDesktopPane(); 
    jp.setVisible(true); 
    jp.add(jf); 
    panel.add(jp);//--------------------这里-------
    this.add(panel,BorderLayout.NORTH); //--------------------这里------- } 
    public static void main(String[] args) {
    MyFrame myFrame=new MyFrame();
    myFrame.setVisible(true);
    }