当前位置: 技术问答>java相关
关于java的兼容性问题
来源: 互联网 发布时间:2015-02-19
本文导语: 我用forte for java 做applets, 如果applets用AWT开发的话,浏览器可以初始化applets. 但是如果applets用到swing(import javax.swing.*)的东西,浏览器就找不到class, 这是怎么回事? 我的环境:win2000server + apache + forte for java 3E...
我用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("u7528u6237u7f16u53f7");
jLabel1.setFont(new java.awt.Font("幼圆", 0, 14));
getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 20, 60, -1));
jLabel2.setText("u767bu5f55u53e3u4ee4");
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("u6e05u7a7a");
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("u786eu8ba4");
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
}
我的环境: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("u7528u6237u7f16u53f7");
jLabel1.setFont(new java.awt.Font("幼圆", 0, 14));
getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 20, 60, -1));
jLabel2.setText("u767bu5f55u53e3u4ee4");
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("u6e05u7a7a");
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("u786eu8ba4");
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
}
|
设置classpath,把mobilet.class所在的目录写进去
或者看看java console的工作目录在什么地方,把
mobilet.class拷贝进去
或者看看java console的工作目录在什么地方,把
mobilet.class拷贝进去
|
html只要像如下修改,即可:
或者下载jre for 98,win2000,xp,安装,可不用修改html
http://java.sun.com/getjava/download.html,
|
编译不通过,org.netbeans.lib.awtextra?是什么冬冬?