import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class windchill implements ActionListener
{
private static final int WINDOW_WINTH=350;
private static final int WINDOW_HEIGHT=185;
private static final int AREA_WINTH=40;
private static final int FIELD_WINTH=20;
private static final FlowLayout LAYOUT_STYLE=new FlowLayout();
private static final String LEGEND="This windchill calculatie is intended foe velocitoies great than 4 mph";
//实例变量
//GUI的窗口
private JFrame window=new JFrame("WIndchill calulator");
//图例
private JTextArea lengend=new JTextArea(LEGEND,2,AREA_WINTH);
//温度的用户输入区域
private JLabel fahrTrg=new JLabel("Fahrenheit temperature");
private JTextField fahrText=new JTextField(FIELD_WINTH);
//风速的用户输入区域
private JLabel windTrg=new JLabel (" Windspeed (mph) ");
private JTextField windText=new JTextField(FIELD_WINTH);
//温度接果的输入区域
private JLabel chillTrg =new JLabel("Windchill temperature");
private JTextField chillText=new JTextField(FIELD_WINTH);
//运行按钮
private JButton runButton=new JButton("run");
//Windchill构造方法
public void windchill()
{
window.setSize(WINDOW_WINTH,WINDOW_HEIGHT);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// window.setVisble(true);
lengend.setEditable(false);
lengend.setLineWrap(true);
lengend.setWrapStyleWord(true);
lengend.setBackground(window.getBackground());
chillText.setEditable(false);
chillText.setBackground(Color.WHITE);
//注册事务监听器
runButton.addActionListener(this);
//向容器增加构件
Container c=window.getContentPane();
c.setLayout(LAYOUT_STYLE);
c.add(lengend);
c.add(fahrTrg);
c.add (fahrText);
c.add(windTrg);
c.add(windText);
c.add(chillTrg);
c.add(chillText);
c.add(runButton);
//显示GUI
window.show();
}
//actionperformend
public void actionperformend(ActionEvent e)
{
String response1=fahrText.getText();
double t=Double.parseDouble(response1);
String response2=windText.getText();
double v=Double.parseDouble(response2);
//计算温度
double windchillTemperature=0.081*(t-91.4)*(3.71*Math.sqrt(v)+5.81-0.25*v)+91.4;
int perceivedTemperature=(int) Math.round(windchillTemperature);
//显示温度
String output=String.valueOf(perceivedTemperature);
chillText.setText(output);
}
//main函数入口
public static void main(String [] args)
{
windchill gui=new windchill();
}
}
import java.awt.*;
import java.awt.event.*;
public class windchill implements ActionListener
{
private static final int WINDOW_WINTH=350;
private static final int WINDOW_HEIGHT=185;
private static final int AREA_WINTH=40;
private static final int FIELD_WINTH=20;
private static final FlowLayout LAYOUT_STYLE=new FlowLayout();
private static final String LEGEND="This windchill calculatie is intended foe velocitoies great than 4 mph";
//实例变量
//GUI的窗口
private JFrame window=new JFrame("WIndchill calulator");
//图例
private JTextArea lengend=new JTextArea(LEGEND,2,AREA_WINTH);
//温度的用户输入区域
private JLabel fahrTrg=new JLabel("Fahrenheit temperature");
private JTextField fahrText=new JTextField(FIELD_WINTH);
//风速的用户输入区域
private JLabel windTrg=new JLabel (" Windspeed (mph) ");
private JTextField windText=new JTextField(FIELD_WINTH);
//温度接果的输入区域
private JLabel chillTrg =new JLabel("Windchill temperature");
private JTextField chillText=new JTextField(FIELD_WINTH);
//运行按钮
private JButton runButton=new JButton("run");
//Windchill构造方法
public void windchill()
{
window.setSize(WINDOW_WINTH,WINDOW_HEIGHT);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// window.setVisble(true);
lengend.setEditable(false);
lengend.setLineWrap(true);
lengend.setWrapStyleWord(true);
lengend.setBackground(window.getBackground());
chillText.setEditable(false);
chillText.setBackground(Color.WHITE);
//注册事务监听器
runButton.addActionListener(this);
//向容器增加构件
Container c=window.getContentPane();
c.setLayout(LAYOUT_STYLE);
c.add(lengend);
c.add(fahrTrg);
c.add (fahrText);
c.add(windTrg);
c.add(windText);
c.add(chillTrg);
c.add(chillText);
c.add(runButton);
//显示GUI
window.show();
}
//actionperformend
public void actionperformend(ActionEvent e)
{
String response1=fahrText.getText();
double t=Double.parseDouble(response1);
String response2=windText.getText();
double v=Double.parseDouble(response2);
//计算温度
double windchillTemperature=0.081*(t-91.4)*(3.71*Math.sqrt(v)+5.81-0.25*v)+91.4;
int perceivedTemperature=(int) Math.round(windchillTemperature);
//显示温度
String output=String.valueOf(perceivedTemperature);
chillText.setText(output);
}
//main函数入口
public static void main(String [] args)
{
windchill gui=new windchill();
}
}
请问一下,这个程序错在哪里啊?!
请高手帮我改一下!!