java星星图案代码,java星号图形输出

实现星星闪动的java代码

package panel;

网站建设哪家好,找创新互联!专注于网页设计、网站建设、微信开发、重庆小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了博罗免费建站欢迎大家使用!

import java.awt.Color;

import java.awt.Font;

import java.awt.Graphics;

import javax.swing.JPanel;

import main.MainTank;

public class TipPanel extends JPanel implements Runnable{

/**

*

*/

private static final long serialVersionUID = 1L;

//偶数打印,画面板

int time=0;

public void paintComponent(Graphics g){

super.paint(g);

g.fillRect(0, 0, MainTank.getWidthOfGame(), MainTank.getHeightOfGame());//绘制提示窗口

if (time%2==0){//偶数打印,画面板,造成闪烁效果

g.setColor(Color.ORANGE);

Font font=new Font("华文楷体",Font.BOLD,30);

g.setFont(font);//选用字体

g.drawString("Ready", 140, 130);

}

}

@Override

public void run() {

while (true){

try{

Thread.sleep(250);

}catch (Exception e){

e.getMessage();

}

time++;//绘图开关

this.repaint();

}

}

}//TipPanel

类似的,修改下就行

java打印星星图案的

public class Test4 {

public static void main(String[] args) {

for(int i=1;i=9;i++){

if(i=5){

for(int j=1;j=i*2-1;j++){

System.out.print("*");

}

}

if(i5i=9){

for(int j=9;j=(i-5)*2+1;j--)

System.out.print("*");

}

System.out .println();

}

}

}

用Java语言打星星

第一个的代码如下,可以改变i的数值来控制X形状的大小

class Test

{

public static void main(String[] args)

{

int i=3;

int j=i*2-1;

int k,l;

for(;j0;j--)

{

k=(i-1)-Math.abs(j-i);

l=Math.abs(j-i)*2-1;

for(;k0;k--)

{

System.out.print(" ");

}

System.out.print("*");

if(l0)

{

for(;l0;l--)

{

System.out.print(" ");

}

System.out.print("*");

}

System.out.print("\n");

}

}

}

你第二个我也没看明白,不过思路应该都差不多,你根据这一个自己琢磨琢磨吧,关键问题就在k和l的计算上.

页面特效:下星星的代码(JAVA代码)

以下的代码就可以,lz自己在*的地方填入星星的图片就可以了

body bgcolor=#ee3300

style

.drop { position: absolute; width: 3; filter: flipV(), flipH(); font-size: 40; color: #ffffff }

/style

script language="javascript"

snow = false; // false-rain; true-snow

snowsym = " * " are the symbols for each

rainsym = " * " can put images here.

howmany = 20 many drops/snowflakes?

/**************Do not need to change anything below***********/

if(snow){sym = snowsym; speed=1; angle=10; drops=howmany}

else{sym = rainsym; speed=30; drops=howmany; angle=6}

movex = -speed/angle; movey = speed; count = 0;

function moverain(){

for(move = 0; move drops; move++){

xx[move]+=movex; yy[move]+=mv[move];

hmm = Math.round(Math.random()*1);

if(xx[move] 0){xx[move] = maxx+10;}

if(yy[move] maxy){yy[move] = 10;}

drop[move].left = xx[move]

drop[move].top = yy[move]+document.body.scrollTop;

}setTimeout('moverain()','1')}

/script

script language="javascript"

if (document.all){

drop = new Array(); xx = new Array(); yy = new Array(); mv = new Array()

ly = "document.all[\'"; st = "\'].style"

for(make = 0; make drops; make++){

document.write('div id="drop'+make+'" class=drop'+sym+'/div');

drop[make] = eval(ly+'drop'+make+st);

maxx = document.body.clientWidth-40

maxy = document.body.clientHeight-40

xx[make] = Math.random()*maxx;

yy[make] = -100-Math.random()*maxy;

drop[make].left = xx[make]

drop[make].top = yy[make]

mv[make] = (Math.random()*5)+speed/16;

drop[make].fontSize = (Math.random()*10)+20;

if(snow){col = 'white'}else{col = 'white'}

drop[make].color = col;

}

window.onload=moverain

}

/script

/body


当前标题:java星星图案代码,java星号图形输出
分享网址:http://pwwzsj.com/article/dsigoss.html