简体   繁体   English

获得JInternalFrame对象的关注

[英]gaining a focus of JInternalFrame object

What happens when you minimize JInternalFrame object using built-in icon located in the corner (next to maximizing and closing ones)? 当使用位于拐角处的内置图标最小化JInternalFrame对象时(在最大化和关闭边界旁边),会发生什么? I have a JInternalFrame in JDesktopPane and my problem is following: When I minimize one frame it is being minimized. 我在JDesktopPane中有一个JInternalFrame,我的问题是:当我最小化一帧时,它正在被最小化。 When I try to re-open the frame via using JMenu it works for first time. 当我尝试通过使用JMenu重新打开框架时,它第一次起作用。 When I do this procedure again, the frame is being minimized but not re-opened, but when I click manually on a iconified frame, it shows properly. 当我再次执行此过程时,该框架被最小化,但没有重新打开,但是当我手动单击一个图标化的框架时,它会正确显示。 I tried to do combination of setSelected, moveToFront, setIcon, setVisible, activateFrame, or requestFocus, but still no effects. 我尝试将setSelected,moveToFront,setIcon,setVisible,activateFrame或requestFocus组合在一起,但仍然没有效果。 I wonder what happens when you minimize JInternalFrame, what is being set, what should do to get focus of a particular frame, and why the procedure it works for the first time and not others? 我不知道在最小化JInternalFrame时会发生什么,正在设置什么,如何获得特定帧的焦点,为什么它的过程第一次而不是其他时候起作用? thanks 谢谢

Seems to work fine for me 似乎对我来说很好

try {

    if (myFrame.isIcon()) {

        myFrame.setIcon(false);
        miDoShowHide.setText("Hide");

    } else {

        myFrame.setIcon(true);
        miDoShowHide.setText("Show");

    }

} catch (Exception exp) {

    exp.printStackTrace();

}

I set up a menu item that would call this functionality. 我设置了一个菜单项,称为该功能。 I tested by using the menu to min, restore, min, restore. 我通过使用菜单来进行最小,还原,最小,还原的测试。 I minimized the frame by the frame control and restored via the menu, minimized by the menu and restored by the frame control. 我通过框架控件最小化了框架,并通过菜单进行了还原,通过菜单最小化了并通过框架控件进行了还原。

Also make sure that the JInternalFrame is set to Iconifiable ( setIconifiable(true) ) otherwise you will experience some strange results 还要确保将JInternalFrame设置为IconifiablesetIconifiable(true) ),否则您将遇到一些奇怪的结果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM