为什么当 Windows 屏幕锁定时 setExtendedState(JFrame.ICONIFIED) 不起作用?
全部。 我想用 setExtendedState(JFrame.ICONIFIED) 最小化我的 jframe,在大多数情况下,它可以正常工作,但是当我用 WIN+L 锁定我的操作系统(windows XP)屏幕时它不起作用。我的 wimple 代码如下:
import javax.swing.JDialog;
import javax.swing.JFrame;
public class FrameTest extends JFrame {
public static FrameTest ft = new FrameTest();
public static void main(String[] args)
{
FrameTest.ft.setVisible(true);
FrameTest.ft.setLocation(300, 300);
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
JDialog dlg = new JDialog( ft, "xxx", true );
ft.setExtendedState(JFrame.ICONIFIED);
dlg.setVisible(true);//if not have this line, it works also in screen lock case
}
}
任何帮助将不胜感激。
all.
i want to minimize my jframe with setExtendedState(JFrame.ICONIFIED), in most case, it works properly, but when it does not work when i lock my os(windows XP) screen with WIN+L.My wimple code are as follows:
import javax.swing.JDialog;
import javax.swing.JFrame;
public class FrameTest extends JFrame {
public static FrameTest ft = new FrameTest();
public static void main(String[] args)
{
FrameTest.ft.setVisible(true);
FrameTest.ft.setLocation(300, 300);
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
JDialog dlg = new JDialog( ft, "xxx", true );
ft.setExtendedState(JFrame.ICONIFIED);
dlg.setVisible(true);//if not have this line, it works also in screen lock case
}
}
Any help will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可能认为您正在从主线程而不是事件调度线程操作 Swing 组件。尝试将
main
的内容包装在:如果这没有帮助,请尝试将第二个
invokeLater
块拆分为:这使 Swing 有机会在移交之前响应图标化控制到对话框。
It could me that you are manipulating Swing components from the main thread instead of the Event Dispatch Thread. Try wrapping the contents of
main
in:If that doesn't help, try splitting the second
invokeLater
block into:That gives Swing a chance to respond to the iconification before handing off control to the dialog.