帮我看看这个...... 把代码帖出来,给分:你点管理就可以了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 package untitled1;import java.awt.*;import java.awt.event.*;import java.applet.*;import com.borland.jbcl.layout.*;public class valia extends Applet { boolean flag = false,flag1 = false,flag2 = false; double num; boolean isStandalone = false; TextField text1 = new TextField(); XYLayout xYLayout1 = new XYLayout(); Label label1 = new Label(); Checkbox checkbox1 = new Checkbox(); Checkbox checkbox2 = new Checkbox(); Label label2 = new Label(); /**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 valia() { } /**Initialize the applet*/ public void init() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } /**Component initialization*/ private void jbInit() throws Exception { text1.setFont(new java.awt.Font("Dialog", 0, 16)); text1.setText("0"); text1.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(FocusEvent e) { text1_focusLost(e); } }); this.setLayout(xYLayout1); label1.setFont(new java.awt.Font("Dialog", 0, 16)); label1.setText("输入数据"); checkbox1.setLabel("双精度"); checkbox1.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(ItemEvent e) { checkbox1_itemStateChanged(e); } }); checkbox2.setLabel("整形"); checkbox2.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(ItemEvent e) { checkbox1_itemStateChanged(e); } }); label2.setFont(new java.awt.Font("Dialog", 0, 16)); label2.setText("转换成"); this.add(text1, new XYConstraints(156, 70, 80, -1)); this.add(label1, new XYConstraints(50, 70, 80, -1)); this.add(checkbox1, new XYConstraints(155, 114, 72, 27)); this.add(checkbox2, new XYConstraints(155, 152, 69, 25)); this.add(label2, new XYConstraints(50, 110, 83, 27)); } /**Get Applet information*/ public String getAppletInfo() { return "Applet Information"; } /**Get parameter info*/ public String[][] getParameterInfo() { return null; } void text1_focusLost(FocusEvent e) { String str = text1.getText() ; if (str!=null){ try{ num = Double.parseDouble(str); flag = true; } catch(Exception ex){} } repaint(); } public void paint(Graphics g){ if(flag){ if (checkbox1.getState()){ g.drawString(String.valueOf(num),100,200); } if (checkbox2.getState()){ g.drawString(String.valueOf((int)(num)),100,250); } } } void checkbox1_itemStateChanged(ItemEvent e) { repaint(); }} 匿名内部类问题 用java制作一个词法分析器? 用itext生成pdf时,用哪个函数精确定位待输入汉字的开始位置呢? 在java中怎么样获取鼠标左键!如何将物体旋转后的效果在相同位置显示出来?(图形是三维) 寻求数据结构和算法(Java实现)电子书 如果我一个类即想继承JApplet的方法,有希望有thread的方法。我改怎么办?(初学者) 在java中如何设置本地的时间? 文件传输 what is Bean? 数据传递问题? JAVA application 有什么用? jdk问题
import java.awt.event.*;
import java.applet.*;
import com.borland.jbcl.layout.*;public class valia extends Applet {
boolean flag = false,flag1 = false,flag2 = false;
double num;
boolean isStandalone = false;
TextField text1 = new TextField();
XYLayout xYLayout1 = new XYLayout();
Label label1 = new Label();
Checkbox checkbox1 = new Checkbox();
Checkbox checkbox2 = new Checkbox();
Label label2 = new Label();
/**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 valia() {
}
/**Initialize the applet*/
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
/**Component initialization*/
private void jbInit() throws Exception {
text1.setFont(new java.awt.Font("Dialog", 0, 16));
text1.setText("0");
text1.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(FocusEvent e) {
text1_focusLost(e);
}
});
this.setLayout(xYLayout1);
label1.setFont(new java.awt.Font("Dialog", 0, 16));
label1.setText("输入数据");
checkbox1.setLabel("双精度");
checkbox1.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(ItemEvent e) {
checkbox1_itemStateChanged(e);
}
}); checkbox2.setLabel("整形");
checkbox2.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(ItemEvent e) {
checkbox1_itemStateChanged(e);
}
}); label2.setFont(new java.awt.Font("Dialog", 0, 16));
label2.setText("转换成");
this.add(text1, new XYConstraints(156, 70, 80, -1));
this.add(label1, new XYConstraints(50, 70, 80, -1));
this.add(checkbox1, new XYConstraints(155, 114, 72, 27));
this.add(checkbox2, new XYConstraints(155, 152, 69, 25));
this.add(label2, new XYConstraints(50, 110, 83, 27));
}
/**Get Applet information*/
public String getAppletInfo() {
return "Applet Information";
}
/**Get parameter info*/
public String[][] getParameterInfo() {
return null;
}
void text1_focusLost(FocusEvent e) {
String str = text1.getText() ;
if (str!=null){
try{
num = Double.parseDouble(str);
flag = true;
}
catch(Exception ex){}
}
repaint();
}
public void paint(Graphics g){
if(flag){
if (checkbox1.getState()){
g.drawString(String.valueOf(num),100,200);
}
if (checkbox2.getState()){
g.drawString(String.valueOf((int)(num)),100,250);
}
}
} void checkbox1_itemStateChanged(ItemEvent e) {
repaint();
}
}