Java Final Exam 9

Source: Internet
Author: User

/**9

* Use text boxes, tags, buttons, etc. to complete an interface

* The option to enter is "People's currency", "USD"

* Convert to another coin currency conversion interface

**/

Import java.awt.*;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 javax.swing.*;p ublic  Class test{public static void main (String[] args) {jframe exit = new  jframe ("Currency conversion rate calculation"); Exit.setlayout (null); Exit.setsize (300, 200); exit.setlocation (0, 0); Exit.setvisible (TRUE); Jlabel lab1 = new jlabel ("Enter the Gold:");//Label lab1.setbounds (0,0,60,30); Exit.add (LAB1);final  Jtextfield text1 = new jtextfield ();  //"Currency" text box text1.seteditable (true); Text1.setbounds (60,0,120,30); Exit.add (Text1); Final jtextfield text4 = new jtextfield ( ); Text4.seteditable (true); Text4.setbounds (130,120,120,30); Exit.add (TEXT4); Jlabel lab2 = new jlabel ("Choice of Currency:");//Label lab2.setbounds (0,30,60,20); Exit.add (LAB2); Final jradiobutton jrb1 = new jradiobutton ("People's currency");final  Jradiobutton jrb2 = new jradiobutton ("USD"); Jrb1.additemlistener (New ItemListener ()  {@Overridepublic  void itemstatechanged (itemevent e)  {// TODO  auto-generated method stubif  (E.getsource ()  == jrb1) {jrb2.setselected (false);d ouble  c = double.parsedouble (Text1.gettext ()); C *= 0.1618;text4.settext (String.valueOf (c)) ;}}}); Jrb1.setbounds (0,55,80,30); Exit.add (JRB1); Jrb2.additemlistener (New itemlistener ()  {@Overridepublic  void itemstatechanged (itemevent e)  {// TODO Auto-generated method  stubif  (E.getsource ()  == jrb2) {jrb1.setselected (false);d ouble c =  Double.parsedouble (Text1.gettext ()); C *= 6.228;text4.settext (String.valueof (c));}}); Jrb2.setbounds (85,55,80,30); Exit.add (JRB2); Exit.addwindowliStener (New windowadapter () {//Exit Event Listener public void windowclosing (windowevent arg0) {System.exit (1);}});}}


This article is from the "hacker" blog, make sure to keep this source http://anglecode.blog.51cto.com/5628271/1619893

Java Final Exam 9

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.