⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mywindow.java

📁 初学java,最近帮同学作的一些实验
💻 JAVA
字号:
import java.net.*;
import java.io.*;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class Mywindow extends Frame implements ActionListener{
  TextField text1,text2;
  Button button1,button2;
  Mywindow()
  {
	  super("悄悄话窗口");
	  setLayout(new GridLayout(3,2));
	  text1=new TextField(12);
	  text2=new TextField(18);
	  button1=new Button("送出悄悄话");
	  button2=new Button("关闭此窗口");
	  add(new Label("送悄悄地话到:"));
	  add(text1);
	  add(new Label("输入您的悄悄话:"));
	  add(text2);
	  add(button2);
	  add(button1);
	  setSize(400,190);
	  text1.setEditable(false);
	  setVisible(false);
	  button1.addActionListener(this);
	  button2.addActionListener(this);
	  setBackground(Color.cyan);
	  addWindowListener(new WindowAdapter()
	  {
		 public void windowClosing(WindowEvent e)
		 {
			 setVisible(false);
			 System.exit(0);
		 }
	  });
  }
public void actionPerformed(ActionEvent e) {
	// TODO Auto-generated method stub
	if(e.getSource()==button1)
	{
		try{
			chatappletthree.out.writeUTF("悄悄地对"+text1.getText()+"说:"+text2.getText()+"(我是"+chatappletthree.name+")");
			text2.setText(null);
			
		}catch(IOException e1){}
	}
	else if(e.getSource()==button2)
	{
		this.setVisible(false);
	}
	
}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -