当前位置: 技术问答>java相关
源代码有问题,请帮我看一下
来源: 互联网 发布时间:2015-07-01
本文导语: 这是一个关于JInternalFrame的例子。 是我按照书上打下来得,但是它什么都不显示不能。 不知是为什么? 请高手帮忙。 import java.awt.*; import java.awt.event.*; import javax.swing.*; /** * Title: newman的作品 * Description: neman...
这是一个关于JInternalFrame的例子。
是我按照书上打下来得,但是它什么都不显示不能。
不知是为什么?
请高手帮忙。
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
*
*
*
*
* @author nch@peoplemail.com.cn
* @version 1.0
*/
public class JInternalFrame_test {
public JInternalFrame_test() {
}
public static void main(String[] args) {
MyWindow3 JInternalFrame_test1 = new MyWindow3();
}
}
class MyWindow3 extends JFrame
{JButton button1,button2;
JInternalFrame interframe_1,interframe_2;
MyWindow3()
{Container con=this.getContentPane() ;
con.setLayout(new GridLayout(1,2)) ;
button1=new JButton("Boy");
button2=new JButton("Girl");
interframe_1=new JInternalFrame("内窗体1",true,true,true,true);
interframe_1.setSize(100,100) ;
interframe_1.getContentPane().add(button1,BorderLayout.CENTER ) ;
JDesktopPane desk1=new JDesktopPane();
desk1.setLayout(new FlowLayout()) ;
desk1.add(interframe_1) ;
interframe_2=new JInternalFrame("内窗体2",true,true,true,true);
interframe_2.setSize(300,150) ;
interframe_2.getContentPane() .add(button2,BorderLayout.CENTER) ;
interframe_2.getContentPane() .add(new Label("ookk"),BorderLayout.NORTH) ;
JDesktopPane desk2=new JDesktopPane();
desk2.setLayout(new FlowLayout()) ;
desk2.add(interframe_2) ;
con.add(desk1) ;
con.add(desk2) ;
addWindowListener (new WindowAdapter()
{public void windowClosing(WindowEvent e)
{System.exit (0);}});
this.setSize(200,200);
this.setVisible(true) ;
}
}
是我按照书上打下来得,但是它什么都不显示不能。
不知是为什么?
请高手帮忙。
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
*
Title: newman的作品
*
Description: neman的版权
*
Copyright: Copyright (c) 2002
*
Company: shu
* @author nch@peoplemail.com.cn
* @version 1.0
*/
public class JInternalFrame_test {
public JInternalFrame_test() {
}
public static void main(String[] args) {
MyWindow3 JInternalFrame_test1 = new MyWindow3();
}
}
class MyWindow3 extends JFrame
{JButton button1,button2;
JInternalFrame interframe_1,interframe_2;
MyWindow3()
{Container con=this.getContentPane() ;
con.setLayout(new GridLayout(1,2)) ;
button1=new JButton("Boy");
button2=new JButton("Girl");
interframe_1=new JInternalFrame("内窗体1",true,true,true,true);
interframe_1.setSize(100,100) ;
interframe_1.getContentPane().add(button1,BorderLayout.CENTER ) ;
JDesktopPane desk1=new JDesktopPane();
desk1.setLayout(new FlowLayout()) ;
desk1.add(interframe_1) ;
interframe_2=new JInternalFrame("内窗体2",true,true,true,true);
interframe_2.setSize(300,150) ;
interframe_2.getContentPane() .add(button2,BorderLayout.CENTER) ;
interframe_2.getContentPane() .add(new Label("ookk"),BorderLayout.NORTH) ;
JDesktopPane desk2=new JDesktopPane();
desk2.setLayout(new FlowLayout()) ;
desk2.add(interframe_2) ;
con.add(desk1) ;
con.add(desk2) ;
addWindowListener (new WindowAdapter()
{public void windowClosing(WindowEvent e)
{System.exit (0);}});
this.setSize(200,200);
this.setVisible(true) ;
}
}
|
帮你改了:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
*
*
*
*
* @author nch@peoplemail.com.cn
* @version 1.0
*/
public class InternalFrame_test {
public InternalFrame_test() {
}
public static void main(String[] args) {
MyWindow3 JInternalFrame_test1 = new MyWindow3();
}
}
class MyWindow3 extends JFrame
{JButton button1,button2;
JInternalFrame interframe_1,interframe_2;
MyWindow3()
{Container con=this.getContentPane() ;
con.setLayout(new GridLayout(1,2)) ;
button1=new JButton("Boy");
button2=new JButton("Girl");
interframe_1=new JInternalFrame("内窗体1",true,true,true,true);
interframe_1.setBounds(100,100,300,300) ;
interframe_1.getContentPane().add(button1,BorderLayout.CENTER ) ;
JDesktopPane desk1=new JDesktopPane();
desk1.setLayout(new FlowLayout()) ;
desk1.add(interframe_1) ;
interframe_2=new JInternalFrame("内窗体2",true,true,true,true);
interframe_2.setBounds(300,150,350,350) ;
interframe_2.getContentPane() .add(button2,BorderLayout.CENTER) ;
//interframe_2.getContentPane() .add(new Label("ookk"),BorderLayout.NORTH) ;
JDesktopPane desk2=new JDesktopPane();
desk2.setLayout(new FlowLayout()) ;
desk2.add(interframe_2) ;
interframe_1.show();
interframe_2.show();
con.add(desk1) ;
con.add(desk2) ;
addWindowListener (new WindowAdapter()
{public void windowClosing(WindowEvent e)
{System.exit (0);}});
this.setSize(200,200);
this.setVisible(true) ;
}
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
*
Title: newman的作品
*
Description: neman的版权
*
Copyright: Copyright (c) 2002
*
Company: shu
* @author nch@peoplemail.com.cn
* @version 1.0
*/
public class InternalFrame_test {
public InternalFrame_test() {
}
public static void main(String[] args) {
MyWindow3 JInternalFrame_test1 = new MyWindow3();
}
}
class MyWindow3 extends JFrame
{JButton button1,button2;
JInternalFrame interframe_1,interframe_2;
MyWindow3()
{Container con=this.getContentPane() ;
con.setLayout(new GridLayout(1,2)) ;
button1=new JButton("Boy");
button2=new JButton("Girl");
interframe_1=new JInternalFrame("内窗体1",true,true,true,true);
interframe_1.setBounds(100,100,300,300) ;
interframe_1.getContentPane().add(button1,BorderLayout.CENTER ) ;
JDesktopPane desk1=new JDesktopPane();
desk1.setLayout(new FlowLayout()) ;
desk1.add(interframe_1) ;
interframe_2=new JInternalFrame("内窗体2",true,true,true,true);
interframe_2.setBounds(300,150,350,350) ;
interframe_2.getContentPane() .add(button2,BorderLayout.CENTER) ;
//interframe_2.getContentPane() .add(new Label("ookk"),BorderLayout.NORTH) ;
JDesktopPane desk2=new JDesktopPane();
desk2.setLayout(new FlowLayout()) ;
desk2.add(interframe_2) ;
interframe_1.show();
interframe_2.show();
con.add(desk1) ;
con.add(desk2) ;
addWindowListener (new WindowAdapter()
{public void windowClosing(WindowEvent e)
{System.exit (0);}});
this.setSize(200,200);
this.setVisible(true) ;
}
}