如何设置小程序的大小

如何设置小程序的大小

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

问题描述

我已经写了一个小的测试小应用程序,并开始通过Eclipse的appletviewer的小程序。
我注意到标签在code的begginig,但appletviewer中并没有看到它。它开始在非标准窗口小程序与每次的大小相同。
我使用JDK 1.7,Eclipse的开普勒

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:

运行 - &GT;运行配置 - &GT; Java小程序 - &GT;新配置。默认大小可以在参数标签进行更改。

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

请注意,这只是用于测试和用户看到的是实际的小程序依赖于applet的方式为他们推出了(这是通过一个&LT典型的做法;小程序&GT; &LT;对象&gt; &LT;嵌入&gt;在网页标记所有这些标签的支持大小属性。 )

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.)

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

09-05 13:42