import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.*;public class ButtonSound extends JFrame {
public ButtonSound() {
super();
setSize(300, 300);
Container c = this.getContentPane();
c.setLayout(new BorderLayout());
JButton b = new JButton("cc");
ActionListener action = new ActionListener() {
public void actionPerformed(ActionEvent e) {
Toolkit.getDefaultToolkit().beep();
}
};
b.addActionListener(action);
c.add(b, BorderLayout.CENTER);
setVisible(true); } public static void main(String args[]) {
new ButtonSound ();
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货