求助:两个Java程序!

来源:百度知道 编辑:UC知道 时间:2024/06/23 19:50:32
1编写一个应用程序,读取几行文本,并在一个表中打印出一个字母的单词,两个字母的单词、3个字母的单词出现的次数。

2编写一个程序,该程序以不同的颜色随机产生三角形。每个三角形应用不同的颜色进行填充。

// ############### Hasgrable类_键值对 ################

import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.StringTokenizer;
import javax.swing.*;
public class Hasgrable类_键值对 extends JFrame{
private JTextArea inputField;
private JLabel prompt;
private JTextArea display;
private JButton goButton;
private Hashtable table;
public Hasgrable类_键值对()
{
super("word Type Count");
inputField =new JTextArea(3,20);
table =new Hashtable();
goButton =new JButton("GO");
goButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
createTable();
display.setText(createOutput());
}
});
prompt=new JLabel("Enter a string: ");