- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个打开多个 JIF 的应用程序,但我只想创建 JIF 的单个实例,因此我使用这些函数来检查这一点,并在按下某个键后使用 dispose 关闭 JIF(JDesktopPane. getSelectedFrame().dispose())。但是连续2-3次处理后,它没有创建新的JIF?我在这里做错了什么吗?
public static void setInternalFrame(final JInternalFrame internalFrame) {
log.debug("CurActiveInternalFrame " + ShoppyPOSApp.getCurrentActiveInternalFrame(), null);
log.debug("Incoming internalFrame " + internalFrame, null);
boolean isFrameFound = false;
try {
// Have a check whether the DesktopPane contains the internal Frame
// If yes bring it to front and set the focus
for (int i = 0; i < ShoppyPOSApp.frame.mainDesktopPane.getAllFrames().length; i++) {
if (ShoppyPOSApp.frame.mainDesktopPane.getAllFrames()[i].getClass() == internalFrame.getClass()) {
isFrameFound = true;
}
}
if (!isFrameFound) {
internalFrame.setVisible(true);
internalFrame.setLocation(
ShoppyPOSApp.frame.mainDesktopPane.getWidth()/ 2 - internalFrame.getWidth() / 2,
ShoppyPOSApp.frame.mainDesktopPane.getHeight() / 2 - internalFrame.getHeight() / 2
);
ShoppyPOSApp.frame.mainDesktopPane.add(internalFrame);
}
internalFrame.setSelected(true);
} catch (Exception e) {
log.debug(e.toString(), null);
}
}
最佳答案
您正在 for 循环中比较输入参数的类和桌面内部框架。这始终是正确的,因为您的参数是 JInternalFrame 的实例,并且 getAllFrames 方法返回 JInternalFrames 数组。为什么不定期进行比较呢? :
ShoppyPOSApp.frame.mainDesktopPane.getAllFrames()[i] == internalFrame
我建议使用 HIDE_ON_CLOSE
作为您的 default close operation在框架上并在关键监听器中使用 setVisible(false)
而不是 dispose()
。当框架被处置时,它们将被关闭,并且您不应该在关闭后尝试重新使用框架。如果您只是隐藏框架,它仍然是桌面 Pane 的子级,因此当您在 setInternalFrame
方法中找到框架时,应该添加对 setVisible(true)
的调用.
听起来你的行为不一致(你说它在两到三次处置后失败)。这向我表明您遇到了事件线程问题。您的 setInternalFrame 是否在事件线程上被调用?你熟悉Event Dispatch Thread吗?你使用得正确吗?
关于java - 维护 JInternalFrame 的单个实例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1736809/
任何人都可以帮助如何将值从一个 jInternalFrame1 传递到另一个 jInternalFrame2?我无法在 jInternalFrame2 中创建 jInternalFrame1 的对
我有 2 个 JInternalFrames,每个 JInternalFrames 包含一个 JPanel。一个 JPanel(源)更新其 GUI 和一些数据以响应鼠标事件。另一个 JPanel(目标
有可能吗?从另一个 JInternalFrame 调用 JInternalFrame ??如果是这样怎么办? 我花了好几个小时寻找答案..之前发现一些问题.. 在这里How to manage a J
我有一个包含这段代码的 JDesktopPane。 public class Menu extends JFrame implements ActionListener{ /** * Creates
这是我的源代码。我无法将我的 JInternalframe 放到前面。我已经尝试了很多代码,但没有任何效果。 private void jMenuItem3ActionPerformed(ja
在下面的 SSCCE 中,您可以看到,如果最大化 JInternalFrame 之一,则会同时最大化它们。这只(AFAIK)发生在“Windows”LookAndFeel 中(如果省略 LookAnd
我在桌面 Pane 内有一个 JInternalframe (tab_items)。每当用户单击 tab_items 中的弹出菜单时,我想在同一桌面 Pane 中打开另一个 JInternalfram
例如: 当JButton1点击JInternalFrame1时在JDesktopPane上显示当JButton2点击JInternalFrame1关闭时,JInternalFrame2在JDeskto
我正在创建一个非常简单的程序。我创建了这个类:MainJframeClass、JDesktopPaneClass、JinternalFrameClass1 和 JinternalFrameClass2
在我的应用程序中,我尝试在实现 MigLayout 的单个 JDesktopPane 中打开一个 JInternalFrame 覆盖另一个 JInternalFrame > 但它在第一个内部框架旁边显
我已经阅读了很多关于 Java 中的构造函数的文章,并在 stackoverflow 中搜索了相关问题,但我仍然对我的程序如何从 jinternalframe1 到 jinternalframe2 获
我使用 netbeans 在 java 中创建了 MDI(多文档界面),其中我有两个 jbuttons 和一个 jdesktoppane 所以当点击两个按钮然后两个 jinternalframes 在
我从 https://stackoverflow.com/a/6868039/2240900 得到的这段代码 how to add the internal2 to desktoppane1 usin
您好,我需要一个示例程序,其中当我最大化 JInternalFrame 时,JFrame 的 JMenuBar 应该设置在 JInternalFrame 上当我再次最小化 JInternalFrame
我创建了一个应用程序,其中有两个标题为 的选项卡选项卡 Pane 1 和 选项卡 Pane 2 .在一个标签正文中 选项卡 Pane 1 包含 JInternalFrame其中有一个搜索按钮。单击按钮
我想在 jFrame 中的桌面 Pane 上显示 jInternalFrame1。jInternalFrame1 包含一个按钮,用于通过删除 jInternalFrame1 在桌面 Pane 上显示
我在网上看到一个JInternalFrame的例子,它是这样写的: public class AddEntry extends JInternalFrame 当我尝试在 Netbeans 中创建 JI
下面的“代码部分 1”用于在 MDI 应用程序中从 menuItem 调用 UcakListesi(JinternalFrame) 没有问题。 我想使用相同的代码从另一个 JinternalFrame
我打算在全屏模式下使用 JInternalFrame 作为模态 JDialog,但是,当它被调用时当前没有显示。我需要将它添加到某个容器中吗?我尝试将它添加到 JOptionPane.showInte
我正在处理与此错误相关的问题,我认为:DefaultDesktopManager does not handle InternalFrame state changes as expected. 我有
我是一名优秀的程序员,十分优秀!