本文介绍了如何创建一个Java小程序,反之亦然内一个JFrame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个Java小程序JInternalFrames。为此,我认为你需要这种或那种形式的JFrame。我听说你可以换你的applet在一个JFrame,是最好的?如果你能告诉我,我应该做的我会AP preciate它。 TYIA -Roland

I am trying to create a Java applet with JInternalFrames. For this I believe you need a JFrame in one form or another. I heard you could wrap your applet in a JFrame, is that best? If you could tell me what I should do I would appreciate it. TYIA -Roland

/**
 * @(#)rebuiltgui.java
 *
 * rebuiltgui Applet application
 *
 * @author
 * @version 1.00 2013/1/21
 */

import javax.swing.JInternalFrame;
import javax.swing.JDesktopPane;
import javax.swing.plaf.basic.BasicInternalFrameUI;
import java.awt.event.*;
import java.awt.Desktop;
import javax.swing.*;
import javax.swing.BoxLayout;
import java.awt.*;
import java.applet.*;

public class rebuiltgui extends JApplet {

    public void init() {

        javax.swing.SwingUtilities.invokeLater(new Runnable() {

            public void run() {

                createAndShowGUI();
            }
        });
    }

    private void createAndShowGUI() {

   // This is where I would put the internal frames.
    }
}


推荐答案

您可以在您的一个独立的Swing应用程序做的小程序code同样的方式创建的JFrame

You can create JFrame in the applet code same way you do in a stand alone Swing application:

JFrame frame = new JFrame("Hello");
....
frame.show();

该框架将离开浏览器窗口,显示为一个单独的窗口,只是它会包含一些警告标签,这是一个Java小程序的运行。这种框架可以调整大小或周围移动。

The frame will leave the browser window, showing up as a separate window, just it will contain some warning tags that this is a Java applet running. Such frame can be resized or moved around.

其实,一些小程序不显示多单按钮更推出帧,他们的主要观点。

Actually, some "applets" do not show much more than a single button to launch the frame in they main view.

请参阅以显示四个按钮的小程序的例子推出四种不同的可视化(来源$ C ​​$ C可用)。

See http://baba.sourceforge.net/ for an example of the applet that shows four buttons to launch four different visualizations (source code is available).

如果,非常不同,你真正想要的也不会离开你applet区域框架,使用的。这是一个的layeredPane所以你也可以把你的主要成分为背景图层。

If, very differently, you actually want frames that could not leave your applet area, use InternalFrame. It is a LayeredPane so you can also put your main component as a background layer.

这篇关于如何创建一个Java小程序,反之亦然内一个JFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 16:34
查看更多