在没有 JDesktopPanes 的情况下查看 JInternalFrames [英] View JInternalFrames without JDesktopPanes

查看:42
本文介绍了在没有 JDesktopPanes 的情况下查看 JInternalFrames的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们知道 JInternalFrame 无法运行..我们必须将其设置为 JDesktopPane但是我从我的一位朋友那里听说 JInternalFrame 可以运行.那可能吗..?有没有main方法的代码...?

As we know JInternalFrame cannot run..we have to set it to a JDesktopPane But I heard from one of my friends that JInternalFrame can run. Is that possible..? Is there any code for main method ...?

推荐答案

当然,JInternalFrame 无法运行";他们没有腿.但是,如果您声称没有 JDesktopPane 就无法使用它们,那么您从哪里获得知识"?你为什么不自己试试呢?只需不到五分钟:

Sure, "JInternalFrame cannot run"; they don’t have legs. But if you claim that they cannot be used without a JDesktopPane, where do you get that "knowledge" from? And why don’t you try for yourself? It takes less than five minutes:

import javax.swing.*;

public class IFrames
{
  public static void main(String[] args)
  {
    try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }
    catch(Exception ex){}
    JFrame f=new JFrame();
    f.setContentPane(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
      createFrame("Left"), createFrame("right") ));
    f.setSize(300, 300);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
  }

  private static JInternalFrame createFrame(String title)
  {
    final JInternalFrame f1 = new JInternalFrame(title, true, true);
    f1.setVisible(true);
    f1.getContentPane().add(new JLabel(title));
    return f1;
  }
}

简单的答案:没有 JDesktopPane 没有人会阻止您使用它们,尽管使用它们更自然.文档 说:通常,您添加JInternalFrames 到 JDesktopPane."

Simple answer: no one prevents you from using them without a JDesktopPane though using them with it is more natural. The documentation says: "Generally, you add JInternalFrames to a JDesktopPane."

嗯,一般"并不排除豁免.

Well, "Generally" does not preclude exemptions.

顺便说一下,JOptionPane.showInternal…Dialog 是使用 JInternalFrame 而没有 JDesktopPane 的典型应用示例.

By the way JOptionPane.showInternal…Dialog is a typical example of an application of using a JInternalFrame without a JDesktopPane.

这篇关于在没有 JDesktopPanes 的情况下查看 JInternalFrames的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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