总结:最难的就是当我们需要点击按钮时去实现某个功能-----------因为那个我没有理解透,是涉及整个程序的

package com.a.b;

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

class SB extends JFrame implements ActionListener {
	JButton jb;

	public SB() {
		jb = new JButton("你你你");
		jb.addActionListener(this);// 注册监听
		this.setVisible(true);
		this.add(jb);
		this.setBounds(333, 333, 500, 500);
		this.setDefaultCloseOperation(3);

	}

	public void actionPerformed(ActionEvent a) {

		if (a.getSource() == jb) {
			System.out.println("你好");
		}
	}

}

public class Shi {
	public static void main(String[] args) {
		new SB();
	}

}

  

相关文章:

  • 2022-12-23
  • 2021-11-20
  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2021-08-24
猜你喜欢
  • 2022-12-23
  • 2021-08-22
  • 2022-12-23
  • 2021-12-11
  • 2022-12-23
  • 2021-11-29
  • 2021-05-25
相关资源
相似解决方案