假设我有一个JFrame类的对象作为框架
我想知道它们之间有什么区别
JOptionPane.showMessageDialog(null,message)
Run Code Online (Sandbox Code Playgroud)
和
JOptionPane.showMessageDialog(frame,message)
Run Code Online (Sandbox Code Playgroud)
打印出来的东西.给出相同的结果,它们会弹出同一个地方.所以我想知道这两者之间究竟有什么区别?背景中实际发生的事情有何不同
小智 5
提供框架或任何其他组件时,选项窗格将弹出组件的中间位置.但是,如果您提供null,则它将在屏幕中间弹出.
在你的情况下,我猜你的Jframe是你的屏幕尺寸.因此,如果您减小帧大小并在默认位置(即左上角)启动它,那么您可能会看到差异.
// the dialog is centered on the desktop
JOptionPane.showMessageDialog(null,message)
// the dialog is centered on the frame
JOptionPane.showMessageDialog(frame,message)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1742 次 |
| 最近记录: |