关于java的兼容性问题

hugos 2001-11-08 04:08:30
我用forte for java 做applets, 如果applets用AWT开发的话,浏览器可以初始化applets. 但是如果applets用到swing(import javax.swing.*)的东西,浏览器就找不到class, 这是怎么回事?
我的环境:win2000server + apache + forte for java 3E + java plugin 1.3.1 + java sdk 1.3.1;
怎么样才能够用上swing?
原码如下
/*
* mobile_applet.java
*
* Created on 2001年11月8日, 上午10:42
*/

/**
*
* @author Administrator
*/
import javax.swing.*;

public class mobilelet extends javax.swing.JApplet {

/** Creates new form mobile_applet */
public mobilelet() {
initComponents();
}
public void init()
{
}

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jPasswordFieldPwd = new javax.swing.JPasswordField();
jButtonEmpty = new javax.swing.JButton();
jButtonLogin = new javax.swing.JButton();
jTextFieldUser = new javax.swing.JTextField();

getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

setFont(new java.awt.Font("Arial", 0, 14));
setBackground(java.awt.Color.pink);
jLabel1.setText("\u7528\u6237\u7f16\u53f7");
jLabel1.setFont(new java.awt.Font("幼圆", 0, 14));
getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 20, 60, -1));

jLabel2.setText("\u767b\u5f55\u53e3\u4ee4");
jLabel2.setFont(new java.awt.Font("幼圆", 0, 14));
getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 50, -1, -1));

getContentPane().add(jPasswordFieldPwd, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 50, 90, -1));

jButtonEmpty.setFont(new java.awt.Font("宋体", 0, 12));
jButtonEmpty.setText("\u6e05\u7a7a");
jButtonEmpty.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButtonEmptyMouseClicked(evt);
}
});

getContentPane().add(jButtonEmpty, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 90, 80, -1));

jButtonLogin.setFont(new java.awt.Font("宋体", 0, 12));
jButtonLogin.setText("\u786e\u8ba4");
jButtonLogin.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButtonLoginMouseClicked(evt);
}
});

getContentPane().add(jButtonLogin, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 90, 80, -1));

jTextFieldUser.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextFieldUserActionPerformed(evt);
}
});

getContentPane().add(jTextFieldUser, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 20, 90, -1));

}

private void jTextFieldUserActionPerformed(java.awt.event.ActionEvent evt) {
// Add your handling code here:
}

private void jButtonLoginMouseClicked(java.awt.event.MouseEvent evt) {
// Add your handling code here:

}

private void jButtonEmptyMouseClicked(java.awt.event.MouseEvent evt) {
// Add your handling code here:
jTextFieldUser.setText("");
jPasswordFieldPwd.setText("");
}


// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPasswordField jPasswordFieldPwd;
private javax.swing.JButton jButtonEmpty;
private javax.swing.JButton jButtonLogin;
private javax.swing.JTextField jTextFieldUser;
// End of variables declaration

}


...全文
303 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
hugos 2001-11-13
  • 打赏
  • 举报
回复
dsfdfs
hugos 2001-11-12
  • 打赏
  • 举报
回复
谢谢各位,问题解决了,散分!
需要正确的设置CLASSPATH环境变量。就可以了。
但是对于INTERNET客户,怎么办? 不能让他们手动的设吧,根本就不可能。有没有什么好的方法?
hugos 2001-11-09
  • 打赏
  • 举报
回复
to :gdsean(摇滚java) 
但是为什么AWT做的applets就不用设置工作目录?
gdsean 2001-11-09
  • 打赏
  • 举报
回复
设置classpath,把mobilet.class所在的目录写进去
或者看看java console的工作目录在什么地方,把
mobilet.class拷贝进去
hugos 2001-11-09
  • 打赏
  • 举报
回复
同志们,帮帮忙吧
难道用forte for java 的人太少了?
用AppletViewer可以啊,用IE就找不到。
错误提示:load: class mobilet not found
hugos 2001-11-08
  • 打赏
  • 举报
回复
呵呵,org.netbeans.lib.awtextra是forte的wizard自动生成的。我也不知道是什么东东啊!
gdsean 2001-11-08
  • 打赏
  • 举报
回复
编译不通过,org.netbeans.lib.awtextra?是什么冬冬?
hugos 2001-11-08
  • 打赏
  • 举报
回复
jre 早就装了。
还是不行啊!
hugos 2001-11-08
  • 打赏
  • 举报
回复
plugin我已经有了。
把你的代码加进去之后,好像启动了两个java console.
hexiaofeng 2001-11-08
  • 打赏
  • 举报
回复

html只要像如下修改,即可:
<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
codeBase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"
width=300
height=320
align=center>
<param name="code" value="*****.class">
</OBJECT>


或者下载jre for 98,win2000,xp,安装,可不用修改html
http://java.sun.com/getjava/download.html,

62,635

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧