我在JApplet中创建了一个按钮.如何使用它打开消息框?
okButton = new Button("Miow");
okButton.setBounds(20,20,1150,30);
add(okButton);
//like
if(okButton)
{
JOptionPane.showMessage......
}
解决方法:
这可能对您有所帮助:
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