JFrame全屏聚焦。 [英] JFrame full screen focusing .

查看:197
本文介绍了JFrame全屏聚焦。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  //设置全屏
$这是我设置一个JFrame到全屏模式的方式b $ b frame.dispose();
frame.setUndecorated(true);
screenDevice.setFullScreenWindow(frame);
frame.setVisible(true);

//重置为窗口模式

frame.dispose();
screenDevice.setFullScreenWindow(null);
frame.setUndecorated(false);
frame.setVisible(true);

但是,当我显示任何对话框,像设置对话框,对话框和全屏幕框架都丢失他们的foucs和屏幕上消失。然后我需要点击任务栏图标才能获得焦点。



如何解决这个问题?谢谢。

编辑:

假设在这个全屏窗口的菜单栏中有一个JMenuItem ,然后我通过点击这样的menuitem使可见的设置JDialog:

$ p $ settingsMenuItem.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e){
settingsDialog.showSettingsDialog();
}
});

在全屏模式下,屏幕上不显示settingsDialog和全屏幕。如果你想设置你的 JFrame to 最大化为什么不使用这个:

$ p $ frame $ set $ c $> frame.setExtendedState Frame.MAXIMIZED_BOTH);


This is how i am setting a JFrame to full screen mode :

//set full screen            

frame.dispose();
frame.setUndecorated(true);
screenDevice.setFullScreenWindow(frame);
frame.setVisible(true);

//reset to window mode

frame.dispose();
screenDevice.setFullScreenWindow(null);
frame.setUndecorated(false);
frame.setVisible(true);

But, when i display any dialog, something like settings dialog, the dialog and full screen frame both lost their foucs and disappear on screen. Then i need to click in the taskbar icon to get the focus.

How to solve this issue ? Thank you.

Edit:

Suppose if there is a JMenuItem in the menu bar of this full screen window, then i am making visible a settings JDialog by clicking the menuitem like this:

settingsMenuItem.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
        settingsDialog.showSettingsDialog();
    }
});

The settingsDialog and full screen are not showing on the screen in full screen mode. in window mode it works normally.

解决方案

If you want to set your JFrame to maximized why not use this:

frame.setExtendedState(Frame.MAXIMIZED_BOTH); 

这篇关于JFrame全屏聚焦。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆