不显示顶层时的用法:
JOptionPane.showMessageDialog(null,"普通提示窗口演示", "提示", 2);
顶层窗口用法:
Frame frame = new Frame();
frame.setAlwaysOnTop(true);//设置顶层显示
JOptionPane.showMessageDialog((Component)frame,"顶层窗口演示", "提示", 2);
本文介绍了如何使用Java Swing创建普通提示窗口及顶层窗口。通过代码示例展示了两种不同类型的窗口实现方式,一种为普通的提示窗口,另一种则通过设置顶层属性来实现始终位于其他窗口之上的效果。
JOptionPane.showMessageDialog(null,"普通提示窗口演示", "提示", 2);
Frame frame = new Frame();
frame.setAlwaysOnTop(true);//设置顶层显示
JOptionPane.showMessageDialog((Component)frame,"顶层窗口演示", "提示", 2);
9435
287
581
176
882

被折叠的 条评论
为什么被折叠?