gpt4 book ai didi

java - 我的 japplet 可以编译,但在 applet 查看器中显示为空白

转载 作者:行者123 更新时间:2023-12-01 13:03:07 25 4
gpt4 key购买 nike

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

import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

public class LoginApplet extends JApplet { /**
*
*/
private static final long serialVersionUID = 1L;

JLabel titlePage;
JLabel[] txt;
JTextField[] jtf;
JButton accept, decline;
JPanel jp1, jp2, jp3;


public void init(){
setSize(400,400);

JPanel content = (JPanel)getContentPane();
GridBagConstraints firstCol = new GridBagConstraints();
firstCol.weightx = 1.0;
firstCol.anchor = GridBagConstraints.WEST;
firstCol.insets = new Insets(5, 20, 5, 5);
GridBagConstraints lastCol = new GridBagConstraints();
lastCol.gridwidth = GridBagConstraints.REMAINDER;
lastCol.weightx = 1.0;
lastCol.fill = GridBagConstraints.HORIZONTAL;
lastCol.insets = new Insets(5, 5, 5, 20);

String[] labeltxt = {"Username", "Password"};
titlePage = new JLabel("Create New Account");
txt = new JLabel[2];
jtf = new JTextField[2];
accept = new JButton("Create");
decline = new JButton("Decline");

jp1 = new JPanel();
jp2 = new JPanel(new GridBagLayout());
jp3 = new JPanel();
for(int i=0; i<labeltxt.length; i++) {
txt[i] = new JLabel();
txt[i].setText(labeltxt[i]);
jp2.add(txt[i], firstCol);
jtf[i] = new JTextField();
jtf[i].setPreferredSize(new Dimension(300, 20));
jp2.add(jtf[i], lastCol);
}
jp1.add(titlePage);
jp3.add(accept);
jp3.add(decline);
content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
content.add(jp1);
content.add(jp2);
content.add(jp3);

}

public void setVisible(boolean b) {
// TODO Auto-generated method stub

}


}

大家好..我发布的这段代码来自类LoginApplet,它由另一个类的ActionPerformed调用....我将其设置为JFrame没有问题(此作业的标题在JApplet中)。现在,当我将其转换为 JApplet 时,问题出现了。我对JApplet不熟悉,运行时代码显示为空白有什么问题吗?

最佳答案

摆脱

public void setVisible(boolean b) {
// TODO Auto-generated method stub
}

它阻止小程序认为它是可见的...

关于java - 我的 japplet 可以编译,但在 applet 查看器中显示为空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23402933/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com