java实验报告,没时间写了 ,一百分

选课程 浏览

package cn.rain.form;

import java.awt.BorderLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JPanel;

import javax.swing.JTextField;

public class Moble extends JFrame {

private static final long serialVersionUID = 1L;

private JTextField txtView;

/**

* Launch the application

* @param args

*/

public static void main(String args[]) {

try {

Moble moble = new Moble();

moble.setVisible(true);

} catch (Exception e) {

e.printStackTrace();

}

}

/**

* Create the frame

*/

public Moble() {

setTitle(Moble);

setBounds(100, 100, 200, 300);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

final JPanel panel = new JPanel();

getContentPane().add(panel, BorderLayout.CENTER);

txtView = new JTextField();

panel.setLayout(null);

panel.add(txtView);

final JButton btn1 = new JButton();

btn1.addActionListener(new ActionListener() {

//加监听

public void actionPerformed(ActionEvent arg0) {

txtView.setText(txtView.getText().concat(1));

}

});

btn1.setText(1);

btn1.setBounds(0, 73, 59, 23);

panel.add(btn1);

final JButton btn2 = new JButton();

btn2.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

//文本显示

txtView.setText(txtView.getText().concat(2));

}

});

btn2.setText(2);

btn2.setBounds(68, 73, 59, 23);

panel.add(btn2);

final JButton btn3 = new JButton();

btn3.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

txtView.setText(txtView.getText().concat(3));

}

});

btn3.setText(3);

btn3.setBounds(133, 73, 59, 23);

panel.add(btn3);

final JButton btn4 = new JButton();

btn4.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

txtView.setText(txtView.getText().concat(4));

}

});

btn4.setText(4);

btn4.setBounds(0, 102, 59, 23);

panel.add(btn4);

final JButton btn5 = new JButton();

btn5.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

txtView.setText(txtView.getText().concat(5));

}

});

btn5.setText(5);

btn5.setBounds(65, 102, 59, 23);

panel.add(btn5);

final JButton btn6 = new JButton();

btn6.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

txtView.setText(txtView.getText().concat(6));

}

});

btn6.setText(6);

btn6.setBounds(133, 102, 59, 23);

panel.add(btn6);

final JButton btn7 = new JButton();

btn7.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

txtView.setText(txtView.getText().concat(7));

}

});

btn7.setText(7);

btn7.setBounds(0, 131, 59, 23);

panel.add(btn7);

final JButton btn8 = new JButton();

btn8.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

txtView.setText(txtView.getText().concat(8));

}

});

btn8.setText(8);

btn8.setBounds(65, 131, 59, 23);

panel.add(btn8);

final JButton btn9 = new JButton();

btn9.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

txtView.setText(txtView.getText().concat(9));

}

});

btn9.setText(9);

btn9.setBounds(133, 131, 59, 23);

panel.add(btn9);

final JButton btn0 = new JButton();

btn0.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

txtView.setText(txtView.getText().concat(0));

}

});

btn0.setText(0);

btn0.setBounds(68, 160, 57, 23);

panel.add(btn0);

txtView = new JTextField();

txtView.setBounds(59, 24, 90, 21);

panel.add(txtView);

final JButton btnSend = new JButton();

btnSend.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

//如果拨过号了,就不能再拨

if(txtView.getText().indexOf(calling...)==-1){

txtView.setText(txtView.getText().concat(calling...));

}

else{

return;

}

}

});

btnSend.setText(Send);

btnSend.setBounds(40, 189, 127, 23);

panel.add(btnSend);

final JButton btnclear = new JButton();

btnclear.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

txtView.setText();

}

});

btnclear.setText(Clear);

btnclear.setBounds(40, 212, 127, 23);

panel.add(btnclear);

final JButton btnOff = new JButton();

btnOff.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

dispose();

}

});

btnOff.setText(Off);

btnOff.setBounds(40, 232, 127, 23);

panel.add(btnOff);

}

}

//这个程序不难的,好像没什么注释可写,你自己看看应该看得懂,如果哪

//里不明白,再问我吧,程序没有问题,我运行过了~

转载请注明:多米培训网 » java实验报告,没时间写了 ,一百分