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

📄 windowtextarea.java

📁 这是哲学家问题算法
💻 JAVA
字号:
 import java.awt.*;
 import java.awt.event.*;
 import java.util.*;
 class WindowTextArea extends Frame implements TextListener ,ActionListener
 {
 	TextArea text1,text2;
 	Button buttonSort;
 	WindowTextArea()
 	{
 		setLayout(new FlowLayout());
 		text1=new TextArea(6,15);
 		text2=new TextArea(6,15);
 		buttonSort=new Button("排序");
 		add(text1);
 		add(text2);
 		add(buttonSort);
 		text2.setEditable(false);
 		text1.addTextListener(this);
 		buttonSort.addActionListener(this);
 		setBounds(100,100,350,160);
 		setVisible(true);
 		validate();
 	}
 	public void textValueChanged(TextEvent e)
 	{
 		String s=text1.getText();
 		String t[]=s.split(",");
 		text2.setText(null);
 		for(int i=0;i<t.length;i++)
 		{
 			text2.append(t[i]+"\n");
 		}
 	}
 	public void actionPerformed(ActionEvent e)
 	{
 		String s=text2.getText();
 		String t[]=s.split(",");
 		text2.setText(null);
 		Arrays.sort(t);
 		for(int i=0;i<t.length;i++)
 		{
 			text2.append(t[i]+"\n");
 		}
 	}
 }
 class Main
 {
 	public static void main(String args[])
 	{
 		WindowTextArea win=new WindowTextArea();
 	}
 }

⌨️ 快捷键说明

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