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

📄 modul.java

📁 简单T9输入法模拟
💻 JAVA
字号:
import java.util.*;
import java.text.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
import java.lang.*;
import java.io.*;

class modul extends MyFrameWithExitHandling
{ 
	private static String result="",last="";//the string should be display on the screen    
	private static int u=0;//the index of the temp array
    private static boolean z=false;
    private String show="";//the input number string
    private int q=0;       // the index of the temp array when using * button
    private static StringBuffer str=new StringBuffer();
    private String TempArray[]=new String[20]; //the temp array to store many words using same number.
   
	control B=new control();
    view D=new view();
	DicStru w=new DicStru();


     public modul()
	{
		
		  JPanel pane = new JPanel();
          pane.setLayout(new BorderLayout());
          pane.add("North",D.paneDis);
          pane.add("Center",B.paneBtn);

		  
		setLayout(new BorderLayout());
		add("Center",pane);

  B.button1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) 
        { 
            try { DisplayText("1", D.display); }
            catch(Exception e) { System.err.println("Error: " + e); }
        }
    });
    
  B.button2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) 
        { 
            try { DisplayText("2", D.display); }
            catch(Exception e) { System.err.println("Error: " + e); }  
        }
    });

    B.button3.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt)
        { 
            try { DisplayText("3", D.display); }
            catch(Exception e) { System.err.println("Error: " + e); }
        }
    });

    B.button4.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) 
        { 
            try { DisplayText("4", D.display); }
            catch(Exception e) { System.err.println("Error: " + e); } 
        }
    });

    B.button5.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) 
        { 
            try { DisplayText("5", D.display); }
            catch(Exception e) { System.err.println("Error: " + e); }
        }
    });

    B.button6.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) 
        { 
            try { DisplayText("6", D.display); }
            catch(Exception e) { System.err.println("Error: " + e); } 
        }
    });       
    
    B.button7.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) 
        { 
            try { DisplayText("7", D.display); }
            catch(Exception e) { System.err.println("Error: " + e); } 
        }
    }); 

     B.button8.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) 
        { 
            try { DisplayText("8", D.display); }
            catch(Exception e) { System.err.println("Error: " + e); } 
        }
    }); 
    
     B.button9.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) 
        { 
            try { DisplayText("9", D.display); }
            catch(Exception e) { System.err.println("Error: " + e); } 
        }
    }); 
    
    B.star.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) 
        { 
            try { DisplayText("*", D.display); }
            catch(Exception e) { System.err.println("Error: " + e); } 
        }
    }); 
  
     B.blank.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) 
        { 
            try { DisplayText(" ", D.display); }
            catch(Exception e) { System.err.println("Error: " + e); } 
        }
    }); 
    
     B.sha.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) 
        { 
            try { DisplayText("#", D.display); }
            catch(Exception e) { System.err.println("Error: " + e); } 
        }
    });


	 }
	public static void main(String[] args) 
	{   
		modul f = new modul();
		f.setSize(220, 330);
		f.setVisible(true);
		System.out.println("Hello World!");
	}
//////////////////////////
	public void DisplayText(String chars, JTextArea ta)
{
   	u=0;

	if (chars!="*"&&chars!=" "&&chars!="1"&& chars!="#")
	{
	str.append(chars);
    show=str.toString();

	for(int h=0;h<=19;h++)
	{
		TempArray[h]=null;
	}
  
	for(int p=0;p<w.end.length-1;p++)
	     if(w.end[p][0].compareTo(show)==0)
	{        
		 	 TempArray[u]=w.end[p][1];
			 System.out.println(TempArray[u]+u);
			 u++;
	}
	if(TempArray[0]!=null)
  	result=TempArray[0];
	else
		result=show;
	}
	else
	{  
		if(chars=="*")
		{
		System.out.println(TempArray[q]);
		z=true;
		while(z==true)
		{ 
		q++;
		if(TempArray[q]==null)
			q=0;
		result=TempArray[q];
		
		System.out.println(TempArray[q]);
		z=false;
		}
		}
		else
			{ 
			if(chars==" ")
	          result+=" ";
			if(chars=="1")
			  result+=".";
			if(chars=="#")
				{
				last="";
				result="";
                }
				str=new StringBuffer();
				last+=result;
				result="";
			    u=0;
				z=false;		
				String TempArray[]=null;
				q=0;
				show="";
				System.out.println("THE last--->"+last+"\n");
				System.out.println("the result--->"+result+"\n");
     		}
	}
	 System.out.println("show---->:"+show+"\n");
	 
	ta.setText(last+result);
} 
}

⌨️ 快捷键说明

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