新手求助

instigator 2003-10-16 09:00:50
我是一个JAVA的初学者,在我编写一个applet时使用JFrame函数
却发现程序总是告诉我初始化失败,怎么回事?
小弟我把程序放在下边,希望各位大虾多多帮助!

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;


public class TheTwoStudent extends JApplet implements ActionListener {

JLabel number1Label,number2Label,number3Label,number4Label,number5Label,
number6Label,student1Label,student2Label,resultLabel;
JTextField number1Field,number2Field,number3Field,number4Field,
number5Field,number6Field,resultField;
JButton button;
String display;
JTextArea outArea;

public void init() {
Container cont = getContentPane();
cont.setLayout(new FlowLayout());
//cont.setVisible(true);

//load student1
student1Label = new JLabel("Enter Student A's marks : ");
cont.add(number1Label);


number1Label = new JLabel("Enter mark of Subject A : ");
cont.add(number1Label);
number1Field = new JTextField(10);
cont.add(number1Field);

number2Label = new JLabel("Enter mark of Subject B : ");
cont.add(number2Label);
number2Field = new JTextField(10);
cont.add(number2Field);

number3Label = new JLabel("Enter mark of Subject C : ");
cont.add(number2Label);
number3Field = new JTextField(10);
cont.add(number3Field);



//load student2
student2Label = new JLabel("Enter Student B's marks : ");
cont.add(number2Label);

number4Label = new JLabel("Enter mark of Subject A : ");
cont.add(number4Label);
number4Field = new JTextField(10);
cont.add(number1Field);

number5Label = new JLabel("Enter mark of Subject B : ");
cont.add(number5Label);
number5Field = new JTextField(10);
cont.add(number1Field);

number6Label = new JLabel("Enter mark of Subject C : ");
cont.add(number6Label);
number6Field = new JTextField(10);
cont.add(number1Field);


//load button
button = new JButton("DISPLAY");
button.addActionListener(this);
cont.add(button);

//load result area
outArea = new JTextArea(10,15);
cont.add(outArea);

}//end init()

public void actionPerformed(ActionEvent actionEvent){

display = "THE Calculate rusult:\n";

float max,min,average,sum;
float [][]mark=new float[2][3];
mark[0][0] = Float.parseFloat(number1Field.getText());
mark[0][1] = Float.parseFloat(number2Field.getText());
mark[0][2] = Float.parseFloat(number3Field.getText());
mark[1][0] = Float.parseFloat(number4Field.getText());
mark[1][1] = Float.parseFloat(number5Field.getText());
mark[1][2] = Float.parseFloat(number6Field.getText());

max=mark[0][0];
min=mark[0][0];
sum=0;
for(int i=0;i<2;i++)
for(int j=0;j<3;j++){
if(max<=mark[i][j])max=mark[i][j];
if(min>=mark[i][j])min=mark[i][j];
sum+=mark[i][j];
}
average=sum/6;

display += "The max mark is "+max+"\n";
display += "The min mark is "+min+"\n";
display += "The average mark is"+average+"\n";


outArea.setText(display);
}
}
...全文
33 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
instigator 2003-10-18
  • 打赏
  • 举报
回复
小弟我已经解决那个问题了
不过还是要谢谢你!
呵呵
LoveRose 2003-10-16
  • 打赏
  • 举报
回复
修改为

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;


代码://load student1
student1Label = new JLabel("Enter Student A's marks : ");
cont.add(number1Label);

修改为
//load student1
student1Label = new JLabel("Enter Student A's marks : ");
cont.add(student1Label);
新手求助RBF神经网络数据预测问题-数据.xls 本程序用前六个数据预测下一数据,前200组数据用于训练,用后80组数据进行预测,可预测结果为一个值,请大家指教: 源程序为: clc clear close all %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %每五个数据整合, x=xlsread; n=length m=5; sum=0; j=1; x1=zeros); for k=1:m:n     for i=k:         sum=sum x;     end     x1=sum;     j=j 1;     sum=0; end j t=1:; figure plot;%,'d-m' hold on; grid on title; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %归一化处理 [x2,mint,maxt] = premnmx figure plot;%,'d-m' hold on; grid on title; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %输入数据 for k=1:1:200     p_train=[x2 x2 x2 x2 x2 x2]; 5*6     t_train=x2; 5*1 end     p_train=p_train'; %6*195     t_train=t_train'; %1*195 for z=1:1:81     p_test=[x2 x2 x2 x2 x2 x2];     t_test=x2; end      p_test=p_test';      t_test=t_test'; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %建立 RBF 网络                      goal = 0.0001;                     % 训练误差的平方和 spread = 0.01;                     % 此值越大,需要的神经元就越少 MN = size;              % 最大神经元数 DF = 1;                            % 显示间隔 net = newrb; data_out=sim p_mse=mse figure plot hold on plot title; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %预测并作图 y=sim y_mse=mse figure plot; hold on; plot title; legend;
新手求助RBF神经网络数据预测问题-历史开奖数据.xlsx 本程序用前六个数据预测下一数据,前200组数据用于训练,用后80组数据进行预测,可预测结果为一个值,请大家指教: 源程序为: clc clear close all %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %每五个数据整合, x=xlsread; n=length m=5; sum=0; j=1; x1=zeros); for k=1:m:n     for i=k:         sum=sum x;     end     x1=sum;     j=j 1;     sum=0; end j t=1:; figure plot;%,'d-m' hold on; grid on title; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %归一化处理 [x2,mint,maxt] = premnmx figure plot;%,'d-m' hold on; grid on title; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %输入数据 for k=1:1:200     p_train=[x2 x2 x2 x2 x2 x2]; 5*6     t_train=x2; 5*1 end     p_train=p_train'; %6*195     t_train=t_train'; %1*195 for z=1:1:81     p_test=[x2 x2 x2 x2 x2 x2];     t_test=x2; end      p_test=p_test';      t_test=t_test'; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %建立 RBF 网络                      goal = 0.0001;                     % 训练误差的平方和 spread = 0.01;                     % 此值越大,需要的神经元就越少 MN = size;              % 最大神经元数 DF = 1;                            % 显示间隔 net = newrb; data_out=sim p_mse=mse figure plot hold on plot title; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %预测并作图 y=sim y_mse=mse figure plot; hold on; plot title; legend;

62,612

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧