这个 真的没啥意思 给按钮添加一个监听 监听调用 button的另一个调用图片的构造方法 很方便\
package com.test;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class ButtonDemo {
URL url = this.getClass().getResource("poto.jpg");
public ButtonDemo() {
}
public void showMe() {
JFrame frame = new JFrame();
JPanel panel = new JPanel();
final JButton button;
button = new JButton("点击我!");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
button.setIcon(new ImageIcon(url));
}
});
frame.add(panel);
panel.add(button);
frame.setSize(600, 500);
frame.setVisible(true);
}
public static void main(String[] args) {
new ButtonDemo().showMe();
}
}
这是基本的 你看看吧
这个 真的没啥意思 给按钮添加一个监听 监听调用 button的另一个调用图片的构造方法 很方便\
package com.test;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class ButtonDemo {
URL url = this.getClass().getResource("poto.jpg");
public ButtonDemo() {
}
public void showMe() {
JFrame frame = new JFrame();
JPanel panel = new JPanel();
final JButton button;
button = new JButton("点击我!");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
button.setIcon(new ImageIcon(url));
}
});
frame.add(panel);
panel.add(button);
frame.setSize(600, 500);
frame.setVisible(true);
}
public static void main(String[] args) {
new ButtonDemo().showMe();
}
}
这是基本的 你看看吧
介绍你一个插件·~swt
傻瓜式的·~
用jquery或js不是很方便吗?干吗非要用java呢?