ch16l03.txt

来自「《Web编程专家指南》」· 文本 代码 · 共 35 行

TXT
35
字号
Listing 16.3 PopDial class.import java.awt.*;class PopDial extends Dial    {        public PopDial(String aName, int aLowVal, int aHighVal,                       int aTicksEvery, long aSweepTime, Color fColor){            super(aName, aLowVal, aHighVal, aTicksEvery, aSweepTime, fColor);        }        public void paint(Graphics g){            Rectangle myExtent = this.bounds();            g.drawOval(0, 0, myExtent.width, myExtent.height);            if(flash == true){                long curTime = java.lang.System.currentTimeMillis();                long millisSince = curTime - 836327000000L;                long population = millisSince / sweepTime + 265232323;                String myLabel = "U.S. Pop: " + population;                g.setColor(flashColor);                g.fillOval(0, 0, myExtent.width, myExtent.height);                g.setColor(Color.black);                g.drawString(myLabel, 0, myExtent.height / 2);                System.out.println(myLabel);                flash = false;            }else{                //convert percent done into an arc...                int arcDegrees = (int) (percent * 360);                g.fillArc(0, 0, myExtent.width, myExtent.height, 90,                          arcDegrees);            }        }    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?