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

📄 example7_35.java

📁 不错的教程 适合中高级人员的使用
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
 class Win extends Frame implements KeyListener
{  TextField text[]=new TextField[3];
   
   Win()
   {   setLayout(new FlowLayout());	   
       addWindowListener(new WindowAdapter()
	   {public void windowClosing(WindowEvent e)
	   {System.exit(0);}
	   }
	   );
	   for(int i=0;i<3;i++)
	   {
		   text[i]=new TextField(7);
		   text[i].addKeyListener(this);
		   text[i].addKeyListener(this);
		   add(text[i]);
	   }
	   text[0].requestFocusInWindow();
		 setBounds(10,10,300,300);
		 setVisible(true);
		 validate();
   }
   public void keyPressed(KeyEvent e)
   {  TextField text=(TextField)e.getSource();
      if(text.getCaretPosition()>=6)
	   {text.transferFocus();	  }
   }

   public void keyTyped(KeyEvent e) {}
   public void keyReleased(KeyEvent e) {}
   public void focusGained(FocusEvent e)
	{
	   TextField text=(TextField)e.getSource();
	   text.setText(null);
   }
    public void focusLost(FocusEvent e)	{}

}
public class Example7_35
{
	public static void main(String args[])
	{
		new Win();
	}
}

⌨️ 快捷键说明

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