try use appletviewer you.html

解决方案 »

  1.   

    为什么我用appletviewer试了试,怎么老是提示 "未初始化applet小程序"啊?
    哪位阿牛哥肯帮一帮!!!
      

  2.   

    怎么个初始化法
    我的html里面是这样写的:
    <html>
    <applet code="Welcome1.class" width =600 height=600>
    </applet>
    </html>
    而且我执行javac Welcome1.java时是没有问题的
    救命啊
      

  3.   

    //我知道了,你的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";