Click here to Skip to main content
15,886,574 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my program. I make program for Marquee but What else I have to add.......

Java
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Twoo extends Frame implements Runnable
{
	private int x;
	private int y;
	Thread t1;
	public Twoo(String title)
	{
		super(title);
		t1 = new Thread(this,"thread1");
		t1.start();
		x=590;
		y=0;
	}
	public void run()
	{
		while (true)
		{
			try
			{ 	x--;	
				y++;
				Thread.sleep(10);
				repaint();
				if(x==0 && y==590){
					
					for(int i=0 ; i< 590;i++){
						x++;
						y--;
						Thread.sleep(10);
						repaint();
						
					}

				}
				

			}
			catch (InterruptedException ie)
			{
				ie.printStackTrace();
			}
			
		}
	}
	public void paint(Graphics g)
	{
		g.setColor(Color.blue);
		g.setFont(new Font("Arial",Font.BOLD|Font.ITALIC,20));
		g.drawString("Mumbai, Rohan Maharashtra",x,300);
		g.drawString("Mumbai, Maharashtra",y,300);
		g.drawString("Mumbai, Maharashtra",200,x);
		g.drawString("Mumbai, Maharashtra",200,y);

	}
	public static void main(String[] args) 
	{
		Frame f=new TwoString("My Thread Frame");
		f.setSize(800,500);
		f.setVisible(true); 
	}
		
}


What I have tried:

I tried to make a text to scroll from left to right by marquee, but I want to stop it when mouse move on it.
Posted
Updated 7-Apr-16 2:22am

1 solution

You need to add a MouseListener, see jframe mouselistener - Google Search[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900