如何设置小程序的大小? [英] How to set size of applet?

查看:31
本文介绍了如何设置小程序的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个小测试小程序,并通过 Eclipse appletviewer 启动小程序.我在代码的开始处注意到了标签,但 appletviewer 没有看到它.它每次都在标准窗口中以相同的大小启动小程序.我使用 JDK 1.7,Eclipse Kepler

I have written a little test applet and start the applet via Eclipse appletviewer. I have noted tag at the begginig of the code, but appletviewer doesn't see it. It starts the applet in standart window with the same size every time. I use JDK 1.7, Eclipse Kepler

import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

/*<applet code="TestApplet" width=200 height=40>
</applet>
*/
public class TestApplet extends JApplet{
    private Container cp;
    private JPanel mainPanel, testPanel1;
    private JLabel testLabel1 = new JLabel("Test1"),
                testLabel2 = new JLabel("Test2");
    private JTextField testTextField1 = new JTextField(),
            testTextField2 = new JTextField();
    private JButton testButton1 = new JButton("TestButton1"),
            testButton2 = new JButton("TestButton2");
    public void init(){
        cp = getContentPane();
        testPanel1 = new JPanel(new GridLayout(3,1));
        cp.add(testPanel1);
        testPanel1.add(testLabel1);
        testPanel1.add(testTextField1);
        testPanel1.add(testButton1);
    }

    public void start(){
    }

    public void stop(){

    }

    public void destroy(){

    }
}

如何在使用 Eclipse 启动小程序窗口时更改小程序窗口的大小?

How can I change size of the applet window when I start it using Eclipse?

推荐答案

您可以在 Eclipse 中的运行配置中更改它:

You can change it in Run Configurations in Eclipse:

运行 ->运行配置 ->Java 小程序 ->新配置.可以在参数"选项卡中更改默认大小.

Run -> Run Configurations -> Java Applet -> New Configuration. the default size can be changed in the Parameters tab.

请注意,这仅用于测试,您的用户看到的实际小程序取决于为他们启动小程序的方式(通常通过 <;object> 标签在网页中.所有这些标签都支持大小属性.)

Note that this is only for testing and the actual applet your user sees is depends on how the applet is launched for them (Which is done typically via a <applet>, <object> or <embed> tags in a webpage. all of these tags support size attributes.)

这篇关于如何设置小程序的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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