This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes HTML, CSS and JavaScript and the fly likes How to create scrolling text? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to create scrolling text?" Watch "How to create scrolling text?" New topic
Author

How to create scrolling text?

Yatin Shah
Ranch Hand

Joined: Sep 11, 2004
Posts: 72
Hello guys,

I would like to create code which will scroll any text message input by user. Any one can help me? Please check my code as follow:

[jspcode]
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Entry Form</h1>
<form name="Name Input Form" action="response.jsp">
Enter Your Name:
<input type="text" name="name" />
<input type="submit" value="OK" />
</form>
</body>
</html>
[/jspcode]

[jspcode]
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<jsp:useBean id="mybean" scope="session" class="org.mypackage.web.MyWeb" />
<jsp:setProperty name="mybean" property="name" />

<!-- HTML codes by Quackit.com -->
<marquee behavior="scroll" direction="left">
<h1>Hello, <jsp:getProperty name="mybean" property="name" />!</h1>
</marquee>

</body>
</html>
[/jspcode]

[javacode]
public class MyWeb {

private String name;

public MyWeb()
{
name=null;
}

/**
* @return the name
*/
public String getName() {
return name;
}

/**
* @param name the name to set
*/
public void setName(String name) throws Exception{
this.name = name;

while(true){
System.out.print("\r"+ name);
Thread.sleep(200);
name = name.substring(1) + name.substring(0,1);
}
}
}
[/javacode]

[javacode]

Thaning You,
Yatin Shah
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to create scrolling text?