2

ログイン後にアプレットクラスを呼び出しています。フォームは表示されますが、コンポーネントは表示されません。これが私のクラスです:

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package stanacle;


import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import java.util.Calendar;
import javax.swing.JOptionPane;
/**
*
* @author Stano
*/
public class MenuOption extends JApplet{
Label header, menu, error, user;
TextField option;
Button go;

/**
 * Initialization method that will be called after the applet is loaded
 * into the browser.
 */
public void init() {
    // TODO start asynchronous download of heavy 
    setSize(1024, 768);
    setLayout(null);
    setVisible(true);
    header = new Label();
        menu = new Label();
        error = new Label();
        user = new Label();
        option = new TextField();
        go = new Button("GO");
        header.setBounds(370, 10, 200, 20);
        menu.setBounds(10, 60, 200, 20);
        option.setBounds(150, 60, 200, 20);
        go.setBounds(750, 10, 150, 30);
        error.setBounds(370, 310, 500, 20);
        user.setBounds(10, 10, 200, 20);
        header.setText("MENU OPTION PAGE");
        menu.setText("Enter Menu Option");


        add(header);
        add(menu);
        add(option);
        add(go);
        add(error);
        add(user);
}
// TODO overwrite start(), stop() and destroy() methods
}

フォームは表示されていますが、TextField、Labeled、およびButtonを含むコンポーネントは表示されていません。私は何を間違っているのでしょうか?

4

1 に答える 1

1

1)コード行

setSize(1024, 768);
setLayout(null);
setVisible(true);

public void init() {コンテナを表示してから追加するため、の最後のコード行である必要がありますJ/Components

2)本当の理由(OpenGL、CAD / CAM)がない場合は、

3) NullLayoutを使用しないでください

于 2012-06-12T13:22:03.713 に答える