请教Applet中调用非标准类库的问题。 你把borland的这类所在的包的路径设置到classpath里面去.borland这个包我没用过,所以不知道具体的位置.如果用到自定义的类库也要设置到classpath里面去,就跟你运行一般的java程序一样,如果需要第三方的类库就要用classpath,或者是放入到jdk文件夹下的jre/lib/ext目录下. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你用了borland公司自己的一些组件 ,这些组件不是j2sdk自带的,你在jb中运行可以,但用浏览器就不行了,你找到borland这些包,应该是一些.jar包,将他们的路径放到环境变量classpath里面应该就可以解决 borland公司的那些包好像在jbuilder目录下的lib文件夹里面,具体是哪个我就不太清楚了. 都试了,还是不行!我贴下原代码,哪位大虾帮我试下。package test;import java.awt.*;import java.awt.event.*;import java.applet.*;import javax.swing.*;import com.borland.jbcl.layout.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class AppletTest extends Applet { private boolean isStandalone = false; JPanel jPanel1 = new JPanel(); XYLayout xYLayout1 = new XYLayout(); JTextField jTextField1 = new JTextField(); JButton jButton1 = new JButton(); JTextField jTextField2 = new JTextField(); JLabel jLabel1 = new JLabel(); //Get a parameter value public String getParameter(String key, String def) { return isStandalone ? System.getProperty(key, def) : (getParameter(key) != null ? getParameter(key) : def); } //Construct the applet public AppletTest() { } //Initialize the applet public void init() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { jPanel1.setLayout(xYLayout1); xYLayout1.setWidth(300); xYLayout1.setHeight(400); this.setBackground(SystemColor.info); jButton1.setBackground(SystemColor.textHighlight); jButton1.setForeground(Color.orange); jButton1.setText("È·¶¨"); jButton1.addActionListener(new AppletTest_jButton1_actionAdapter(this)); jTextField1.setBackground(Color.pink); jTextField1.setText(""); jPanel1.setBackground(SystemColor.activeCaptionBorder); jPanel1.setAlignmentY((float) 0.5); jTextField2.setBackground(Color.pink); jTextField2.setText(""); jLabel1.setFont(new java.awt.Font("Monospaced", 0, 12)); jLabel1.setForeground(Color.yellow); jLabel1.setText(" ÇëÊäÈëÒ»Êý×Öºóµ¥»÷È·¶¨£º"); this.add(jPanel1, null); jPanel1.add(jTextField2, new XYConstraints(55, 130, 216, 27)); jPanel1.add(jButton1, new XYConstraints(200, 102, 67, 17)); jPanel1.add(jTextField1, new XYConstraints(180, 56, 89, 20)); jPanel1.add(jLabel1, new XYConstraints(14, 54, 161, 20)); } //Get Applet information public String getAppletInfo() { return "Applet Information"; } //Get parameter info public String[][] getParameterInfo() { return null; } void jButton1_actionPerformed(ActionEvent e) { char input = jTextField1.getText().charAt(0); switch(input){ case 49: jTextField2.setText(new String("ÄúÊäÈëµÄÊÇ1¡£"));break; case 50: jTextField2.setText(new String("ÄúÊäÈëµÄÊÇ2¡£"));break; default: jTextField2.setText(new String("ÄúÊäÈëµÄÊDz»ºÏ·¨µÄÊý×Ö¡£"));break; case 51:jTextField2.setText(new String("ÄúÊäÈëµÄÊÇ3¡£"));break; } }}class AppletTest_jButton1_actionAdapter implements java.awt.event.ActionListener { AppletTest adaptee; AppletTest_jButton1_actionAdapter(AppletTest adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jButton1_actionPerformed(e); }} 还有个问题,就是如果每要在Applet中引用个非标准或自定义的类库,就要在客户端进行这么负责的环境配置,那岂不是很麻烦? 对。就是这样,客户端要安装JRE。 但JRE只有JAVA的一些核心类库,如Applet里用到第三方或自定义的类库,怎么办?客户端显示会不会有问题?就想上面那个AppletTest有用到borland的jbcl包,在浏览器里就不能正常显示。哪位大虾能清楚的说下Applet在浏览器中的显示过程? 有没有好的算法解决这一问题! 小问题 java的方向选择 struts 动态Action问题 提个简单的判断问题? 关于String的方法contains() 如何让程序在繁忙的时候把鼠标变为沙漏? 急救!!如何控制 float 型变量的小数位数? 请高手指点迷津 在JAVA里面怎样访问系统目录 rmi 在不同的机器上运用问题 关于java在编译和运行时所引用的类库的问题。
这些组件不是j2sdk自带的,你在jb中运行可以,但用浏览器就不行了,
你找到borland这些包,应该是一些.jar包,将他们的路径放到环境变量classpath里面应该就可以解决
我贴下原代码,哪位大虾帮我试下。
package test;import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/public class AppletTest extends Applet {
private boolean isStandalone = false;
JPanel jPanel1 = new JPanel();
XYLayout xYLayout1 = new XYLayout();
JTextField jTextField1 = new JTextField();
JButton jButton1 = new JButton();
JTextField jTextField2 = new JTextField();
JLabel jLabel1 = new JLabel();
//Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
} //Construct the applet
public AppletTest() {
}
//Initialize the applet
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
jPanel1.setLayout(xYLayout1);
xYLayout1.setWidth(300);
xYLayout1.setHeight(400);
this.setBackground(SystemColor.info);
jButton1.setBackground(SystemColor.textHighlight);
jButton1.setForeground(Color.orange);
jButton1.setText("È·¶¨");
jButton1.addActionListener(new AppletTest_jButton1_actionAdapter(this));
jTextField1.setBackground(Color.pink);
jTextField1.setText("");
jPanel1.setBackground(SystemColor.activeCaptionBorder);
jPanel1.setAlignmentY((float) 0.5);
jTextField2.setBackground(Color.pink);
jTextField2.setText("");
jLabel1.setFont(new java.awt.Font("Monospaced", 0, 12));
jLabel1.setForeground(Color.yellow);
jLabel1.setText(" ÇëÊäÈëÒ»Êý×Öºóµ¥»÷È·¶¨£º");
this.add(jPanel1, null);
jPanel1.add(jTextField2, new XYConstraints(55, 130, 216, 27));
jPanel1.add(jButton1, new XYConstraints(200, 102, 67, 17));
jPanel1.add(jTextField1, new XYConstraints(180, 56, 89, 20));
jPanel1.add(jLabel1, new XYConstraints(14, 54, 161, 20));
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
} void jButton1_actionPerformed(ActionEvent e) {
char input = jTextField1.getText().charAt(0);
switch(input){
case 49: jTextField2.setText(new String("ÄúÊäÈëµÄÊÇ1¡£"));break;
case 50: jTextField2.setText(new String("ÄúÊäÈëµÄÊÇ2¡£"));break;
default:
jTextField2.setText(new String("ÄúÊäÈëµÄÊDz»ºÏ·¨µÄÊý×Ö¡£"));break;
case 51:jTextField2.setText(new String("ÄúÊäÈëµÄÊÇ3¡£"));break;
}
}}class AppletTest_jButton1_actionAdapter implements java.awt.event.ActionListener {
AppletTest adaptee; AppletTest_jButton1_actionAdapter(AppletTest adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
哪位大虾能清楚的说下Applet在浏览器中的显示过程?