import java.awt.*;

成都創(chuàng)新互聯(lián)公司專注于梨林企業(yè)網站建設,成都響應式網站建設公司,商城網站制作。梨林網站建設公司,為梨林等地區(qū)提供建站服務。全流程按需定制,專業(yè)設計,全程項目跟蹤,成都創(chuàng)新互聯(lián)公司專業(yè)和態(tài)度為您提供的服務
import java.awt.event.*;
import java.util.*;
class p1 extends Panel
{
Label l1;
Font f=new Font("宋體",Font.BOLD,20);
p1()
{
setLayout(new GridLayout(1,1));
l1=new Label("網上選課記錄系統(tǒng)",Label.CENTER);
l1.setFont(f);
add(l1);
}
}
class p2 extends Panel
{
Label l1,l2;
TextField t1,t2;
p2()
{
setLayout(new GridLayout(1,4));
l1=new Label("姓名",Label.CENTER);
l2=new Label("學號",Label.CENTER);
t1=new TextField(10);
t2=new TextField(10);
add(l1);
add(t1);
add(l2);
add(t2);
}
}
class p3 extends Panel
{
Label l1,l2;
TextField t1,t2;
p3()
{
setLayout(new GridLayout(1,4));
l1=new Label("專業(yè)",Label.CENTER);
l2=new Label("所屬院(系)",Label.CENTER);
t1=new TextField(10);
t2=new TextField(10);
add(l1);
add(t1);
add(l2);
add(t2);
}
}
class p4 extends Panel
{
Label l1;
Button btn1;
Button btn2;
Button btn3;
Font f=new Font("宋體",Font.BOLD,20);
p4()
{
setLayout(new GridLayout(1,4));
l1=new Label("請選擇您要選修的課程并確認",Label.CENTER);
btn1=new Button("查詢");
btn2=new Button("確認");
btn3=new Button("退出系統(tǒng)");
add(l1);
add(btn1);
add(btn2);
add(btn3);
}
}
class p5 extends Panel
{
List list ;
p5()
{
setLayout(new GridLayout(1,1));
list=new List(8,true);
list.add("大學英語");
list.add("計算機圖形學");
list.add("JAVA語言");
list.add("高等數(shù)學");
list.add("數(shù)據結構");
list.add("單片機");
list.add("網絡應用與開發(fā)");
list.add("概率論與數(shù)理統(tǒng)計");
list.add("管理學概論");
list.add("數(shù)據庫概論");
list.add("英語聽力");
list.add("VC++");
list.add("商務英語");
list.add("會計學");
list.add("經濟學");
list.add("計算機網絡");
add(list);
}
}
class p6 extends Panel
{
TextArea ta;
p6()
{
setLayout(new GridLayout(1,1));
ta=new TextArea(8,30);
add(ta);
}
}
class p8 extends Panel
{
Label l1,l2,l3;
Label l4,l5,l6,l7,l9;
Panel p11,p22,p33,p44,p55;
TextField t1,t2;
Button btn;
p8()
{
p11=new Panel();
p22=new Panel();
p33=new Panel();
p44=new Panel();
p55=new Panel();
p11.setLayout(new GridLayout(1,1));
p22.setLayout(new GridLayout(1,1));
p33.setLayout(new GridLayout(1,4));
p44.setLayout(new GridLayout(1,4));
p55.setLayout(new GridLayout(1,1));
l4=new Label("");
l5=new Label("");
l6=new Label("");
l7=new Label("");
l9=new Label("");
l1=new Label("歡迎來到網上選課系統(tǒng)",Label.CENTER);
Font f=new Font("宋體",Font.BOLD,30);
l1.setFont(f);
l2=new Label("請輸入管理員帳號",Label.CENTER);
l3=new Label("請輸入管理員密碼",Label.CENTER);
setBackground(Color.lightGray);
btn=new Button("確定");
t1=new TextField(20);
t2=new TextField(15);
t2.setEchoChar(′*′);
l1.setForeground(Color.magenta);
t1.setBackground(Color.cyan);
t2.setBackground(Color.cyan);
t1.setForeground(Color.red);
t2.setForeground(Color.red);
l2.setForeground(Color.blue);
l3.setForeground(Color.blue);
p11.add(l1);
p22.add(l4);
p33.add(l5);
p33.add(l2);
p33.add(t1);
p33.add(l6);
p44.add(l7);
p44.add(l3);
p44.add(t2);
p44.add(btn);
p55.add(l9);
setLayout(new GridLayout(5,1));
add(p11);
add(p22);
add(p33);
add(p44);
add(p55);
}
}
class p9 extends Panel
{
p1 pn1=new p1();
p2 pn2=new p2();
p3 pn3=new p3();
p4 pn4=new p4();
p5 pn5=new p5();
p6 pn6=new p6();
p9()
{
setLayout(new GridLayout(6,1));
add(pn1);
add(pn2);
add(pn3);
add(pn4);
add(pn5);
add(pn6);
}
}
class user
{
String username;
String sd;
String major;
String institute;
String course;
user(String x1,String x2,String x3,String x4,String x5)
{
username=x1;
sd=x2;
major=x3;
institute=x4;
course=x5;
}
}
public class www
{
public static void main(String args[])
{
new m();
}
}
class m extends Frame implements ActionListener,ItemListener
{
StringBuffer ss=new StringBuffer("您好!您選修的課程有:");
Vector xiang=new Vector();
p9 pn9;
p8 pn8;
CardLayout cc=new CardLayout();
Button btn1;
Dialog d1;
m()
{
super("網上選課");
pn8=new p8();
pn9=new p9();
setLayout(cc);
add("one",pn8);
add("two",pn9);
btn1=new Button("確定");
pn9.pn1.l1.setBackground(Color.pink);
pn9.pn1.l1.setForeground(Color.blue);
pn9.pn2.l1.setBackground(Color.gray);
pn9.pn2.l1.setForeground(Color.orange);
pn9.pn2.l2.setBackground(Color.gray);
pn9.pn2.l2.setForeground(Color.orange);
pn9.pn3.l1.setBackground(Color.gray);
pn9.pn3.l1.setForeground(Color.orange);
pn9.pn3.l2.setBackground(Color.gray);
pn9.pn3.l2.setForeground(Color.orange);
pn9.pn2.t1.setForeground(Color.red);
pn9.pn2.t1.setBackground(Color.cyan);
pn9.pn2.t2.setForeground(Color.red);
pn9.pn2.t2.setBackground(Color.cyan);
pn9.pn3.t1.setForeground(Color.red);
pn9.pn3.t1.setBackground(Color.cyan);
pn9.pn3.t2.setForeground(Color.red);
pn9.pn3.t2.setBackground(Color.cyan);
pn9.pn5.list.setBackground(Color.pink);
pn9.pn5.list.setForeground(Color.blue);
pn9.pn6.ta.setBackground(Color.blue);
pn9.pn6.ta.setForeground(Color.white);
pn9.pn4.btn1.addActionListener(this);
pn9.pn4.btn2.addActionListener(this);
pn9.pn4.btn3.addActionListener(this);
pn9.pn5.list.addActionListener(this);
(pn9.pn5.list).addItemListener(this);
pn8.btn.addActionListener(this);
btn1.addActionListener(this);
setSize(650,400);
show();
}
public void actionPerformed(ActionEvent e)
{
xiang.addElement(new user("馬先生","23597483","計算機","計算機系","單片機,數(shù)學"));
xiang.addElement(new user("楊先生","7899452","計算機","計算機系","單片機,數(shù)學"));
xiang.addElement(new user("董先生","7899452","計算機","計算機系","單片機,數(shù)學"));
xiang.addElement(new user("何先生","7899453","計算機","計算機系","單片機,數(shù)學"));
if(e.getSource()==pn8.btn)
{
String ss="123";
if(ss點抗 pareTo(pn8.t1.getText())==0ss點抗 pareTo(pn8.t2.getText())==0)
cc.show(this,"two");
else
{
d1=new Dialog(this,"警告",true);
Panel p1=new Panel();
p1.add(new Label("您無權進本系統(tǒng)!"));
d1.add("Center",p1);
Panel p2=new Panel();
p2.add(btn1);
d1.add("South",p2);
d1.setSize(200,100);
d1.show();
}
}
if(e.getSource()==btn1)
{
d1.dispose();
}
if(e.getSource()==pn9.pn4.btn3)
{
dispose();
System.exit(0);
}
if(e.getSource()==pn9.pn4.btn2)
{
pn9.pn6.ta.setText("");
ss.append(" 您的姓名是:"+pn9.pn2.t1.getText()+" "+"您的學號是:"+pn9.pn2.t2.getText()+" ");
ss.append("您的專業(yè)是:"+pn9.pn3.t1.getText()+" "+"您所在院(系)是:"+pn9.pn3.t2.getText()+" ");
ss.append("您的所有信息將被保存!");
pn9.pn6.ta.setText(ss.toString());
user s1=new user(pn9.pn2.t1.getText(),pn9.pn2.t2.getText(),pn9.pn3.t1.getText(),pn9.pn3.t2.getText(),ss.toString());
int i;
for(i=0;ixiang.size();i++)
{
user s=(user)xiang.elementAt(i);
if(s.sd點抗 pareTo(s1.sd)==0)
{
s.username=s1.username;
s.sd=s1.sd;
s.major=s1.major;
s.institute=s1.institute;
s.course=s1.course;
xiang.setElementAt(new user(s.username,s.sd,s.major,s.institute,s.course),i);
break;
}
}
if(i==xiang.size())
xiang.addElement(new user(pn9.pn2.t1.getText(),pn9.pn2.t2.getText(),pn9.pn3.t1.getText(),pn9.pn3.t2.getText(),ss.toString()));
}
if(e.getSource()==pn9.pn4.btn1)
{
pn9.pn6.ta.setText("");
if(pn9.pn2.t2.getText()=="")
{
d1=new Dialog(this,"注意",true);
Panel p1=new Panel();
p1.add(new Label("按學號進行查詢!請輸入學號!再按此鍵!"));
d1.add("Center",p1);
Panel p2=new Panel();
p2.add(btn1);
d1.add("South",p2);
d1.setSize(250,100);
d1.show();
}
int i;
for(i=0;ixiang.size();i++)
{
user s=(user)xiang.elementAt(i);
if(s.sd點抗 pareTo(pn9.pn2.t2.getText())==0)
{
pn9.pn2.t1.setText(""+s.username);
pn9.pn3.t1.setText(""+s.major);
pn9.pn3.t2.setText(""+s.institute);
pn9.pn6.ta.setText("您選修的課程有:"+s.course);
break;
}
}
if(i==xiang.size())
{
d1=new Dialog(this,"警告",true);
Panel p1=new Panel();
p1.add(new Label("用戶不存在!請重新輸入!"));
d1.add("Center",p1);
Panel p2=new Panel();
p2.add(btn1);
d1.add("South",p2);
d1.setSize(200,100);
d1.show();
}
}
}
public void itemStateChanged(ItemEvent e)
{
List temp;
String sList[];
String mgr=new String("");
if(e.getItemSelectable()instanceof List)
{
temp=(List)(e.getItemSelectable());
sList=temp.getSelectedItems();
for(int i=0;isList.length;i++)
mgr=mgr+sList[i]+" ";
ss.append(mgr);
}
}
}
本程序已經成功!!!望再驗證!!!!
java課程設計題目及代碼分別是:
1、題目:計算器。設計內容是設計一個圖形界面(GUI)的計算器應用程序,完成簡單的算術運算。
設計要求是設計的計算器應用程序可以完成家法、減法、乘法、除法和取余運算。且有小數(shù)點、正負號、求倒數(shù)、退格和清零功能。
2、代碼:
數(shù)字按鈕NumberButton類如下:
import java.awt.
import java.awt.event.
import javax.swing.
public class NumberButton extends Button.
{
int number.
public NumberButton(int number).
{
super(""+number).
this.number=number.
setForeground(Color.blue).
}
public int getNumber().
{
return number;
}
}
其它java課程設計題目及代碼是:
題目:華容道。編寫一個按鈕的子類,使用該子類創(chuàng)建的對象代表華容道中的人物。通過焦點事件控制人物顏色,當人物獲得焦點時顏色為藍色,當失去焦點時顏色為灰色。
通過鍵盤事件和鼠標事件來實現(xiàn)曹操、關羽等人物的移動。當人物上發(fā)生鼠標事件或鍵盤事件時,如果鼠標指針的位置是在人物的下方(也就是組件的下半部分)或按下鍵盤的“↓“鍵,該人物向下移動。向左、向右和向上的移動原理類似。
代碼是:
String name[]={"曹操","關羽","張","劉","馬","許","兵","兵","兵","兵"}.
for(int i=0;iname.length;i++).
{
person[i]=new Person(i,name[i]).
person[i].addKeyListener(this).
person[i].addMouseListener(this).
//? ? ?person[i].addFocusListener(new Person).
add(person[i]).
}
person[0].setBounds(104,54,100,100).
person[1].setBounds(104,154,100,50).
person[2].setBounds(54,154,50,100).
person[3].setBounds(204,154,50,100).
person[4].setBounds(54,54,50,100).
person[5].setBounds(204,54,50,100);
person[6].setBounds(54,254,50,50);
person[7].setBounds(204,254,50,50);
person[8].setBounds(104,204,50,50);
person[9].setBounds(154,204,50,50);
Java 程序員必須收藏的資源大全
古董級工具
這些工具伴隨著Java一起出現(xiàn),在各自輝煌之后還在一直使用。
Apache Ant:基于XML的構建管理工具。
cglib:字節(jié)碼生成庫。
GlassFish:應用服務器,由Oracle贊助支持的Java EE參考實現(xiàn)。
Hudson:持續(xù)集成服務器,目前仍在活躍開發(fā)。
JavaServer Faces:Mojarra是JSF標準的一個開源實現(xiàn),由Oracle開發(fā)。
JavaServer Pages:支持自定義標簽庫的網站通用模板庫。
Liquibase:與具體數(shù)據庫獨立的追蹤、管理和應用數(shù)據庫Scheme變化的工具。
2.構建工具
構建及應用依賴關系處理工具。
Apache Maven:Maven是一款聲明式構建及依賴管理工具,采用約定優(yōu)于配置方式進行管理。相對Apache Ant更推薦使用Maven,前者采用了過程式管理,維護相對困難。
Bazel:來自Google的構建工具,可以快速、可靠地構建代碼。
Gradle:使用Groovy(非XML)進行增量構建,可以很好地與Maven依賴管理配合工作。
需要這些學習資料和工具的可以自己下載哦
分享名稱:java網上教學代碼 java在線教學
轉載來源:http://chinadenli.net/article46/ddgsgeg.html
成都網站建設公司_創(chuàng)新互聯(lián),為您提供營銷型網站建設、App設計、標簽優(yōu)化、微信公眾號、外貿網站建設、電子商務
聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)