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

📄 example7_32.java.bak

📁 不错的教程 适合中高级人员的使用
💻 BAK
字号:
import java.awt.*;import java.awt.event.*;
class MyWindow extends Frame implements FocusListener
{  Button button;TextField text; 
     
   MyWindow(String s)
   {   super(s);
	   button=new Button("确定");
      text=new TextField(10);
	  text.requestFocusInWindow();
	  setLayout(new FlowLayout());
	  add(button);
	  add(text);
	  text.addFocusListener(this);
	  button.addFocusListener(this);
	  addWindowListener(new WindowAdapter()
	      {public void windowClosing(WindowEvent e)
			  {System.exit(0);}
	       }
	  );
	  setBounds(100,100,150,150);
      setVisible(true);
	  validate();
    }   
   public void focusGained(FocusEvent e)
	{
      Component com=(Component) e.getSource();
	  com.setBackground(Color.blue);
	  if(com==text)
		  text.setText(null);	  
   }
   public void focusLost(FocusEvent e)
	{
      Component com=(Component) e.getSource();
	  com.setBackground(Color.red);
	}

}
 
public class Example7_32
{  public static void main(String args[])
   { new MyWindow();
   }
}

⌨️ 快捷键说明

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