java程序设计 清华出版社 孙燮华老师编写的程序源代码

源代码在线查看: windows.java

软件大小: 20 K
上传用户: zxyxwd6
关键词: java 程序设计 清华 出版社
下载地址: 免注册下载 普通下载 VIP

相关代码

				//windows.java
				import java.awt.*;
				import java.awt.event.*;
				
				public class windows extends Frame implements ActionListener{
				  Button button1,button2;
				  demoframe window1;
				
				  public windows(String s){
				    super(s);
				    setLayout(new GridLayout(1,2));
				    button1=new Button("Show window");
				    button2=new Button("Hide window");
				    button1.addActionListener(this);
				    button2.addActionListener(this);
				    add(button1);
				    add(button2);
				    window1=new demoframe("Window Demo");
				    window1.setSize(200,100);
				  }
				                                      
				  public void actionPerformed(ActionEvent e){
				    if(e.getSource()==button1){
				      window1.setVisible(true);
				    }
				    if(e.getSource()==button2){
				      //window1.setVisible(false);
				      window1.dispose();
				    }
				  }
				  public static void main(String args[]){
				    windows myWindows=new windows("My first windows");
				    myWindows.setSize(250,100);
				    myWindows.show();
				  }
				}
				
				class demoframe extends Frame{
				  Label label1;
				  demoframe(String title){
				    super(title);
				    setLayout(new GridLayout(1,1));
				    label1=new Label("Hello from Java!");
				    add(label1);
				  }
				}
							

相关资源