永发信息网

为什么APPLET写到HTML里显示不出来?就一个灰灰的框框?

答案:2  悬赏:10  手机版
解决时间 2021-05-18 08:21
  • 提问者网友:动次大次蹦擦擦
  • 2021-05-17 15:56

HTML里的内容是这样的(原本是放在一个小模块里,这里简化了一下):

<Html>
<Applet code="LoginApplet.class" height=100 width=170>
</Applet>
</Html>

程序的JAVA文件里的代码如下:

import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import javax.swing.*;

public class LoginApplet extends JApplet implements ActionListener
{
 private JTextField text_user;
 private JPasswordField password;
 private JButton button_login;
 
 public void init()
 {
  this.setBackground(Color.white);
  this.setLayout(new GridLayout(3,1));
  
  this.add(new JLabel("用户名"));
  text_user = new JTextField("",40);
  text_user.addActionListener(this);
  this.add(text_user);
  
  this.add(new JLabel("密码"));
  password = new JPasswordField("",40);
  this.add(password);
  
  button_login = new JButton("登录");
  this.add(button_login);
  button_login.addActionListener(this);
 }

 public void actionPerformed(ActionEvent e)
 {
  if((e.getSource()==button_login)||(e.getSource()==password))
  {}
 }
}

编译通过,也生成了CLASS文件,和HTML在同一个目录

运行结果是这样子:

是缺了什么东西吗?

最佳答案
  • 五星知识达人网友:枭雄戏美人
  • 2021-05-17 17:19
你好像没有让他在窗体里显示把?
全部回答
  • 1楼网友:往事隔山水
  • 2021-05-17 17:45
闂锛?input name="qt" style="background-color: #ffffff; width: 200px;" type="text" value="" />
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯