⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 handlejbutton.java

📁 初学的好东西值得一看看欢迎下载观看使用
💻 JAVA
字号:
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.FlowLayout;
import javax.swing.ImageIcon;
import java.awt.event.ActionListener;
import java.awt.event.MouseListener;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
class HandleJButton extends JFrame implements ActionListener,MouseListener,MouseMotionListener{
	JButton jbutton1=new JButton("上一笔");
	ImageIcon imageIcon1=new ImageIcon("d:\\java_project\\image\\next.gif");
	JButton jbutton2=new JButton("下一笔",imageIcon1);
	ImageIcon imageIcon2=new ImageIcon("d:\\java_project\\image\\exit.gif");
	JButton jbutton3=new JButton(imageIcon2);
	FlowLayout flowLayout1=new FlowLayout();
	HandleJButton(){
		setTitle("按钮演示窗口");
		setSize(200,150);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.getContentPane().setLayout(flowLayout1);
		jbutton1.addActionListener(this);
		jbutton2.addActionListener(this);
		jbutton3.addActionListener(this);
		jbutton1.addMouseListener(this);
		jbutton2.addMouseListener(this);
		jbutton3.addMouseListener(this);
		jbutton1.addMouseMotionListener(this);
		jbutton2.addMouseMotionListener(this);
		jbutton3.addMouseMotionListener(this);
		this.getContentPane().add(jbutton1);
		this.getContentPane().add(jbutton2);
    		this.getContentPane().add(jbutton3);
		show();
	}
	
	public void actionPerformed(ActionEvent e){
		Object source=e.getSource();
		if(source==jbutton1){
			System.out.println("jbutton1按钮被单击");
		}
		else if(source==jbutton2){
			jbutton1.setEnabled(false);
		}
		else if(source==jbutton3){
			jbutton1.setEnabled(true);
		}
	}
	public void mouseClicked(MouseEvent e){
		System.out.println("mouseClicked事件发生了.");
	}
	public void mouseEntered(MouseEvent e){
		System.out.println("mouseEntered事件发生了.");
	}
	public void mouseExited(MouseEvent e){
		System.out.println("mouseExited事件发生了.");
	}
	public void mousePressed(MouseEvent e){
		System.out.println("mousePressed事件发生了.");
	}
	public void mouseReleased(MouseEvent e){
		System.out.println("mouseReleased事件发生了.");
	}
	public void mouseDragged(MouseEvent e){
		System.out.println("mouseDragged事件发生了.");
	}
	public void mouseMoved(MouseEvent e){
		System.out.println("mouseMoved事件发生了.");
	}
	
	public static void main(String[] args){
		HandleJButton sjb=new HandleJButton();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -