How to present a simple alert message in java?

后端 未结 5 448
无人及你
无人及你 2020-12-07 11:00

Coming from .NET i am so used calling Alert() in desktop apps. However in this java desktop app, I just want to alert a message saying \"thank you for using java\" I have to

5条回答
  •  北海茫月
    2020-12-07 11:46

    I'll be the first to admit Java can be very verbose, but I don't think this is unreasonable:

    JOptionPane.showMessageDialog(null, "My Goodness, this is so concise");
    

    If you statically import javax.swing.JOptionPane.showMessageDialog using:

    import static javax.swing.JOptionPane.showMessageDialog;
    

    This further reduces to

    showMessageDialog(null, "This is even shorter");
    

提交回复
热议问题