| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 888 人关注过本帖
标题:关于paint方法里不能输出变量的问题
取消只看楼主 加入收藏
想你的天空
Rank: 2
等 级:新手上路
威 望:5
帖 子:610
专家分:0
注 册:2004-12-30
收藏
 问题点数:0 回复次数:0 
关于paint方法里不能输出变量的问题
import java.awt.Graphics ;
import javax.swing.JApplet ;
import javax.swing.JOptionPane;
public class Float2 extends JApplet{
 public void init()
 {
  String firstNumber;
  String secondNumber;
  String thirdNumber;
  float   first;
  float   second;
  float   third;
  float   sum,average,mul,max,min;
  firstNumber = JOptionPane.showInputDialog("Enter first number");
  secondNumber = JOptionPane.showInputDialog("Enter second number");
  thirdNumber = JOptionPane.showInputDialog("Enter third number");
  
  first = Float.parseFloat(firstNumber);
  second = Float.parseFloat(secondNumber);
  third = Float.parseFloat(thirdNumber);
  sum = first + second + third;
  average = sum/3;
  
     if((second>first)&&(second>third))  max = second ;
       else if((second>first)&&(second<third))  max = third ;
      else max = first ;
     
     if((second<first)&&(second<third))  min = second ;
       else if((second<first)&&(second>third)) min = third ;
      else min = first ;   
      mul = first * second * third ;
      
      String str = new String("max = " + max + "\nmin = " + min + "\naverage = "+average + "\nmul = "+ mul);
        //String title = "VC++.NET";
        //JOptionPane.showMessageDialog(null,str,title,JOptionPane.PLAIN_MESSAGE);
     }
     public void paint(Graphics g)
     {
      super.paint(g);
      g.draw3DRect(15,10,270,60,true);
      g.drawString(str,25,25);  ////编译器致使 str 出错, 我改个 “ abc” 就可以运行输出
        System.exit(0);
  }
}
搜索更多相关主题的帖子: 变量 paint 输出 
2005-09-20 09:20
快速回复:关于paint方法里不能输出变量的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015940 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved