4

我在 JApplet 中创建了一个按钮。如何使用它打开消息框?

okButton = new Button("Miow");
okButton.setBounds(20,20,1150,30);
add(okButton);

//like
if(okButton)
{
    JOptionPane.showMessage......
}
4

1 回答 1

8

这可能会帮助您:

okButton.addActionListener(new MyAction());
public class MyAction implements ActionListener{
  public void actionPerformed(ActionEvent ae){
    JOptionPane.showMessageDialog(null, "This is the simple message 
    dialog box.", "Roseindia.net", 1);
  }
}

取自这里:http ://www.roseindia.net/java/example/java/swing/ShowMessageDialog.shtml

于 2013-10-29T11:52:21.467 回答