标题:关于图的输出问题
只看楼主
不知道二号
Rank: 2
等 级:论坛游民
帖 子:6
专家分:15
注 册:2011-6-19
结帖率:0
 问题点数:0 回复次数:0 
关于图的输出问题
import javax.swing.*;
import java.awt.*;
import java.util.*;
public class experiment_5_23 {

    public static void main(String[] args) {
        // TODO Auto-generated method stub


        final double PI=3.1415926;
        int hour,minute,str=1;
        double hu_hour;
        double hu_Minute;;
        Scanner scanner=new Scanner(System.in);
        do{
            System.out.println("请输入多少点:(0~12):");
            hour=scanner.nextInt();
        }while(hour<0||hour>12);
        
        do{
            System.out.println("请输入多少分钟(0~59):");
            minute=scanner.nextInt();
        }while(minute<0||minute>59);
        
        JFrame win;
        Container contentPane;
        Graphics g;
        
        win=new JFrame("My frist Rectangle");
        win.setSize(300,300);
        win.setLocation(100, 100);
        win.setVisible(true);

        
        contentPane=win.getContentPane();
        g=contentPane.getGraphics();
        
        while(str<100)
        {
            str++;
        g.drawOval(50, 50, 200, 200);
        Point pt=new Point();
        pt.x=150;
        pt.y=150;
        
        g.drawString("12",145,65);
        g.drawString("3",240,150);
        g.drawString("6",150,245);
        g.drawString("9",52,150);
        
        hu_Minute=(double)minute*2*PI/60;
        hu_hour=(hour+(double)minute/60)*2*PI/12;
        g.drawLine(150, 150, (int)(150+75*Math.sin(hu_Minute)), (int)(150-75*Math.cos(hu_Minute)));
        g.drawLine(150, 150, (int)(150+60*Math.sin(hu_hour)), (int)(150-60*Math.cos(hu_hour)));
        
        }
   
    }

}



在我电脑上测试,当str<35时,所画的图一闪而过,当str>35时。图就显示出来,当切换窗口时,图就会不见了。这是不是与系统的刷新周期或软件本身原因。望多位多多帮忙~~~~
搜索更多相关主题的帖子: public double import method minute 
2011-10-16 10:12



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-352572-1-1.html




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

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