2017-07-27
Java画手机该如何编程呢?
代码如下:import java。awt。*;
import java。applet。*;
public class JavaPhone extends Applet
{
String str;
int x, y, ScrX, ScrY, KeyX, KeyY;
Image img;
public void init()
{
x=20; y=20;
ScrX=45; ScrY=72;
KeyX=45; KeyY=350;
img = getImage(getCodeBase(), "ScreenPic。 jpg");
}
public void paint(Graphics g)
{
/...全部
代码如下:import java。awt。*;
import java。applet。*;
public class JavaPhone extends Applet
{
String str;
int x, y, ScrX, ScrY, KeyX, KeyY;
Image img;
public void init()
{
x=20; y=20;
ScrX=45; ScrY=72;
KeyX=45; KeyY=350;
img = getImage(getCodeBase(), "ScreenPic。
jpg");
}
public void paint(Graphics g)
{
/*Background*/
g。setColor(new Color(60,60,60));
g。fillRoundRect(x, y, 250, 500, 50,50);
g。
setColor(new Color(0,0,0));
g。fillRoundRect(x+7, y+7, 235, 485, 30, 30);
/*white light*/
int[] v = {31,31,33,37,47,37,35};
int[] w = {50,38,33,31,31,35,37};
g。
setColor(new Color(255,255,255));
g。fillPolygon(v, w, v。length);
/*Nokia N73*/
Font f=new Font("Arial Black", Font。
PLAIN, 12);
g。setFont(f);
g。setColor(new Color(255,255,255));
g。drawString("NOKIA", x+25, y+28);
Font f1=new Font("Arial", Font。
PLAIN, 12);
g。setFont(f1);
g。drawString("N73", x+48, y+40);
/*3G Camera*/
g。setColor(new Color(255,255,255));
g。
fillRoundRect(x+175, y+15, 30, 30, 10, 10);
g。setColor(new Color(60,60,60));
g。fillRoundRect(x+177, y+17, 26, 26, 10, 10);
g。
setColor(new Color(0,0,0));
g。fillOval(x+185, y+25, 10, 10);
/*ear speaker*/
g。setColor(new Color(80,80,80));
g。
drawRoundRect(115, 43, 50, 15, 15, 15);
g。setColor(new Color(255,255,255));
g。fillRoundRect(121, 47, 38, 8, 10, 10);
/*Blue Light*/
g。
setColor(new Color(0,0,255));
g。fillRoundRect(x+158, y+24, 12, 12, 3, 3);
g。setColor(new Color(255,255,255));
g。
drawLine(x+160, y+29, x+160, y+26);
g。drawLine(x+160, y+26, x+161, y+25);
g。drawLine(x+161, y+25, x+164, y+25);
/*Key*/
g。
setColor(new Color(120,120,120));
g。drawRoundRect(KeyX, KeyY, 197, 150, 25, 30);
/*Uper Key Area*/
g。
setColor(new Color(255,255,255));
g。fillRoundRect(KeyX+10, KeyY+8, 177, 40, 20,20);
g。setColor(new Color(220,220,220));
g。
fillRoundRect(KeyX+20, KeyY+12, 157, 32, 10, 20);
g。setColor(new Color(70,70,70));
g。fillRoundRect(KeyX+60, KeyY+15, 80,26, 5, 5);
g。
setColor(new Color(180,180,180));
g。fillRoundRect(KeyX+62, KeyY+17, 76,22, 10, 10);
g。setColor(new Color(250,250,250));
g。
fillRoundRect(KeyX+91, KeyY+18, 20, 20, 5, 5);
g。setColor(new Color(100,100,100));
g。fillRoundRect(KeyX+93, KeyY+20, 16, 16, 4, 4);
g。
setColor(new Color(0,0,0));
g。fillRect(KeyX+10, KeyY+28, 81, 2);
g。fillRect(KeyX+111, KeyY+28, 76, 2);。
收起