
正文
java特效代码免费下载 java图像特效
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
JS特效代码--一个很Cool的JS菜单效果
script
function CoolMenuControl(){
// 常规变量 this lastScrollX= ; this lastScrollY= ; this lastScrollW= ; this lastScrollH= ; this td_X= ; this td_Y= ; this td_W= ; this td_H= ; this td= ; this mouseon= ; this current=null this _name; this table_name; this menudiv_name; this menutable_name; this ml= ; this menuarray=new Array(); this speed; this href="";
// 菜单项目 function menuitem(type value url target){ this type=type this value=value this url=url this target=target }
// 插入菜单 this insertmenu=function(type value url target){ this menuarray[this menuarray length]=new menuitem(type value url target) }
// 程序初试化 this init=function(name bdc bgc speed Alpha){ var in="" var cellcount= var lastcellcount= this _name=name+"" this table_name=name+"table" this menudiv_name=name+"menudiv" this menutable_name=name+"menutable" this speed=speed
for (i= ;ithis menuarray length;i++) { if (this menuarray[i] type==" ") cellcount=cellcount+ if (this menuarray[i] type==" " || this menuarray[i] type==" ") {cellcount= } if (lastcellcountcellcount) {lastcellcount++} }
//alert(cellcount)
stylecode="cursor:hand;filter:Alpha(style= opacity="+Alpha+");background color:"+bgc
suspendcode="DIV id="+this _name+" style= POSITION:absolute; onclick= "+name+" doClick() " +"table id="+this table_name+" border= width= cellspacing= style= border collapse: collapse bordercolor= "+bdc+" " +"trtd height= style= "+stylecode+" /td/tr/table/div"; document write(suspendcode); var fcell=true for (i= ;ithis menuarray length;i++) { switch(this menuarray[i] type) { case " ": t=cellcount* if (t= ) { in+= trtd colspan= class=ht onmouseover= +name+ href=" +this menuarray[i] url+ +this menuarray[i] target+ " +this menuarray[i] value } else { in+= trtd colspan= +t+ class=ht onmouseover= +name+ href=" +this menuarray[i] url+ +this menuarray[i] target+ " +this menuarray[i] value } fcell=true break; case " ": t=(cellcount )* if (t= ) { in+= trtd width= td onmouseover= +name+ href=" +this menuarray[i] url+ +this menuarray[i] target+ " +this menuarray[i] value } else { in+= trtd width= td colspan= +t+ onmouseover= +name+ href=" +this menuarray[i] url+ +this menuarray[i] target+ " +this menuarray[i] value } fcell=true break; case " ": if (fcell) { in+= trtd width= td onmouseover= +name+ href=" +this menuarray[i] url+ +this menuarray[i] target+ " +this menuarray[i] value; fcell=false } else { in+= td width= td onmouseover= +name+ href=" +this menuarray[i] url+ +this menuarray[i] target+ " +this menuarray[i] value; } break; } } in= div id= +this menudiv_name+ onmousemove=" +name+ doOver()" + table id= +this menutable_name+ border= cellpadding=" " class="menu" cellspacing=" " +in + /table/div ; //alert(in) document write(in);
this lastScrollX= ; this lastScrollY= ; this posXY(eval(this menutable_name) cells[ ]) this td_W=eval(this menutable_name) cells[ ] scrollWidth+ this td_H=eval(this menutable_name) cells[ ] scrollHeight setInterval(name+" scrollback()" ) }
// 单击超连接 this doClick=function(){ //alert(this url) var url=this href split(" ") //alert(url[ ]) //alert(url[ ]) if (url[ ]=="") return
if (url[ ]=="_blank") {window open(url[ ])} else {location href=url[ ]} }
// 滑动处理 this scrollback=function(){ diffX=this td_X diffY=this td_Y diffW=this td_W diffH=this td_H percentX=this speed*(diffX this lastScrollX); percentY=this speed*(diffY this lastScrollY); percentW=this speed*(diffW this lastScrollW); percentH=this speed*(diffH this lastScrollH);
if(percentX )percentX=Math ceil(percentX); else percentX=Math floor(percentX); if(percentY )percentY=Math ceil(percentY); else percentY=Math floor(percentY); if(percentW )percentW=Math ceil(percentW); else percentW=Math floor(percentW); if(percentH )percentH=Math ceil(percentH); else percentH=Math floor(percentH);
eval(this _name) style pixelTop+=percentY; eval(this _name) style pixelLeft+=percentX; eval(this table_name) style pixelWidth+=percentW; eval(this table_name) style pixelHeight+=percentH;
this lastScrollX=this lastScrollX+percentX; this lastScrollY=this lastScrollY+percentY; this lastScrollW=this lastScrollW+percentW; this lastScrollH=this lastScrollH+percentH; }
// 滑出 this doOver=function() { if (event srcElement tagName=="TD") { if (event srcElement innerText length== || event srcElement innerText=="|") return this posXY(event srcElement) this td_W=event srcElement scrollWidth+ this td_H=event srcElement scrollHeight } }
// 绝对定位 this posXY=function(obj){ _left=obj offsetLeft _top=obj offsetTop vParent = obj offsetParent; while (vParent tagName toUpperCase() != "BODY") { _left += vParent offsetLeft; _top += vParent offsetTop; vParent = vParent offsetParent; } this td_X=_left this td_Y=_top }
// 关于 this about=function(){ alert("OK") }
} /script
head meta equiv="Content Language" content="zh cn" style b{color=# ;cursor:hand} menu { font family:Arial; cursor:Default; font size: px; border: px # solid; border collapse: collapse; filter:progid:DXImageTransform Microsoft Gradient(gradienttype= startcolorstr=#ffffff endcolorstr=#dddddd) progid:DXImageTransform Microsoft Shadow(direction= color=#cccccc strength= ); } ht{ font weight:bold } /style ! 第一步 实体化X Menu类 用法: var 实体变量 new CoolMenuControl() script language="javascript" var CoolMenu =new CoolMenuControl() var about=new Array() about[ ]="关于X Menu菜单nnAuthor:PuterJamnCopyright n转载请通知本人" about[ ]="关于作者nn"这家伙很懒 什么也没留下!!"
/script /head body ! 第二步 建立菜单项目 用法: 实体变量 insertmenu(类型 Html代码 链接网址 目标) 类型 0代表菜单标题 1代表树型菜单子项目 2代表横向菜单子项目 Html代码 显示在菜单上的Html代码 链接网址 不用多说了 网址或Javascript脚本 目标 默认为空 既不在本页打开 "_blank"代表在新的页面打开 例如: CoolMenu insertmenu(" " "img src=// blueidea /img/icon/arrow gif 新浪网" " "_blank") script CoolMenu insertmenu(" " "本站首页" "" "") CoolMenu insertmenu(" " "新闻中心" " "_blank") CoolMenu insertmenu(" " "文章中心" " "_blank") CoolMenu insertmenu(" " "图片欣赏" " "_blank") CoolMenu insertmenu(" " "软件下载" " "_blank") CoolMenu insertmenu(" " "娱乐欣赏" " "_blank") /script
lishixinzhi/Article/program/Java/JSP/201311/19958
相关问答
Q1: 求java公告栏特效代码
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Test{
private JFrame frame;
private String scrolledText;
private String str ="滚动文字 Demo";
public static void main(String args[]) {
try{
Test window = new Test();
window.frame.setVisible(true);
}
catch(Exception e){
e.printStackTrace();
}
}
public Test(){
initialize();
}
private void initialize(){
frame.setBounds(100, 100, 500, 375);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JPanel panel = new JPanel();
panel.setBackground(Color.WHITE);
panel.setLayout(new BorderLayout());
frame.getContentPane().add(panel, BorderLayout.NORTH);
final JLabel label = new JLabel();
label.setText("New JLabel");
panel.add(label);
label_scrolledText(label);
frame.addComponentListener(
new ComponentAdapter(){
public void componentResized(ComponentEvent arg0){
label_scrolledText(label);
}
});
}
public void label_scrolledText(JLabel label) {
this.scrolledText = this.str;
label.setText(scrolledText);
FontMetrics metrics = label.getFontMetrics(label.getFont());
int textW = metrics.stringWidth(label.getText());
Dimension frameSize = frame.getSize();
for (int i = 1; i = (frameSize.width - textW) / 3 - 3; i++)
scrolledText += " ";
label.setText(scrolledText);
Thread thread = new Thread(new TextChanger(label));
thread.start();
}
}
java.lang.NullPointerException
at Test.initialize(Test.java:26)
at Test.init(Test.java:23)
at Test.main(Test.java:16)
Q2: 跨年特效代码
package love;import java.applet.Applet;import java.awt.Color;import java.awt.Graphics;import java.net.URL;import java.util.Random;/*** 烟花* @author enjoy**/@SuppressWarnings("serial")public class Q extends Applet implements Runnable {public int speed, variability, Max_Number, Max_Energy, Max_Patch,Max_Length, G;public String sound;private int width, height; private Thread thread = null; private BeaClassDemo bcd[]; public void init() { int i;this.setSize(1900, 900); width = getSize().width - 1;height = getSize().height - 1;speed = 1; // 烟花绽放的速度variability = 10;Max_Number = 980; // 可发出烟花的最大数目Max_Energy = width + 50;Max_Patch = 90; // 最大的斑点数Max_Length = 90; // 斑点的最大距离G = 150; // 向地面弯曲的力度bcd = new BeaClassDemo[Max_Number]; for (i = 0; i Max_Number; i++)bcd[i] = new BeaClassDemo(width, height, G); }public void start() { if (thread == null) {thread = new Thread(this);thread.start();}}@SuppressWarnings("deprecation")public void stop() { if (thread != null) {thread.stop();thread = null;}}@SuppressWarnings({ "unused", "static-access" })public void run() {int i;int E = (int) (Math.random() * Max_Energy * 3 / 4) + Max_Energy / 4 + 1;int P = (int) (Math.random() * Max_Patch * 3 / 4) // 烟花的斑点数+ Max_Patch / 4 + 1;int L = (int) (Math.random() * Max_Length * 3 / 4) // 烟花可发射出的距离+ Max_Length / 4 + 1;long S = (long) (Math.random() * 10000); boolean sleep; Graphics g = getGraphics();URL u = null;while (true) {try {thread.sleep(1000 / speed);} catch (InterruptedException x) {}sleep = true;for (i = 0; i Max_Number; i++)sleep = sleep bcd[i].sleep;if (sleep Math.random() * 100 variability) {E = (int) (Math.random() * Max_Energy * 3 / 4) + Max_Energy / 4+ 1;P = (int) (Math.random() * Max_Patch * 3 / 4) + Max_Patch / 4+ 1;L = (int) (Math.random() * Max_Length * 3 / 4) + Max_Length / 4+ 1;S = (long) (Math.random() * 10000);}for (i = 0; i Max_Number; i++) {if (bcd[i].sleep Math.random() * Max_Number * L 1) {bcd[i].init(E, P, L, S);bcd[i].start();}bcd[i].show(g);}}}public void paint(Graphics g) { g.setColor(Color.black); g.fillRect(0, 0, width + 1, height + 1); }}class BeaClassDemo {public boolean sleep = true;private int energy, patch, length, width, height, G, Xx, Xy, Ex[], Ey[], x,y, Red, Blue, Green, t;private Random random; public BeaClassDemo(int a, int b, int g) { width = a;height = b;G = g;}public void init(int e, int p, int l, long seed) {int i;energy = e;patch = p;length = l;// 创建一个带种子的随机数生成器random = new Random(seed);Ex = new int[patch]; Ey = new int[patch]; Red = (int) (random.nextDouble() * 128) + 128;Blue = (int) (random.nextDouble() * 128) + 128;Green = (int) (random.nextDouble() * 128) + 128;Xx = (int) (Math.random() * width / 2) + width / 4;Xy = (int) (Math.random() * height / 2) + height / 4;for (i = 0; i patch; i++) {Ex[i] = (int) (Math.random() * energy) - energy / 2;Ey[i] = (int) (Math.random() * energy * 7 / 8) - energy / 8;
回答于 2023-02-22
向TA提问
官方服务
官方网站
官方网站
关于java特效代码免费下载和java图像特效的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。






