如何将JFrame带到前面?

时间:2014-09-15 10:48:27

标签: java swing jframe

我只是想带一个带有进度条的JFrame。我一直在尝试一切:

this.progressFrame.setVisible(true);
this.progressFrame.toFront();
this.progressFrame.repaint();

但框架仍然不可见,图标化,图标一直闪烁。

2 个答案:

答案 0 :(得分:2)

执行以下步骤:
1.确保框架出现在正确的显示器上(如果您有多台显示器,也请检查它们) 2.确保框架尺寸足以看到它 3.尝试添加frame.setBackground(Color.RED),这会使你的窗口变成鲜艳的红色 4.如果您使用的是Windows 7或8,请使用Alt + TAB让Windows突出显示您的窗口 5.如果这些事情都没有帮助过你,那么你的错误可能就在其他地方......尝试隔离你的代码。

为了获得更好的帮助,发布信息和/或显示一些程序代码。

答案 1 :(得分:2)

以备将来参考。

您最好使用JDialog而不是JFrame,

你可以这样使用:

this.progressDialog.setVisible(true);
this.progressDialog.setAlwaysOnTop(true);
this.progressDialog.toFront(); 

this链接所述。