/**8
* Use text boxes, tags, buttons, etc. to complete an interface
* Enter a level of grades, an experiment, a final.
* Auto-present a CI synthesis by a certain percentage
**/
Import java.awt.*;import java.awt.event.actionevent;import java.awt.event.actionlistener;import java.awt.event.windowadapter;import java.awt.event.windowevent;import javax.swing.*;p ublic class test{public static void main (String[] args) {JFrame exit = New jframe ("Big-time Java class"); Exit.setlayout (null); Exit.setsize (300, 200); Exit.setlocation (0, 0) ; Exit.setvisible (true); Jlabel lab1 = new jlabel ("Flat-time:");//Label lab1.setbounds (0,0,60,30); Exit.add (LAB1);final Jtextfield text1 = new jtextfield (); //"level" text box text1.seteditable (true); Text1.setbounds (60,0,60,30); Exit.add (Text1); Jlabel lab11 = new jlabel ("Occupied proportion is 30%"); Lab11.setbounds (130,0,100,30); Exit.add (LAB11); Jlabel lab2 = new jlabel ("experiment:");//Label lab2.setbounds (0,40,60,30); Exit.add (LAB2); final jtextfield text2 = new jtextfield (); //"Experiment" text box TeXt2.seteditable (True); Text2.setbounds (60,40,60,30); Exit.add (TEXT2); Jlabel lab22 = new jlabel ("Occupied proportion is 20%"); Lab22.setbounds (130,40,100,30); Exit.add (LAB22); Jlabel lab3 = new jlabel ("Final grades:");//Label lab3.setbounds (0,80,60,30); Exit.add (LAB3); final jtextfield text3 = new jtextfield (); //"Final Grades" text box Text3.seteditable (true); Text3.setbounds (60,80,60,30); Exit.add (TEXT3); Jlabel lab33 = new jlabel ("Occupied proportion is 50%"); Lab33.setbounds (130,80,100,30); Exit.add (lab33); final jtextfield text4 = new jtextfield (); text4.seteditable (true); Text4.setBounds ( 150,120,60,30); Exit.add (TEXT4); Final jbutton but1 = new jbutton ("Total:");// Label But1.setbounds (60, 120, 80, 30); Exit.add (BUT1); But1.addactionlistener (New actionlistener () {@Overridepublic void actionperformed (actionevent e) {// todo auto-generated method stubif (E.getsource () &nBSP;== BUT1) {double a = double.parsedouble (Text1.gettext ());d ouble b = Double.parsedouble (Text2.gettext ());d ouble c = double.parsedouble (Text3.gettext ());d ouble D = a*0.2 + b*0.3 + c*0.5;text4.settext (string.valueof (d));}}); Exit.addwindowlistener (New windowadapter () {//Exit Event listener public void windowclosing (WindowEvent arg0) {system.exit (1);}});}}
Java Final Exam 8