事件不会写,请高手帮忙 怎么联系你?qq or msn? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import javax.swing.*;import java.awt.*;import java.awt.event.*;public class Assign_1 extends JApplet implements ItemListener{ Container ctp=getContentPane(); TextField tf2=new TextField(5); TextArea ta1= new TextArea("Module\t\t\tResult",1,40,3), ta2= new TextArea(10,40); Button MissBut= new Button("Missing Module"), ExemptBut= new Button("Exempted Module"); Label lb1=new Label("Name"), lb2=new Label("Status"); String obj[]={"Tim","James","Nick","John","Chris"}, status[]={"Pass","Fail","Pass","Pass","Pass"}; int SwDesign[]={0,45,50,59,65}, MultiMe[]={60,0,57,87,40}, DbSys[]={75,45,60,59,80}, OOMP[]={67,0,0,78,79}, WWW[]={90,51,50,70,70}, Maths[]={85,35,50,89,59}, English[]={50,59,0,90,68}; Choice stu_name = new Choice(); public void init() { ctp.setLayout(new FlowLayout()); ctp.add(lb1); for (int n=0;n<obj.length;n++) stu_name.addItem(obj[n]); ctp.add(stu_name); stu_name.addItemListener(this); ctp.add(lb2); ctp.add(tf2); ctp.add(ta1); ctp.add(ta2); ta1.setEditable(false); ta2.setEditable(false); ctp.add(MissBut); ctp.add(ExemptBut); } public void itemStateChanged(ItemEvent e) { int x=0,y; String ko=(String)e.getItem(); for (y=0;y<obj.length;y++) if (ko==obj[y]) x=stu_name.getSelectedIndex(); tf2.setText(status[x]); ta2.setText(""); if( SwDesign[x]!=0) ta2.appendText("Software Design\t\t"+SwDesign[x]+"\n"); if (MultiMe[x]!=0) ta2.appendText("Multimedia System\t"+MultiMe[x]+"\n"); if (DbSys[x]!=0) ta2.appendText("Database System\t\t"+DbSys[x]+"\n"); if (OOMP[x]!=0) ta2.appendText("Object Oriented Program\t"+OOMP[x]+"\n"); if (WWW[x]!=0) ta2.appendText("World Wide Web\t\t"+WWW[x]+"\n"); if (Maths[x]!=0) ta2.appendText("Maths\t\t\t"+Maths[x]+"\n"); if (English[x]!=0) ta2.appendText("English\t\t\t"+English[x]+"\n"); } public boolean action( Event event, Object o ) { int x=stu_name.getSelectedIndex(); if ( event.target instanceof Button ) { String current = (String) event.arg; if ( current.equals( "Missing Module" ) ) { int y=0; ta2.setText(""); ta2.appendText("Missing Modules:\n\n"); if (SwDesign[x]==0) { ta2.appendText("\tSoftware Design\n"); y=1; } if (MultiMe[x]==0) { ta2.appendText("\tMultimedia System\n"); y=1; } if (DbSys[x]==0) { ta2.appendText("\tDatabase System\n"); y=1; } if (OOMP[x]==0) { ta2.appendText("\tObject Oriented Program\n"); y=1; } if (WWW[x]==0) { ta2.appendText("\tWorld Wide Web\n"); y=1; } if (Maths[x]==0) { ta2.appendText("\tMaths\n"); y=1; } if (English[x]==0) { ta2.appendText("\tEnglish\n"); y=1; } if ( y==0) ta2.appendText("\tNo missing modules !"); } else if ( current.equals( "Exempted Module" ) ) { int y=0; ta2.setText(""); ta2.appendText("Exempted Moules:\n\n"); if (SwDesign[x]>75) { ta2.appendText("\tSoftware Engineering\n"); y=1; } if (Maths[x]>75) { ta2.appendText("\tAdvance Maths\n"); y=1; } if (WWW[x]>75) { ta2.appendText("\tWeb Fundamentals\n"); y=1; } if (y==0) ta2.appendText("\tNo exempted modules !"); } } return true; }} import javax.swing.*;import java.awt.*;import java.awt.event.*;public class project3 extends JApplet implements ItemListener{ Container c=getContentPane(); JLabel label=new JLabel("请选择学生姓名"), label1=newJLabel("--------------------------------------------------------------------------------"), label2=new JLabel(" "), label3=new JLabel(" "), label4=new JLabel(" "); JComboBox cbx = new JComboBox(); JTextArea txt = new JTextArea(8, 20), textM = new JTextArea(2,12), textE = new JTextArea(2,12); JButton button1 = new JButton(" Missing Modules"), button2 = new JButton("Exempted Modules"); String name[] = {"张奇峰","杨耀","蔡平盛","林艺宾","张炎","邱君"}, VB[] = {"","","75","72","",""}, JAVA[] = {"80","80","80","","80",""}, MLT[] = {"80","80","80","80","80","80"}, DWS[] = {"63","70","80","65","60","80"}, SD[] = {"","","","","",""}, BO[] = {"","","75","78","80",""}, BC[] = {"70","75","78","65","60",""}, CT[] = {"","67","63","80","73",""};public void init() { c.setLayout(new FlowLayout()); for (int n=0;n<name.length;n++) cbx.addItem(name[n]); c.add(label); c.add(cbx); cbx.addItemListener(this); c.add(txt); c.add(label1); c.add(button1); c.add(label2); c.add(button2); c.add(label4); c.add(textM); c.add(label3); c.add(textE); setSize(380, 320); }public void itemStateChanged(ItemEvent e) { int x=0,y; String ko=(String)e.getItem(); for (y=0;y<name.length;y++) if (ko==name[y]) x=cbx.getSelectedIndex(); txt.setText(""); if(VB[x]!="") txt.append("Visual Basic :\t\t"+VB[x]+"\n"); if(JAVA[x]!="") txt.append("Java :\t\t "+JAVA[x]+"\n"); if(MLT [x]!="") txt.append("Multimedia :\t\t "+MLT [x]+"\n"); if(DWS [x]!="") txt.append("Development a Web Site :\t "+DWS [x]+"\n"); if(SD [x]!="") txt.append("Systems Development :\t "+ SD[x]+"\n"); if(BC [x]!="") txt.append("Business Communication :\t "+BC [x]+"\n"); if(BO [x]!="") txt.append("Business Organization :\t "+BO [x]+"\n"); if( CT[x]!="") txt.append("Computer Technology :\t "+ CT[x]+"\n"); } //public boolean action( Event event, Object o ) // {}你先运行一下,我现在想在下面的2个文字区内显示未修和免修的科目。谢了,我的email:[email protected] import javax.swing.*;import java.awt.*;import java.awt.event.*;public class name extends JApplet implements ItemListener { int x = 0; Container c=getContentPane(); JLabel label=new JLabel("请选择学生姓名"), label1=new JLabel("--------------------------------------------------------------------------------"), label2=new JLabel(" "), label3=new JLabel(" "), label4=new JLabel(" "); JComboBox cbx = new JComboBox(); JTextArea txt = new JTextArea(8, 20), textM = new JTextArea(2,12), textE = new JTextArea(2,12); JButton button1 = new JButton(" Missing Modules"), button2 = new JButton("Exempted Modules"); String name[] = {"张奇峰","杨耀","蔡平盛","林艺宾","张炎","邱君"}; String lessons[] = {"VB","JAVA","MLT","DWS","SD","BO","BC","CT"}; int scores[][] = { {0,0,75,72,0,0}, {80,80,80,0,80,0}, {80,80,80,80,80,80}, {63,70,80,65,60,80}, {0,0,0,0,0,0}, {0,0,75,78,80,0}, {70,75,78,65,60,0}, {0,67,63,80,73,0} }; public void init(){ c.setLayout(new FlowLayout()); for (int n=0;n<name.length;n++){ cbx.addItem(name[n]); } c.add(label); c.add(cbx); cbx.addItemListener(this); c.add(txt); c.add(label1); c.add(button1); c.add(label2); c.add(button2); c.add(label4); c.add(textM); c.add(label3); c.add(textE); button1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { button1_actionPerformed(e); } }); button2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { button2_actionPerformed(e); } }); setSize(380, 320); } public void itemStateChanged(ItemEvent e){ int y; String ko=(String)e.getItem(); for (y=0;y<name.length;y++) if (ko==name[y]){ x=cbx.getSelectedIndex(); txt.setText(""); if(scores[0][x]!=0) txt.append("Visual Basic :\t\t"+scores[0][x]+"\n"); if(scores[1][x]!=0) txt.append("Java :\t\t "+scores[1][x]+"\n"); if(scores[2][x]!=0) txt.append("Multimedia :\t\t "+scores[2][x]+"\n"); if(scores[3][x]!=0) txt.append("Development a Web Site :\t "+scores[3][x]+"\n"); if(scores[4][x]!=0) txt.append("Systems Development :\t "+scores[4][x]+"\n"); if(scores[5][x]!=0) txt.append("Business Communication :\t "+scores[5][x]+"\n"); if(scores[6][x]!=0) txt.append("Business Organization :\t "+scores[6][x]+"\n"); if(scores[7][x]!=0) txt.append("Computer Technology :\t "+scores[7][x]+"\n"); } } void button1_actionPerformed(ActionEvent e) { textM.setText(""); for(int z = 0;z<8 ;z++){ if(scores[z][x]<60){ textM.append(lessons[z]+"\n"); } } } void button2_actionPerformed(ActionEvent e) { textE.setText(""); for(int z = 0;z<8 ;z++){ if(scores[z][x]>=60){ textE.append(lessons[z]+"\n"); } } }} 以后最好不要直接找代码,至少要现有自己的思路,然后有那个部分不会再来问晕了,刚发现你只是来问事件的,可是我为了实现的方便,把你的数据结构做了点修改,你所要求的功能都已经实现了,自己仔细的读一下代码吧我事件的部分用的是JB自动生成的代码copy过来的,因为我觉得这部分代码简洁明了。 如何识别html元素是不是输入框?? 一道关于断言的题目 急﹗急﹗急﹗請大家幫忙,將這段c++源碼轉換成java源碼 急需解决的问题,请帮忙! 简单问题,加散分! 怎样增长定长的数字字串,前面补”0”: //eg. Num_Incre (‘00023’) => ‘00024’ 急!!高人帮忙呀!!!一个关于获取JPanel尺寸的问题!!!抢分呀!! redkey 老兄进来接分 一个多点发送的应用程序,可是本能接收??? 初学Java,有些问题想问?详细请进。 请问怎样实现JAVA程序的自动连接 哪儿能下载到不是试用版的JCreator呀???
import java.awt.*;
import java.awt.event.*;
public class Assign_1 extends JApplet implements ItemListener
{
Container ctp=getContentPane();
TextField tf2=new TextField(5); TextArea ta1= new TextArea("Module\t\t\tResult",1,40,3),
ta2= new TextArea(10,40);
Button MissBut= new Button("Missing Module"),
ExemptBut= new Button("Exempted Module"); Label lb1=new Label("Name"),
lb2=new Label("Status");
String obj[]={"Tim","James","Nick","John","Chris"},
status[]={"Pass","Fail","Pass","Pass","Pass"}; int SwDesign[]={0,45,50,59,65},
MultiMe[]={60,0,57,87,40},
DbSys[]={75,45,60,59,80},
OOMP[]={67,0,0,78,79},
WWW[]={90,51,50,70,70},
Maths[]={85,35,50,89,59},
English[]={50,59,0,90,68}; Choice stu_name = new Choice();
public void init()
{
ctp.setLayout(new FlowLayout());
ctp.add(lb1);
for (int n=0;n<obj.length;n++)
stu_name.addItem(obj[n]);
ctp.add(stu_name);
stu_name.addItemListener(this); ctp.add(lb2);
ctp.add(tf2);
ctp.add(ta1);
ctp.add(ta2);
ta1.setEditable(false);
ta2.setEditable(false); ctp.add(MissBut);
ctp.add(ExemptBut);
}
public void itemStateChanged(ItemEvent e)
{
int x=0,y;
String ko=(String)e.getItem();
for (y=0;y<obj.length;y++)
if (ko==obj[y])
x=stu_name.getSelectedIndex();
tf2.setText(status[x]);
ta2.setText("");
if( SwDesign[x]!=0)
ta2.appendText("Software Design\t\t"+SwDesign[x]+"\n");
if (MultiMe[x]!=0)
ta2.appendText("Multimedia System\t"+MultiMe[x]+"\n");
if (DbSys[x]!=0)
ta2.appendText("Database System\t\t"+DbSys[x]+"\n");
if (OOMP[x]!=0)
ta2.appendText("Object Oriented Program\t"+OOMP[x]+"\n");
if (WWW[x]!=0)
ta2.appendText("World Wide Web\t\t"+WWW[x]+"\n");
if (Maths[x]!=0)
ta2.appendText("Maths\t\t\t"+Maths[x]+"\n");
if (English[x]!=0)
ta2.appendText("English\t\t\t"+English[x]+"\n");
}
public boolean action( Event event, Object o )
{
int x=stu_name.getSelectedIndex();
if ( event.target instanceof Button )
{
String current = (String) event.arg;
if ( current.equals( "Missing Module" ) )
{
int y=0;
ta2.setText("");
ta2.appendText("Missing Modules:\n\n");
if (SwDesign[x]==0)
{
ta2.appendText("\tSoftware Design\n");
y=1;
}
if (MultiMe[x]==0)
{
ta2.appendText("\tMultimedia System\n");
y=1;
}
if (DbSys[x]==0)
{
ta2.appendText("\tDatabase System\n");
y=1;
}
if (OOMP[x]==0)
{
ta2.appendText("\tObject Oriented Program\n");
y=1;
}
if (WWW[x]==0)
{
ta2.appendText("\tWorld Wide Web\n");
y=1;
}
if (Maths[x]==0)
{
ta2.appendText("\tMaths\n");
y=1;
}
if (English[x]==0)
{
ta2.appendText("\tEnglish\n");
y=1;
}
if ( y==0)
ta2.appendText("\tNo missing modules !");
} else if ( current.equals( "Exempted Module" ) )
{
int y=0;
ta2.setText("");
ta2.appendText("Exempted Moules:\n\n");
if (SwDesign[x]>75)
{
ta2.appendText("\tSoftware Engineering\n");
y=1;
}
if (Maths[x]>75)
{
ta2.appendText("\tAdvance Maths\n");
y=1;
}
if (WWW[x]>75)
{
ta2.appendText("\tWeb Fundamentals\n");
y=1;
}
if (y==0)
ta2.appendText("\tNo exempted modules !");
} }
return true;
}
}
import java.awt.*;
import java.awt.event.*;
public class project3 extends JApplet implements ItemListener
{
Container c=getContentPane();
JLabel label=new JLabel("请选择学生姓名"),
label1=new
JLabel("--------------------------------------------------------------------------------"),
label2=new JLabel(" "),
label3=new JLabel(" "),
label4=new JLabel(" ");
JComboBox cbx = new JComboBox();
JTextArea txt = new JTextArea(8, 20),
textM = new JTextArea(2,12),
textE = new JTextArea(2,12);
JButton button1 = new JButton(" Missing Modules"),
button2 = new JButton("Exempted Modules");
String name[] = {"张奇峰","杨耀","蔡平盛","林艺宾","张炎","邱君"},
VB[] = {"","","75","72","",""},
JAVA[] = {"80","80","80","","80",""},
MLT[] = {"80","80","80","80","80","80"},
DWS[] = {"63","70","80","65","60","80"},
SD[] = {"","","","","",""},
BO[] = {"","","75","78","80",""},
BC[] = {"70","75","78","65","60",""},
CT[] = {"","67","63","80","73",""};
public void init()
{
c.setLayout(new FlowLayout());
for (int n=0;n<name.length;n++)
cbx.addItem(name[n]);
c.add(label);
c.add(cbx);
cbx.addItemListener(this);
c.add(txt);
c.add(label1);
c.add(button1);
c.add(label2);
c.add(button2);
c.add(label4);
c.add(textM);
c.add(label3);
c.add(textE);
setSize(380, 320);
}
public void itemStateChanged(ItemEvent e)
{
int x=0,y;
String ko=(String)e.getItem();
for (y=0;y<name.length;y++)
if (ko==name[y])
x=cbx.getSelectedIndex();
txt.setText("");
if(VB[x]!="")
txt.append("Visual Basic :\t\t"+VB[x]+"\n");
if(JAVA[x]!="")
txt.append("Java :\t\t "+JAVA[x]+"\n");
if(MLT [x]!="")
txt.append("Multimedia :\t\t "+MLT [x]+"\n");
if(DWS [x]!="")
txt.append("Development a Web Site :\t "+DWS [x]+"\n");
if(SD [x]!="")
txt.append("Systems Development :\t "+ SD[x]+"\n");
if(BC [x]!="")
txt.append("Business Communication :\t "+BC [x]+"\n");
if(BO [x]!="")
txt.append("Business Organization :\t "+BO [x]+"\n");
if( CT[x]!="")
txt.append("Computer Technology :\t "+ CT[x]+"\n");
}
//public boolean action( Event event, Object o )
// {}
你先运行一下,我现在想在下面的2个文字区内显示未修和免修的科目。
谢了,我的email:[email protected]
import java.awt.*;
import java.awt.event.*;public class name extends JApplet implements ItemListener {
int x = 0;
Container c=getContentPane();
JLabel label=new JLabel("请选择学生姓名"),
label1=new JLabel("--------------------------------------------------------------------------------"),
label2=new JLabel(" "),
label3=new JLabel(" "),
label4=new JLabel(" ");
JComboBox cbx = new JComboBox();
JTextArea txt = new JTextArea(8, 20),
textM = new JTextArea(2,12),
textE = new JTextArea(2,12);
JButton button1 = new JButton(" Missing Modules"),
button2 = new JButton("Exempted Modules");
String name[] = {"张奇峰","杨耀","蔡平盛","林艺宾","张炎","邱君"};
String lessons[] = {"VB","JAVA","MLT","DWS","SD","BO","BC","CT"};
int scores[][] = {
{0,0,75,72,0,0},
{80,80,80,0,80,0},
{80,80,80,80,80,80},
{63,70,80,65,60,80},
{0,0,0,0,0,0},
{0,0,75,78,80,0},
{70,75,78,65,60,0},
{0,67,63,80,73,0}
};
public void init(){
c.setLayout(new FlowLayout());
for (int n=0;n<name.length;n++){
cbx.addItem(name[n]);
}
c.add(label);
c.add(cbx);
cbx.addItemListener(this);
c.add(txt);
c.add(label1);
c.add(button1);
c.add(label2);
c.add(button2);
c.add(label4);
c.add(textM);
c.add(label3);
c.add(textE);
button1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button1_actionPerformed(e);
}
});
button2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button2_actionPerformed(e);
}
});
setSize(380, 320);
}
public void itemStateChanged(ItemEvent e){
int y;
String ko=(String)e.getItem();
for (y=0;y<name.length;y++)
if (ko==name[y]){
x=cbx.getSelectedIndex();
txt.setText("");
if(scores[0][x]!=0)
txt.append("Visual Basic :\t\t"+scores[0][x]+"\n");
if(scores[1][x]!=0)
txt.append("Java :\t\t "+scores[1][x]+"\n");
if(scores[2][x]!=0)
txt.append("Multimedia :\t\t "+scores[2][x]+"\n");
if(scores[3][x]!=0)
txt.append("Development a Web Site :\t "+scores[3][x]+"\n");
if(scores[4][x]!=0)
txt.append("Systems Development :\t "+scores[4][x]+"\n");
if(scores[5][x]!=0)
txt.append("Business Communication :\t "+scores[5][x]+"\n");
if(scores[6][x]!=0)
txt.append("Business Organization :\t "+scores[6][x]+"\n");
if(scores[7][x]!=0)
txt.append("Computer Technology :\t "+scores[7][x]+"\n");
}
}
void button1_actionPerformed(ActionEvent e) {
textM.setText("");
for(int z = 0;z<8 ;z++){
if(scores[z][x]<60){
textM.append(lessons[z]+"\n");
}
}
}
void button2_actionPerformed(ActionEvent e) {
textE.setText("");
for(int z = 0;z<8 ;z++){
if(scores[z][x]>=60){
textE.append(lessons[z]+"\n");
}
}
}
}
可是我为了实现的方便,把你的数据结构做了点修改,你所要求的功能都已经实现了,
自己仔细的读一下代码吧我事件的部分用的是JB自动生成的代码copy过来的,因为我觉得这部分代码简洁明了。