石大遠(yuǎn)程Java語(yǔ)言程序設(shè)計(jì)在線(xiàn)考試第二題_第1頁(yè)
石大遠(yuǎn)程Java語(yǔ)言程序設(shè)計(jì)在線(xiàn)考試第二題_第2頁(yè)
石大遠(yuǎn)程Java語(yǔ)言程序設(shè)計(jì)在線(xiàn)考試第二題_第3頁(yè)
石大遠(yuǎn)程Java語(yǔ)言程序設(shè)計(jì)在線(xiàn)考試第二題_第4頁(yè)
石大遠(yuǎn)程Java語(yǔ)言程序設(shè)計(jì)在線(xiàn)考試第二題_第5頁(yè)
已閱讀5頁(yè),還剩17頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、中國(guó)石油大學(xué)(北京)遠(yuǎn)程教育學(xué)院期 末 考 試 Java語(yǔ)言程序設(shè)計(jì) 學(xué)習(xí)中心:通州_   姓名:_程瀟 學(xué)號(hào):_117910_一、簡(jiǎn)答題1 什么是多態(tài)性? 方法的重載和覆蓋有何區(qū)別? 閱讀下列代碼,指出其中存在的重載和覆蓋, 寫(xiě)出輸出結(jié)果是什么?解釋為什么這樣輸出? (15分)class Class1 public void find() System.out.println("Class1.find");class Class2 extends Class1public void find() System.out.println("Cla

2、ss2.find"); class Class3 public void get(Class1 one) System.out.println("get(Class1)");one.find();public void get(Class2 two) System.out.println("get(Class2)");two.find();public class Test1 public static void main(String args) Class1 one = new Class2();Class3 three = new Cla

3、ss3();three.get(one);1 什么是多態(tài)性? 方法的重載和覆蓋有何區(qū)別? 閱讀下列代碼,指出其中存在的重載和覆蓋, 寫(xiě)出輸出結(jié)果是什么?解釋為什么這樣輸出? (15分)多態(tài)性:指允許不同類(lèi)的對(duì)象對(duì)同一消息做出響應(yīng)。即同一消息可以根據(jù)發(fā)送對(duì)象的不同而采用多種不同的行為方式。(發(fā)送消息就是函數(shù)調(diào)用)方法的重載和覆蓋的區(qū)別:重載public void println(int i); public void println(char c); public void println(String s);覆蓋public class Employee String name; int sa

4、lary; public String getDetails() return " Name: "+ name+ " n "+ "Salary: "+ salary; - public class Manager extends Employee String department;/* 方法的覆蓋*/ public String getDetails() return " Name: "+ name+ " n "+ " Manager of "+department; pu

5、blic void test() /調(diào)用父類(lèi)的方法,怎么辦? System.out.println(super.getDetails(); public static void main(String args) Manager m=new Manager(); System.out.println( m.getDetails(); - (1)方法的覆蓋是子類(lèi)和父類(lèi)之間的關(guān)系,是垂直關(guān)系;方法的重載是同一個(gè)類(lèi)中方法之間的關(guān)系,是水平關(guān)系。 (2)覆蓋只能由一個(gè)方法,或只能由一對(duì)方法產(chǎn)生關(guān)系;方法的重載是多個(gè)方法之間的關(guān)系。 (3)覆蓋要求參數(shù)列表相同;重載要求參數(shù)列表不同。 (4)覆蓋關(guān)系中,

6、調(diào)用那個(gè)方法體,是根據(jù)對(duì)象的類(lèi)型(對(duì)象對(duì)應(yīng)存儲(chǔ)空間類(lèi)型)來(lái)決定;重載關(guān)系,是根據(jù)調(diào)用時(shí)的實(shí)參表與形參表來(lái)選擇方法體的。Class1和class2 中都有的find方法,其中class2就是繼承了class1的find方法就是覆蓋而class3有兩個(gè)get方法因?yàn)槿雲(yún)⒉灰粯泳褪侵剌dget(Class1)Class2.findOne 是class1對(duì)象所以輸出public void get(Class1 one) 因?yàn)閏lass2覆蓋了class1 所以輸出class2 find 函數(shù)2、請(qǐng)說(shuō)說(shuō)final、finally的區(qū)別和作用,舉例說(shuō)明用法;另外用自己的語(yǔ)言介紹throw/throws有什么

7、聯(lián)系和區(qū)別?在程序中應(yīng)如何使用?(15分)final可以修飾類(lèi) ,成員變量,局部變量和方法。1.final修飾成員變量final成員變量的初始化對(duì)于final修飾的變量,系統(tǒng)不會(huì)默認(rèn)初始化為0fina變量初始化方式:在定義的時(shí)候初始化final變量可以在初始化塊中初始化,不可以在靜態(tài)初始化塊中初始化。靜態(tài)final變量可以在靜態(tài)初始化塊中初始化,不可以在初始化塊中初始化。fina變量還可以在構(gòu)造函數(shù)中初始化,但是靜態(tài)final變量不可以。2.final修飾方法當(dāng)final用來(lái)修飾方法時(shí),表示這個(gè)方法不可以被子類(lèi)覆蓋。3.final修飾類(lèi) final修飾的列不允許被繼承,編譯器在處理時(shí)把它的所有

8、方法都當(dāng)作final的,因此final類(lèi)比普通類(lèi)擁有更高的效率。而由關(guān)鍵字abstract定義的抽象列含有必須由繼承自它的子類(lèi)重載實(shí)現(xiàn)的抽象方法,因此無(wú)法同時(shí)用final和abstract來(lái)修飾同一個(gè)類(lèi)。同樣的道理,final也不能用來(lái)修飾接口。final的類(lèi)的方法都不能被重寫(xiě)。但這并不表示final的類(lèi)的屬性值也是不可改變的。要想做到final類(lèi)的屬性值不可改變,必須給他增加final修飾符。finally語(yǔ)句只能用于try/catch語(yǔ)句中,并且附帶著一個(gè)語(yǔ)句塊,表示這段語(yǔ)句最終總是被執(zhí)行。復(fù)制代碼 代碼如下:public class Test public static void mai

9、n(String args) System.out.println(returnTest();/false public static boolean returnTest() try return true; finally return false; 先計(jì)算return后面的表達(dá)式的值,將值臨時(shí)存儲(chǔ)起來(lái),然后計(jì)算finally里的return后的表達(dá)式值,算出后也會(huì)臨時(shí)存儲(chǔ),此時(shí)就會(huì)把之前存儲(chǔ)的值給覆蓋掉。最后,回到前一個(gè)return處,從臨時(shí)存儲(chǔ)變量的地方把值拿出來(lái),返回。即得到了這樣的結(jié)果。 throw/throws有什么聯(lián)系和區(qū)別 仔細(xì)一看就知道了: public Test() th

10、rows RepletException try System.out.println("Test this Project!") catch (Exception e) throw new Exception(e.toString(); throws是用來(lái)聲明一個(gè)方法可能拋出的所有異常信息throw則是指拋出的一個(gè)具體的異常類(lèi)型。通常在一個(gè)方法(類(lèi))的聲明處通過(guò)throws聲明方法(類(lèi))可能拋出的異常信息,而在方法(類(lèi))內(nèi)部通過(guò)throw聲明一個(gè)具體的異常信息。throws通常不用顯示的捕獲異常,可由系統(tǒng)自動(dòng)將所有捕獲的異常信息拋給上級(jí)方法;throw則需要用戶(hù)自己捕獲相

11、關(guān)的異常,而后在對(duì)其進(jìn)行相關(guān)包裝,最后在將包裝后的異常信息拋出。3、編寫(xiě)一個(gè)描述老師基本情況的類(lèi),屬性包括姓名,教工號(hào),基本工資,崗位工資和績(jī)效工資,方法包括信息輸出,設(shè)置姓名和教工號(hào),設(shè)置三種工資金額,計(jì)算總工資(三種工資加起來(lái))和稅后工資(按如下方式計(jì)算,3000以?xún)?nèi)不收稅,3000-5000之間的部分扣10%,大于5000的部分扣15%)。在main方法中對(duì)方法進(jìn)行測(cè)試(15分)public class salary String name;int tnum;double bsalary;double gsalary;double jsalary;double allsalary;pub

12、lic String getName() return name;public void setName(String name) = name;public int getTnum() return tnum;public void setTnum(int tnum) this.tnum = tnum;public double getBsalary() return bsalary;public void setBsalary(double bsalary) this.bsalary = bsalary;public double getGsalary() return

13、 gsalary;public void setGsalary(double gsalary) this.gsalary = gsalary;public double getJsalary() return jsalary;public void setJsalary(double jsalary) this.jsalary = jsalary;public double getAllsalary() return allsalary;public void setAllsalary(double allsalary) this.allsalary = allsalary;public sa

14、lary(String _name, int _tnum, double _bsalary, double _gsalary, double _jsalary) = _name;this.tnum = _tnum;this.bsalary = _bsalary;this.gsalary = _gsalary;this.jsalary = _jsalary;System.out.println(this.toString();Overridepublic String toString() return "salary name=" + name + &q

15、uot;, tnum=" + tnum + ", bsalary=" + bsalary + ", gsalary=" + gsalary+ ", jsalary=" + jsalary + ""public double getall(salary _salary)allsalary=_salary.bsalary+_salary.gsalary+_salary.jsalary;if(allsalary<=3000)allsalary=allsalary;else if(allsalary>

16、3000 && allsalary <=5000)allsalary=(allsalary-3000)*0.9 +3000;else if(allsalary>5000)allsalary=(allsalary-5000)*0.85 +2000*0.9 +3000;return allsalary;public static void main(String args) salary s=new salary("楊松運(yùn)",098014,3500,1000,2000); System.out.println("稅后薪水:"+ s

17、.getall(s);4、Java中實(shí)現(xiàn)多線(xiàn)程有幾種方式?這幾種方式有什么區(qū)別?然后采取其中一種方式設(shè)計(jì)一個(gè)線(xiàn)程例子,在例子中構(gòu)造4個(gè)線(xiàn)程對(duì)象實(shí)現(xiàn)對(duì)同一數(shù)據(jù)類(lèi)對(duì)象進(jìn)行操作(數(shù)據(jù)初始值為10),其中線(xiàn)程對(duì)象1對(duì)數(shù)據(jù)執(zhí)行乘以10的操作,線(xiàn)程對(duì)象2對(duì)數(shù)據(jù)執(zhí)行乘以20的操作, 對(duì)象3對(duì)數(shù)據(jù)執(zhí)行+30的操作,線(xiàn)程對(duì)象4對(duì)數(shù)據(jù)執(zhí)行+40的操作,要求考慮線(xiàn)程同步,保證每一步數(shù)據(jù)操作的正確性。要求提供程序代碼以及運(yùn)行結(jié)果截圖(15分)有三種:(1)繼承Thread類(lèi),重寫(xiě)run函數(shù)創(chuàng)建:class xx extends Thread public void run()Thread.sleep(1000)/線(xiàn)程

18、休眠1000毫秒,sleep使線(xiàn)程進(jìn)入Block狀態(tài),并釋放資源開(kāi)啟線(xiàn)程:對(duì)象.start()/啟動(dòng)線(xiàn)程,run函數(shù)運(yùn)行(2)實(shí)現(xiàn)Runnable接口,重寫(xiě)run函數(shù)開(kāi)啟線(xiàn)程:Thread t = new Thread(對(duì)象)/創(chuàng)建線(xiàn)程對(duì)象t.start()(3)實(shí)現(xiàn)Callable接口,重寫(xiě)call函數(shù)Callable是類(lèi)似于Runnable的接口,實(shí)現(xiàn)Callable接口的類(lèi)和實(shí)現(xiàn)Runnable的類(lèi)都是可被其它線(xiàn)程執(zhí)行的任務(wù)。 Callable和Runnable有幾點(diǎn)不同:Callable規(guī)定的方法是call(),而Runnable規(guī)定的方法是run(). Callable的任務(wù)執(zhí)行后可

19、返回值,而Runnable的任務(wù)是不能返回值的call()方法可拋出異常,而run()方法是不能拋出異常的。 運(yùn)行Callable任務(wù)可拿到一個(gè)Future對(duì)象,F(xiàn)uture表示異步計(jì)算的結(jié)果。它提供了檢查計(jì)算是否完成的方法,以等待計(jì)算的完成,并檢索計(jì)算的結(jié)果.通過(guò)Future對(duì)象可了解任務(wù)執(zhí)行情況,可取消任務(wù)的執(zhí)行,還可獲取任務(wù)執(zhí)行的結(jié)果class Test1 implements Runnable Four four;public Test1(Four four) this.four = four;public void run() four.add();class Test2 imple

20、ments Runnable Four four;public Test2(Four four) this.four = four;public void run() four.add1();class Test3 implements Runnable Four four;public Test3(Four four) this.four = four;public void run() four.mul();class Test4 implements Runnable Four four;public Test4(Four four) this.four = four;public vo

21、id run() four.mul1();public class Four private int a = 10;synchronized void add() a = a + 30;System.out.println(Thread.currentThread().getName() + "inc-30->" + a);synchronized void add1() a = a + 40;System.out.println(Thread.currentThread().getName() + "inc-40->" + a);synch

22、ronized void mul() a = a * 10;System.out.println(Thread.currentThread().getName() + "mul-10->" + a);synchronized void mul1() a = a * 20;System.out.println(Thread.currentThread().getName() + "mul-20->" + a);public static void main(String args) Four four = new Four();Thread t

23、 = new Thread(new Test1(four);t.start();t = new Thread(new Test2(four);t.start();t = new Thread(new Test3(four);t.start();t = new Thread(new Test4(four);t.start();二、編程題1、編寫(xiě)一個(gè)圖形用戶(hù)界面程序,包含兩個(gè)按鈕,一個(gè)信息標(biāo)簽(label)和一個(gè)顯示面板,兩個(gè)按鈕分別為“擲色子”和“移動(dòng)”,在顯示面板中顯示一個(gè)小汽車(chē)(用小圓矩形以及線(xiàn)繪制),隨機(jī)設(shè)定小汽車(chē)的初始位置,當(dāng)點(diǎn)擊“擲色子”按鈕,隨機(jī)產(chǎn)生移動(dòng)信息(上移,下移,左移,右移,

24、移動(dòng)幾步),并顯示在信息標(biāo)簽中,點(diǎn)擊移動(dòng),按照產(chǎn)生的移動(dòng)信息,讓小汽車(chē)進(jìn)行移動(dòng)。要求提供完整程序代碼以及運(yùn)行結(jié)果截圖(20分)package testsc.testdc.entity;import java.awt.Color;import java.awt.Graphics;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;public class carmove extends JFrame private static final

25、 long serialVersionUID = 1L;carmove() TrafficPanel tp = new TrafficPanel();JButton btn1 = new JButton("移動(dòng)");JLabel lab1 = new JLabel();JLabel lab2 = new JLabel();btn1.setBounds(0, 100, 50, 20);lab1.setBounds(90, 100, 30, 20);lab2.setBounds(180, 200, 150, 20);tp.add(btn1);tp.add(lab1);tp.ad

26、d(lab2);lab2.setText("劉福戰(zhàn)");this.add(tp);/this.setResizable(false);this.setSize(500, 500);/ this.setLocationRelativeTo(null);/this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setVisible(true);Thread t = new Thread(tp);t.start();public static void main(String args) new carmove();cla

27、ss TrafficPanel extends JPanel implements Runnable int x = 125, y = 250, direct = 0;int speed = 1;int t1 = 0;int t2 = 0;public void paint(Graphics g) super.paint(g);drawCar(x, y, g, direct);public void drawCar(int x, int y, Graphics g, int direct) switch (direct) case 0:g.setColor(Color.black);g.fil

28、lRect(x - 20, y - 10, 40, 20);g.fillOval(x - 15, y + 10, 10, 10);g.fillOval(x + 5, y + 10, 10, 10);break;case 1:g.setColor(Color.black);g.fillRect(x - 10, y - 10, 20, 40);g.fillOval(x - 20, y - 5, 10, 10);g.fillOval(x - 20, y + 15, 10, 10);break;Overridepublic void run() while (true) try Thread.slee

29、p(50); catch (Exception e) x += t1;y += t2;if (x = 125 && y = 250 && direct = 0) t1 = speed;t2 = 0;direct = 0; else if (x = 250 && y = 250 && direct = 0) t1 = 0;t2 = speed;direct = 1; else if (x = 250 && y = 440 && direct = 1) t1 = 0;t2 = -speed;direct

30、 = 1; else if (x = 250 && y = 250 && direct = 1) t1 = -speed;t2 = 0;direct = 0;repaint();2、編寫(xiě)一個(gè)班級(jí)推優(yōu)(三好生)投票管理程序。列出參與推優(yōu)的學(xué)生名單(8名),可以勾選進(jìn)行投票,要求每個(gè)參選學(xué)生前面有圖標(biāo)表示候選人的性別,每人可以投4名候選人,每次投票后能夠顯示當(dāng)前投票人數(shù)以及每名候選者得票數(shù),圖形化柱狀圖顯示得票數(shù),可以保存投票結(jié)果到文本文件。要求提供完整程序代碼以及運(yùn)行結(jié)果截圖(20分)import java.awt.*;import java.awt.Event.

31、*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.ItemEvent;import java.awt.event.ItemListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.io.BufferedWriter;import java.io.FileWriter;import java.io.IOException;import

32、java.util.StringTokenizer;import javax.swing.*;public class VoteTest extends JFrame implements ActionListener, ItemListener static VoteTest frm = new VoteTest();static Save sa = new Save();static JLabel lab1 = new JLabel("總?cè)藬?shù):");static JLabel lab2 = new JLabel("最高票數(shù)選手:");static J

33、Label lab3 = new JLabel("最高票數(shù):");static JDialog dg = new JDialog();static JLabel lab4 = new JLabel();static JLabel lab5 = new JLabel();static JLabel lab6 = new JLabel();static JLabel lab7 = new JLabel();static JLabel lab8 = new JLabel();static JLabel lab9 = new JLabel();static JLabel lab10

34、 = new JLabel();static JLabel lab11 = new JLabel();static JLabel lab12 = new JLabel();static JLabel lab13 = new JLabel();static JButton btn1 = new JButton("提交");static JButton btn2 = new JButton("下一位投票");static JButton btn3 = new JButton("保存");static JButton btn4 = new

35、JButton("取消");static TextField tf1 = new TextField("", 5);static TextField tf2 = new TextField("", 15);static TextField tf3 = new TextField("", 5);static JCheckBox jb1 = new JCheckBox("陳明茂");static JCheckBox jb2 = new JCheckBox("張三");static

36、 JCheckBox jb3 = new JCheckBox("李四");static JCheckBox jb4 = new JCheckBox("王五");static JCheckBox jb5 = new JCheckBox("張三豐");static JCheckBox jb6 = new JCheckBox("喬峰");static JCheckBox jb7 = new JCheckBox("蕭十一郎");static JCheckBox jb8 = new JCheckBox(&

37、quot;王老吉");static JCheckBox jb9 = new JCheckBox("費(fèi)德南");static JCheckBox jb10 = new JCheckBox("林無(wú)敵");static JPanel pan1 = new JPanel();static JPanel pan2 = new JPanel();static JPanel pan3 = new JPanel();static JPanel pan4 = new JPanel();static int count = 0;static int count1

38、= 0;static int x1 = 100, x2 = 100, x3 = 100, x4 = 100, x5 = 100, x6 = 100,x7 = 100, x8 = 100, x9 = 100, x10 = 100;static int y = 250;static int z = 250;/* * param args */public static void main(String args) / TODO 自動(dòng)生成方法存根BorderLayout br = new BorderLayout();frm.setLayout(br);frm.addWindowListener(s

39、a);frm.setTitle("投票計(jì)數(shù)器");frm.add(pan1, br.NORTH);pan1.setBounds(0, 0, 500, 10);pan1.add(lab1);pan1.add(tf1);pan1.add(lab2);pan1.add(tf2);pan1.add(lab3);pan1.add(tf3);frm.add(pan2, br.WEST);GridLayout gl = new GridLayout(10, 1, 0, 3);pan2.setLayout(gl);pan2.add(jb1);pan2.add(jb2);pan2.add(j

40、b3);pan2.add(jb4);pan2.add(jb5);pan2.add(jb6);pan2.add(jb7);pan2.add(jb8);pan2.add(jb9);pan2.add(jb10);frm.add(pan3, br.SOUTH);pan3.setBounds(150, 450, 10, 10);pan3.add(btn1);pan3.add(btn2);pan3.add(btn3);pan3.add(btn4);frm.add(pan4, br.EAST);GridLayout gl1 = new GridLayout(10, 1, 0, 3);pan4.setLayo

41、ut(gl1);pan4.add(lab4);lab4.setForeground(new Color(0, 0, 255);pan4.add(lab5);lab5.setForeground(new Color(0, 0, 255);pan4.add(lab6);lab6.setForeground(new Color(0, 0, 255);pan4.add(lab7);lab7.setForeground(new Color(0, 0, 255);pan4.add(lab8);lab8.setForeground(new Color(0, 0, 255);pan4.add(lab9);la

42、b9.setForeground(new Color(0, 0, 255);pan4.add(lab10);lab10.setForeground(new Color(0, 0, 255);pan4.add(lab11);lab11.setForeground(new Color(0, 0, 255);pan4.add(lab12);lab12.setForeground(new Color(0, 0, 255);pan4.add(lab13);lab13.setForeground(new Color(0, 0, 255);frm.setSize(500, 400);frm.setLocat

43、ion(400, 300);/ frm.setDefaultCloseOperation(EXIT_ON_CLOSE);frm.setVisible(true);frm.setResizable(false);tf1.setEditable(false);tf2.setEditable(false);tf3.setEditable(false);btn1.addActionListener(frm);btn2.addActionListener(frm);btn3.addActionListener(frm);btn4.addActionListener(frm);jb1.addItemLis

44、tener(frm);jb2.addItemListener(frm);jb3.addItemListener(frm);jb4.addItemListener(frm);jb5.addItemListener(frm);jb6.addItemListener(frm);jb7.addItemListener(frm);jb8.addItemListener(frm);jb9.addItemListener(frm);jb10.addItemListener(frm);btn1.setEnabled(false);static class Save extends WindowAdapter

45、public void windowClosing(WindowEvent e) dg.setTitle("保存文件?");dg.setSize(200, 100);dg.add(btn3);dg.add(btn4);dg.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 30);dg.setLocation(400, 300);dg.setVisible(true);public void itemStateChanged(ItemEvent e) if (count1 > 0) / 每個(gè)人至少投兩個(gè)人btn1.setEn

46、abled(true); else btn1.setEnabled(false);if (count1 < 5) / 此投票計(jì)數(shù)器一個(gè)人只能投四票if (jb1.isSelected() count1+;jb1.setEnabled(true);if (jb2.isSelected() count1+;jb2.setEnabled(true);if (jb3.isSelected() count1+;jb3.setEnabled(true);if (jb4.isSelected() count1+;jb4.setEnabled(true);if (jb5.isSelected() cou

47、nt1+;jb5.setEnabled(true);if (jb6.isSelected() count1+;jb6.setEnabled(true);if (jb7.isSelected() count1+;jb7.setEnabled(true);if (jb8.isSelected() count1+;jb8.setEnabled(true);if (jb9.isSelected() count1+;jb9.setEnabled(true);if (jb10.isSelected() count1+;jb10.setEnabled(true); else count1 = 0;if (j

48、b1.isSelected() jb1.setEnabled(true); else jb1.setEnabled(false);if (jb2.isSelected() jb2.setEnabled(true); else jb2.setEnabled(false);if (jb3.isSelected() jb3.setEnabled(true); else jb3.setEnabled(false);if (jb4.isSelected() jb4.setEnabled(true); else jb4.setEnabled(false);if (jb5.isSelected() jb5.

49、setEnabled(true); else jb5.setEnabled(false);if (jb6.isSelected() jb6.setEnabled(true); else jb6.setEnabled(false);if (jb7.isSelected() jb7.setEnabled(true); else jb7.setEnabled(false);if (jb8.isSelected() jb8.setEnabled(true); else jb8.setEnabled(false);if (jb9.isSelected() jb9.setEnabled(true); el

50、se jb9.setEnabled(false);if (jb10.isSelected() jb10.setEnabled(true); else jb10.setEnabled(false);public void actionPerformed(ActionEvent e) JButton btn = (JButton) e.getSource();if (btn = btn1) btn1.setEnabled(false);count+;tf1.setText("" + count);Graphics g = getGraphics();g.setColor(Color.RED);if (jb1.isSelected() g.fillRect(x1, 70, 1, 15);x1+;if (jb2.isSelected() g.fillRect(x2, 98, 1, 15);x2+;if (jb3.isSelected() g.fillRect(x3, 126, 1, 15);x3+;if (jb4.isSelected() g.fillRect(x4, 158, 1, 15);x4+;if (jb5.isSelected() g.fillRect(x5, 188, 1, 15);x5+;if (jb6.isSelected() g.

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論