把下面的代码放在 body 标签下,图片路径修改成自己的
平山ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联公司的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:13518219792(备注:SSL证书合作)期待与您的合作!
table width="1024" border="0"
tr
td height="200"DIV id=demo style="OVERFLOW: hidden; WIDTH:1024px; HEIGHT: 200px" align=center
TABLE cellSpacing=0 cellPadding=0 align=left border=0 cellspace="0"
TBODY
TR
TD id=demo1 vAlign=top
table width="1024" border="0" align="center" cellpadding="0" cellspacing="0"
tr
td width="250"img src="images/pic/1.gif" width="250" height="200"/td
td width="250"img src="images/pic/2.gif" width="250" height="200"/td
td width="250"img src="images/pic/3.gif" width="250" height="200"/td
td width="250"img src="images/pic/4.gif" width="250" height="200"/td
td width="250"img src="images/pic/5.gif" width="250" height="200"/td
td width="250"img src="images/pic/6.gif" width="250" height="200"/td
td width="250"img src="images/pic/7.gif" width="250" height="200"/td
td width="250"img src="images/pic/8.gif" width="250" height="200"/td
td width="250"img src="images/pic/9.gif" width="250" height="200"/td
td width="250"img src="images/pic/10.gif" width="250" height="200"/td
/table /TD
TD id=demo2 vAlign=top/TD/TR/TBODY
/TABLE
/DIV
div align="center"
SCRIPT
var speed=1
demo2.innerHTML=demo1.innerHTML
function Marquee(){
if(demo2.offsetWidth-demo.scrollLeft=0)
demo.scrollLeft-=demo1.offsetWidth
else{
demo.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
/SCRIPT
/div
/td
/tr
/table
import java.applet.Applet;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Image;public class Welcome extends Applet {
int pos = 0;
Image graph;
int w=0;
String str = "热烈欢迎2009届新生入学";
Font f = new Font("黑体", Font.BOLD, 20);
public Welcome(){
FontMetrics fm = getFontMetrics(f);
w = fm.stringWidth(str);
pos=w;
}
public void paint(Graphics g) {
g.setFont(f);
g.drawString(str, pos-w, 40);
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
pos = pos + 5;
if (pos-w getWidth())
pos = w;
repaint();
}
}
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JLabel;
import javax.swing.JWindow;
import javax.swing.Timer;
public class Marquee extends JWindow {
public static String marqueeText;
public static Marquee myMarquee = new Marquee("呜呜~,跑马灯动不了了~ ");
public static JLabel myJLabel = new JLabel(myMarquee.toString());
// 实例化,否则nullpoint
public static Point anchor = new Point();
public Marquee(String marquee) {
marqueeText = marquee;
}
public static void main(String[] args) {
Timer marquee = new Timer(100, new ActionListener() {
public void actionPerformed(ActionEvent e) {
Point extSize = myMarquee.getLocation();
Dimension viewSize = myJLabel.getPreferredSize();
anchor.x += 5;// 设置移动的速度
myMarquee.setLocation(anchor);
if (anchor.x viewSize.width) {
anchor.x = -extSize.x;
}
}
});
myJLabel.setForeground(Color.RED);
myJLabel.setOpaque(true);
myJLabel.setPreferredSize(new Dimension(1024, 30));
myMarquee.setVisible(true);
myMarquee.setLocation(0, 0);
myMarquee.setAlwaysOnTop(true);
myMarquee.add(myJLabel);
myMarquee.pack();
// 关键一句,你设置了定时器,但没有让它运行起来,start即可
marquee.start();
}
public String toString() {
return marqueeText;
}
}
把问题分开来解决:
1.跑马灯效果,这个是js范畴,可以找一些js组件或直接用html的marque实现。
2.ajax刷新可以用setIterval实现定时访问,然后把服务端返回数据用js加到页面。
3.java服务端就是从数据库或远程服务获取数据然后组织为xml或json返回给ajax客户端。