The method of construction--modern software engineering

Source: Internet
Author: User


Import java.awt.*;
Import Java.awt.event.ActionListener;

Import javax.swing.*;

public class F {
JFrame frame = new JFrame ("Computer");

JPanel PL = new JPanel ();

JPanel P2 = new JPanel ();

static JTextField show = new JTextField ();

static JButton B0 = new JButton ("0");

Static JButton B1 = new JButton ("1");

static JButton B2 = new JButton ("2");

Static JButton B3 = new JButton ("3");

static JButton b4 = new JButton ("4");

static JButton B5 = new JButton ("5");

Static JButton B6 = new JButton ("6");

static JButton B7 = new JButton ("7");

static JButton B8 = new JButton ("8");

static JButton B9 = new JButton ("9");

JButton Bjia = new JButton ("+");

JButton Bjian = new JButton ("-");

JButton Bcheng = new JButton ("*");

JButton Bchu = new JButton ("/");

JButton Bdian = new JButton (".");

JButton Bdeng = new JButton ("=");

JButton Bqingchu = new JButton ("clear");

public void Y () {
Pl.setlayout (New GridLayout (1, 1));
Pl.add (show);
}

public void P () {
B1.addactionlistener (New U ());
B2.addactionlistener (New U ());
B3.addactionlistener (New U ());
B4.addactionlistener (New U ());
B5.addactionlistener (New U ());
B6.addactionlistener (New U ());
B7.addactionlistener (New U ());
B8.addactionlistener (New U ());
B9.addactionlistener (New U ());
B0.addactionlistener (New U ());

Bjia.addactionlistener (New Fu ());
Bjian.addactionlistener (New Fu ());
Bcheng.addactionlistener (New Fu ());
Bchu.addactionlistener (New Fu ());

Bdeng.addactionlistener (New Deng ());
Bqingchu.addactionlistener (New Qing ());

P2.setlayout (New GridLayout (6, 3));
P2.add (B1);
P2.add (B2);
P2.add (B3);
P2.add (B4);
P2.add (B5);
P2.add (B6);
P2.add (B7);
P2.add (B8);
P2.add (B9);
P2.add (B0);
P2.add (Bjia);
P2.add (Bjian);
P2.add (Bcheng);
P2.add (Bchu);
P2.add (Bdian);
P2.add (Bqingchu);
P2.add (Bdeng);
}

public void O () {
Frame.setlayout (New BorderLayout ());
Frame.add (PL, Borderlayout.north);
Frame.add (P2, borderlayout.center);
Frame.setsize (400, 300);
Frame.setvisible (TRUE);

}

public static void Main (string[] args) {
F f = new F ();
F.y ();
F.P ();
F.O ();

}

}
////

Import java.awt.event.ActionEvent;
Import Java.awt.event.ActionListener;

public class ya implements ActionListener {
public static String str = "";

public static String a = "";

public static String B = "";

public static String k = "";

public void actionperformed (ActionEvent e) {
String w = E.getactioncommand ();//Word

if (K.equals ("")) {
A + = W;
F.show.settext (a);

} else {
B + = W;
F.show.settext (b);
}

}

}
////
Import java.awt.event.ActionEvent;
Import Java.awt.event.ActionListener;

public class Deng implements ActionListener {

public void actionperformed (ActionEvent e) {
int a = Integer.parseint (U.A);
int b = Integer.parseint (U.B);
int c = 0;
if (u.k.equals ("+")) {
c = a + B;

} else

if (U.k.equals ("-")) {
c = A-B;

} else

if (U.k.equals ("*")) {
c = A * b;

} else

if (U.k.equals ("/")) {
c = A/b;

} else {

}

String d = string.valueof (c);
F.show.settext (d);
U.A = D;
u.b = "";
U.K = "";
}
}
///

Import java.awt.event.ActionEvent;
Import Java.awt.event.ActionListener;

public class Qing implements ActionListener {

public void actionperformed (ActionEvent e) {
U.A = "";
u.b = "";
U.K = "";
F.show.settext ("");

}

}
///

Import java.awt.event.ActionEvent;
Import Java.awt.event.ActionListener;

public class Qing implements ActionListener {

public void actionperformed (ActionEvent e) {
U.A = "";
u.b = "";
U.K = "";
F.show.settext ("");

}

}
///
2
Programming is too difficult to handle. Write out a little, but not run.

The method of construction--modern software engineering

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.