求助!!java中如何弹出提示信息框?????
各位高手们请教如何在java中如何让窗口中弹出信息提示框?
----------------解决方案--------------------------------------------------------
MessageBox.show("要显示的字符串","标题",消息框按钮,消息框图标)
这样就可以啦!
----------------解决方案--------------------------------------------------------
package bc;
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
public class Frametest extends JFrame {
public Frametest() {
try {
this.setSize(400,300);
this.setDefaultCloseOperation(this.DISPOSE_ON_CLOSE);
this.setVisible(true);
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
getContentPane().setLayout(null);
jButton1.setBounds(new Rectangle(134, 126, 135, 55));
jButton1.setText("jButton1");
jButton1.addActionListener(new Frametest_jButton1_actionAdapter(this));
this.getContentPane().add(jButton1);
}
public static void main(String[] args) {
Frametest frametest = new Frametest();
}
JButton jButton1 = new JButton();
public void jButton1_actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null, "成功");
}
}
class Frametest_jButton1_actionAdapter implements ActionListener {
private Frametest adaptee;
Frametest_jButton1_actionAdapter(Frametest adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
----------------解决方案--------------------------------------------------------
JOptionPane里面很多方法都可以。
如JOptionPane.show...Dialog
----------------解决方案--------------------------------------------------------