java_3.java
来自「里面有我的JAVA实验和一些教程」· Java 代码 · 共 67 行
JAVA
67 行
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class GUI_text extends Applet implements ItemListener,ActionListener
{
String a[] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
String b[] = new String[100];
int i = 0,m = 0,j;
Frame frm = new Frame("GUI编程");
TextField tf = new TextField(20);
TextArea ta = new TextArea(50,50);
Choice co = new Choice();
TextArea ta2 = new TextArea(50,50);
public void init()
{
frm.setSize(500,500);
frm.setLayout(null);
tf.setSize(150,30);
tf.setLocation(10, 30);
frm.add(tf);
tf.addActionListener(this);
ta.setSize(200,200);
ta.setLocation(160,30);
frm.add(ta);
co.setSize(120,30);
co.setLocation(10, 250);
for(i = 0 ; i < 26 ; i++)
{
co.addItem(a[i]);
}
frm.add(co);
co.addItemListener(this);
ta2.setSize(200,200);
ta2.setLocation(160,250);
frm.add(ta2);
frm.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
String s = tf.getText();
b[m] = s;
m++;
ta.append(s + "\n");
tf.setText("");
}
public void itemStateChanged(ItemEvent e)
{
ta2.setText("");
for(j = 0 ; j < m ; j++)
if(b[j].substring(0,1).equals(co.getSelectedItem().toString()))
ta2.append(b[j] + "\n");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?