Windows computer features Java source code

Source: Internet
Author: User

The code is as follows

Import Java.awt.color;import java.awt.container;import java.awt.gridlayout;import java.awt.event.ActionEvent; Import Java.awt.event.actionlistener;import Javax.swing.jbutton;import Javax.swing.jframe;import Javax.swing.jlabel;import javax.swing.jpanel;import Javax.swing.jtextfield;class MyWindows extends JFrame implements        actionlistener{private static final long serialversionuid = 1L;         Boolean tag=true;    Boolean signal=true;    JTextField Text1;        Public mywindows (int w,int h) {settitle ("calculator program");        This.setbounds (100,100,350,300);        Container con = Getcontentpane ();        Con.setlayout (New GridLayout (3,1));        JPanel P1 = new JPanel ();        P1.setlayout (New GridLayout (2,1));        Text1 = new JTextField (150); Text1.sethorizontalalignment (Text1.        right);        Text1.settext ("0.");        JPanel p1_1 = new JPanel ();        P1_1.setlayout (New GridLayout (1,4));        JButton btn_backspace = new JButton ("BackSpace"); Btn_backsPace.setforeground (color.red);        Btn_backspace.addactionlistener (this);        JButton btn_ce = new JButton ("CE");        Btn_ce.setforeground (color.red);        JButton Btn_c = new JButton ("C");        Btn_c.setforeground (color.red);        Btn_c.addactionlistener (this);        P1.add (Text1);        P1_1.add (New JLabel ());        P1_1.add (Btn_backspace);        P1_1.add (BTN_CE);        P1_1.add (Btn_c);               P1.add (p1_1);        JPanel P2 = new JPanel ();        P2.setlayout (New GridLayout (2,1));        JPanel p2_1 = new JPanel ();        P2_1.setlayout (New GridLayout (1,6));        JButton BTN_MC = new JButton ("MC");        Btn_mc.setforeground (color.red);        JButton btn_7 = new JButton ("7");        Btn_7.setforeground (Color.Blue);        Btn_7.addactionlistener (this);        JButton btn_8 = new JButton ("8");        Btn_8.setforeground (Color.Blue);        Btn_8.addactionlistener (this);        JButton btn_9 = new JButton ("9");     Btn_9.setforeground (Color.Blue);   Btn_9.addactionlistener (this);        JButton btn_wind= New JButton ("/");        Btn_wind.setforeground (color.red);        JButton btn_sqrt = new JButton ("sqrt");        Btn_sqrt.setforeground (Color.Blue); P2_1.add (BTN_MC);        P2_1.add (btn_7); P2_1.add (Btn_8);        P2_1.add (Btn_9);        P2_1.add (Btn_wind);p 2_1.add (BTN_SQRT);        JPanel p2_2 = new JPanel ();        P2_2.setlayout (New GridLayout (1,6));        JButton btn_mr = new JButton ("MR");        Btn_mr.setforeground (color.red);        JButton btn_4 = new JButton ("4");        Btn_4.setforeground (Color.Blue);        Btn_4.addactionlistener (this);        JButton btn_5 = new JButton ("5");        Btn_5.setforeground (Color.Blue);        Btn_5.addactionlistener (this);        JButton btn_6 = new JButton ("6");        Btn_6.setforeground (Color.Blue);        Btn_6.addactionlistener (this);        JButton btn_star= New JButton ("*");        Btn_star.setforeground (color.red);        JButton btn_mod = new JButton ("%"); Btn_mod.Setforeground (Color.Blue);        P2_2.add (BTN_MR); P2_2.add (Btn_4);        P2_2.add (btn_5);         P2_2.add (Btn_6);        P2_2.add (Btn_star);p 2_2.add (btn_mod);                P2.add (p2_1);p 2.add (p2_2);        JPanel p3 = new JPanel ();        P3.setlayout (New GridLayout (2,1));        JPanel p3_1 = new JPanel ();        P3_1.setlayout (New GridLayout (1,6));        JButton Btn_ms = new JButton ("MS");        Btn_ms.setforeground (color.red);        JButton btn_1 = new JButton ("1");        Btn_1.setforeground (Color.Blue);        Btn_1.addactionlistener (this);        JButton btn_2 = new JButton ("2");        Btn_2.setforeground (Color.Blue);        Btn_2.addactionlistener (this);        JButton btn_3 = new JButton ("3");        Btn_3.setforeground (Color.Blue);        Btn_3.addactionlistener (this);        JButton btn_sub= New JButton ("-");        Btn_sub.setforeground (color.red);        JButton btn_reverse = new JButton ("1/x");        Btn_reverse.setforeground (Color.Blue); P3_1.add (Btn_ms);        P3_1.add (btn_1); P3_1.add (btn_2);        P3_1.add (Btn_3);        P3_1.add (btn_sub);p 3_1.add (btn_reverse);        JPanel p3_2 = new JPanel ();        P3_2.setlayout (New GridLayout (1,6));        JButton Btn_madd = new JButton ("m+");        Btn_madd.setforeground (color.red);        JButton btn_0= New JButton ("0");        Btn_0.setforeground (Color.Blue);        Btn_0.addactionlistener (this);        JButton Btn_singal = new JButton ("+/-");        Btn_singal.setforeground (Color.Blue);        Btn_singal.addactionlistener (this);        JButton Btn_dot = new JButton (".");        Btn_dot.addactionlistener (this);        JButton btn_add= New JButton ("+");        Btn_add.setforeground (color.red);        JButton btn_equal = new JButton ("=");        Btn_equal.setforeground (color.red);        P3_2.add (Btn_madd); P3_2.add (BTN_0);        P3_2.add (Btn_singal);        P3_2.add (Btn_dot);        P3_2.add (Btn_add);p 3_2.add (btn_equal);        P3.add (p3_1);p 3.add (p3_2); Con.add (p1); Con.add (p2); Con.add (P3);    SetVisible (TRUE);    } public void Press_dot () {tag=false; }

Run results
<ignore_js_op>

Detailed Description: http://java.662p.com/thread-2140-1-2.html

Windows computer features Java source code

Related Article

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.