初学,小题,在线等。。

来源:百度知道 编辑:UC知道 时间:2024/05/18 09:23:14
编写一个 JAVA APPLET,该程序请求用户输入圆的半径,然后显示该圆的直径,周长,面积。。

你要的是Applet小程序,所以要建个html文件或者在appletviewer.exe 上运行才可以.而且你要有界面的输入,所以你要的一个是JApplet吧?
import javax.swing.*;
import java.awt.*;

public class MyJApplet extends JApplet {
private JButton jButton1;
private JEditorPane jEditorPane1;
private JLabel jLabel1;
private JLabel jLabel2;
private JScrollPane jScrollPane1;
private JTextField jTextField1;
public void init() {
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
public void run() {
initComponents();
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
private void initComponents() {
jLabel1 = new JLabel();
jTextField1 = new JTextField("请输入圆的半径");
jButton1 = new JButton();
jEditorPane1 = new JEditorPane();