我的简单的程序为什么不能显示 try use appletviewer you.html 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 为什么我用appletviewer试了试,怎么老是提示 "未初始化applet小程序"啊?哪位阿牛哥肯帮一帮!!! 怎么个初始化法我的html里面是这样写的:<html><applet code="Welcome1.class" width =600 height=600></applet></html>而且我执行javac Welcome1.java时是没有问题的救命啊 //我知道了,你的enter对象没有初始化。//全部如下:import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.text.*; public class Welcoml extends JApplet implements ActionListener { JLabel enterLabel,resultLabel; JTextField enter,result; JTextArea output; int a[]; String display = ""; public void init() { Container c = getContentPane(); c.setLayout(new FlowLayout()); enterLabel = new JLabel("Enter key"); c.add(enterLabel); enter = new JTextField(22);enter.addActionListener(this); c.add(enter) ; resultLabel = new JLabel ("Result"); c.add(resultLabel); result = new JTextField(22); result.setEditable(false); c.add(result); output = new JTextArea(6,60); output.setFont (new Font ("Courier",Font.PLAIN,12)); c.add(output); a = new int[15]; for (int i = 0 ; i<a.length;i++) a[i] = 2 * i; } public void actionPerformed(ActionEvent e) { String searchKey = e.getActionCommand(); display = "Portions of array searched\n"; int element = binarySearch (a,Integer.parseInt(searchKey)); output.setText (display); if (element != -1) result.setText("Found value in element "+ element); else result.setText ("Value not found"); } public int binarySearch (int array[],int key) { int low = 0 ; int high = array.length +1 ; int middle; while (low <= high) { middle = (low + high) /2; buildOutput (low,middle,high); if (key == array[middle]) return middle; else if (key < array[middle]) high = middle - 1; else low = middle +1; } return -1; } void buildOutput (int low,int mid,int high) { DecimalFormat twoDigits = new DecimalFormat("00"); for (int i = 0 ; i < a.length;i++) { if (i < low || i > high) display += " "; else if (i == mid) display += twoDigits.format(a[i]) + "*"; else display += twoDigits.format(a[i]) + ""; } display += "\n"; } } VE 这是神马情况? 问一个关于list的问题 JSP的一种实现 随机函数,看看是否有问题?? 关于JAVA中static的一个问题 StringBuffer与String有什么不同么 求教!!!!!!!!! URLConnection 问题?请熟悉的一定帮忙! 如何将jar文件编译为exe 文件 关于 Java 初始化对象顺序的问题 一个好好玩的东西 求助,在LINUX下不能使用JDK。请帮助,万分感谢!
哪位阿牛哥肯帮一帮!!!
我的html里面是这样写的:
<html>
<applet code="Welcome1.class" width =600 height=600>
</applet>
</html>
而且我执行javac Welcome1.java时是没有问题的
救命啊
//全部如下:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.*; public class Welcoml extends JApplet implements ActionListener
{
JLabel enterLabel,resultLabel;
JTextField enter,result;
JTextArea output; int a[];
String display = ""; public void init()
{
Container c = getContentPane();
c.setLayout(new FlowLayout()); enterLabel = new JLabel("Enter key");
c.add(enterLabel); enter = new JTextField(22);
enter.addActionListener(this);
c.add(enter) ; resultLabel = new JLabel ("Result");
c.add(resultLabel); result = new JTextField(22);
result.setEditable(false);
c.add(result); output = new JTextArea(6,60);
output.setFont (new Font ("Courier",Font.PLAIN,12));
c.add(output); a = new int[15]; for (int i = 0 ; i<a.length;i++)
a[i] = 2 * i;
}
public void actionPerformed(ActionEvent e)
{
String searchKey = e.getActionCommand(); display = "Portions of array searched\n"; int element = binarySearch (a,Integer.parseInt(searchKey)); output.setText (display); if (element != -1)
result.setText("Found value in element "+ element);
else
result.setText ("Value not found");
} public int binarySearch (int array[],int key)
{
int low = 0 ;
int high = array.length +1 ;
int middle; while (low <= high)
{
middle = (low + high) /2; buildOutput (low,middle,high); if (key == array[middle])
return middle;
else if (key < array[middle])
high = middle - 1;
else
low = middle +1;
}
return -1;
} void buildOutput (int low,int mid,int high)
{
DecimalFormat twoDigits = new DecimalFormat("00"); for (int i = 0 ; i < a.length;i++)
{
if (i < low || i > high)
display += " ";
else if (i == mid)
display += twoDigits.format(a[i]) + "*";
else
display += twoDigits.format(a[i]) + "";
}
display += "\n";
}
}