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

📄 appo.java

📁 是一个字符串的最简单的处理系统
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;


public class Appo extends Frame implements WindowListener,ActionListener
{
	String st;
	Button button1,button2;
	TextField textfield;
	Canvas0 can;
	int Vownum=0,vownum=0,Connum=0,connum=0,othnum=0;


	public Appo()
	{
		super();
		setTitle("chang");
		setSize(450,300);
		addWindowListener(this);
		can =new Canvas0(this);
		add("Center",can);
		Panel p1=new Panel();
		p1.setLayout(new FlowLayout());
		Label l1=new Label("Vowels");
		Label l2=new Label("vowels");
		Label l3=new Label("Consonants");
		Label l4=new Label("consonants");
		Label l5=new Label("other");
		p1.add(l1);
		p1.add(l2);
		p1.add(l3);
		p1.add(l4);
		p1.add(l5);

		Panel p2=new Panel();
    	p2.setLayout(new FlowLayout());
		button1=new Button("Go");
		button1.addActionListener(this);
		textfield=new TextField(40);
		button2=new Button("Quit");
		button2.addActionListener(this);
		p2.add(button1);
		p2.add(textfield);
		p2.add(button2);


		Panel p=new Panel();
		p.setLayout(new GridLayout(2,1));
		p.add(p1);
		p.add(p2);
		add("South",p);
	}



	public static void main (String[] args)
	{
		App app=new App();
		app.setVisible(true);
	}

	public void actionPerformed(ActionEvent e)
	{
		if(e.getSource()==button2)
		{
			dispose();
			System.exit(0);
		}
		if(e.getSource()==button1)
		{


			st=textfield.getText();

			for(int i=0;i<st.length();i++)
			{
				char ch=st.charAt(i);

				if((ch=='A')|(ch=='E')|(ch=='I')|(ch=='O')|(ch=='U'))
				Vownum++;

				else if((ch=='a')|(ch=='e')|(ch=='i')|(ch=='o')|(ch=='u'))
				vownum++;

				else if((ch=='B')|(ch=='C')|(ch=='D')|(ch=='F')|(ch=='G')
				|(ch=='H')|(ch=='J')|(ch=='K')|(ch=='L')|(ch=='M')|(ch=='N')
				|(ch=='P')|(ch=='Q')|(ch=='R')|(ch=='S')|(ch=='T')|(ch=='V')
				|(ch=='W')|(ch=='X')|(ch=='Y')|(ch=='Z'))
				Connum++;

				else if((ch=='b')|(ch=='c')|(ch=='d')|(ch=='f')|(ch=='g')
				|(ch=='h')|(ch=='j')|(ch=='k')|(ch=='l')|(ch=='m')|(ch=='n')
				|(ch=='p')|(ch=='q')|(ch=='r')|(ch=='s')|(ch=='t')|(ch=='v')
				|(ch=='w')|(ch=='x')|(ch=='y')|(ch=='z'))
				connum++;

				else othnum++;
			}

			can.repaint();
		}
	}


	public void windowClosing(WindowEvent e)
	{
		dispose();
		System.exit(0);
	}

		public void windowOpened(WindowEvent e){}
		public void windowIconified(WindowEvent e){}
		public void windowDeiconified(WindowEvent e){}
		public void windowClosed(WindowEvent e){}
		public void windowActivated(WindowEvent e){}
		public void windowDeactivated(WindowEvent e){}
}
class Canvas0 extends Canvas
{

	Appo parent;
	public Canvas0(Appo f)
	{
		super();
		parent=f;
	}




	public void paint(Graphics g)
	{
		g.setColor(Color.black);
		g.fillRect(60,205-parent.Vownum*5,35,parent.Vownum*5);

		g.fillRect(117,205-parent.vownum*5,35,parent.vownum*5);
		g.fillRect(190,205-parent.Connum*5,35,parent.Connum*5);
		g.fillRect(275,205-parent.connum*5,35,parent.connum*5);
		g.fillRect(342,205-parent.othnum*5,35,parent.othnum*5);

	}

}



⌨️ 快捷键说明

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