标签:ESS java 鼠标 void close operation text 文字 resource
package cn.rushangw.lesson05;
import javax.swing.*;
import java.awt.*;
import java.net.URL;
public class JButtonDemo01 extends JFrame {
public JButtonDemo01(){
Container container = getContentPane();
//将一个图片变成图标
URL url = JButtonDemo01.class.getResource("lADPD3W5ONBVGtTNBDjNB4A_1920_1080.jpg");
Icon icon = new ImageIcon(url);
//把这个图标放在按钮上
JButton button = new JButton();
button.setIcon(icon);
//鼠标悬停出现的文字
button.setToolTipText("图片按钮");
container.add(button);
setVisible(true);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setBounds(1,1,500,500);
}
public static void main(String[] args) {
new JButtonDemo01();
}
}
标签:ESS java 鼠标 void close operation text 文字 resource
原文地址:https://www.cnblogs.com/nigustudent/p/14814655.html