JAVA程序的流程图

来源:百度知道 编辑:UC知道 时间:2024/05/31 13:26:49
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Drawing extends JFrame implements ActionListener{
JTextField tf = new JTextField();
JButton b1 = new JButton("开始");
JButton b2 = new JButton("停止");
boolean isGo = false;
public Drawing (){
b1.setActionCommand("start");
JPanel p = new JPanel();
p.add(b1);
p.add(b2);

b1.addActionListener(this);
b2.addActionListener(this);
b2.setEnabled(false);

this.getContentPane().add(tf,"North");
this.getContentPane().add(p,"South");
this.setDefaultCloseOperation(JFrame.EXIT.ON.CLOSE);
this.setSize(300,200);
this.setLocation(300,300);
Cursor cu = new Cursor(Cursor.HAND.CURSOR);
this.setCursor(cu);
this.setVisible(true);
tf.setText("welcome to this program! ");
th

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Drawing extends JFrame implements ActionListener {
private static final long serialVersionUID = 1L;
// 实例化一个文本域
JTextField tf = new JTextField();
// 设置两个按钮
JButton b1 = new JButton("开始");
JButton b2 = new JButton("停止");
boolean isGo = false;

public Drawing() {
b1.setActionCommand("start");// 在开始按钮上设置一个动作监听 start
JPanel p = new JPanel();// 创建一个面板容器,用于放置组件
// 将两个按钮添加到可视化容器上面,用add方法
p.add(b1);
p.add(b2);
// 在两个按钮上增加监听的属性,自动调用下面的监听处理方法actionPerformed(ActionEvent
// e),如果要代码有更好的可读性,可用内部类实现动作
// 监听处理。
b1.addActionListener(this);
b2.addActionListener(this);
// 将停止按钮设置为不可编辑(即不可按的状态)
b2.setEnabled(false);
// 将上面的文本域放在面板的北方,也就是上面(上北下南左西右东)
this.getContentPane().add(tf, "North");
// 将可视化容器pannel放在南边,