Question

In: Computer Science

Design the following GUI by using swing components: Can you think of changing the Hi positions...

Design the following GUI by using swing components:

Can you think of changing the Hi positions in an horizontal line every two seconds? Write a program that will allow you to change the sentence position horizontally for every 2 seconds. That is, after another 2 seconds, the Hi position should be changed to the following:

This is JAVA please.

the program is the word HI that automatically scrolls accros the screen until the end and then comes back on the left the next line down. and keeps scrolling like that..

Hi

this question I will cancel because I dont need it now Thanks for your response. I will be posting the actual question in about 20 minutes

Solutions

Expert Solution

package Animation;

import java.applet.*;
import java.awt.*;

// Defines class BannerText extends from super class Applet
// and implements Runnable interface
public class BannerText extends Applet implements Runnable
{
   // Assigns a string
   String message = "Pyari Mohan Sahu ";
   // Creates a font class object
   Font f = new Font("Arial", Font.BOLD, 25);
   // Creates a Thread class object
   Thread myThread;
  
   // Overrides init() method to set the background
   // color and applet size
   public void init()
   {
       setForeground(Color.BLUE);
       setSize(230, 200);
   }
  
   // Overrides start() method to create and start the thread
   public void start()
   {
       myThread = new Thread(this);
       myThread.start();
   }
  
   // Overrides run() method to move text
   public void run ()
   {
       char currentChar;
      
       // Loops infinite times
       for( ; ; )
       {
           try
           {
               // Calls the method to repaint() applet area
               repaint();
               // Sleeps for 2 second
               Thread.sleep(2000);
               // Extracts the character at 0th index position
               currentChar = message.charAt(0);
               // Extracts the sub string from 1st index position to last
               message = message.substring(1, message.length());
               // Concatenate the current character at the end of the message
               message += currentChar;
           }
           catch(InterruptedException e) {}
       }
   }
  
   // Overrides paint() method to display the text
   public void paint(Graphics g)
   {
       // Creates a rectangle
       g.fillRect(1,1,230,200);
       // Sets the color of the text to yellow
       g.setColor(Color.YELLOW);
       // Sets the font of the text
       g.setFont(f);
       // Displays the message
       g.drawString(message, 1, 100);
   }
}

Sample Output:


Related Solutions

Apply JavaFX and exception handling to design a CircleApp class using proper JavaFX GUI components, such...
Apply JavaFX and exception handling to design a CircleApp class using proper JavaFX GUI components, such as labels, text fields and buttons(Submit, Clear, and Exit) to compute the area of circle and display the radius user entered in the text field and computing result in a proper location in the application windows. It will also verify invalid data entries for radius(No letters and must be a postive real number) using expection handling. Your code will also have a custom-designed exception...
Hi-Volt Components You are the IT manager at Hi-Voltage Components, a medium-sized firm that makes specialized...
Hi-Volt Components You are the IT manager at Hi-Voltage Components, a medium-sized firm that makes specialized circuit boards. Hi-Voltage's largest customer: Green Industries, recently installed a computerized purchasing system. If Hi-Voltage connects to the purchasing system, Green Industries will be able to submit purchase orders electronically. Although Hi-Voltage has a computerized accounting system, that system is not capable of handling EDI. Tasks 1. What options does Hi-Voltage have for developing a system to connect with Green Industries Purchasing system? 2....
By using javaFX as the GUI, design and implement java based algorithms using appropriate data structures...
By using javaFX as the GUI, design and implement java based algorithms using appropriate data structures for the following problem: Use depth-first search to find paths to all the vertices in a graph that are connected to a given start vertex s. A sample input file containing the number of vertices, number of edges and a list of edges called tinyCG.txt is provided for you to test your program.
You think that a stock price is going to swing into a certain range. Hence, in...
You think that a stock price is going to swing into a certain range. Hence, in order to limit your risk (and your return as well), you decide to buy one put for $7 with exercise price of 110; buy one put for $1 with exercise price of 95; sell one put for $4 with exercise price of 105; and sell one put for $2 with exercise price of $100. (a) What is your maximum profit and maximum loss of...
You think that a stock price is going to swing into a certain range. Hence, in...
You think that a stock price is going to swing into a certain range. Hence, in order to limit your risk (and your return as well), you decide to buy one put for $7 with exercise price of 110; buy one put for $1 with exercise price of 95; sell one put for $4 with exercise price of 105; and sell one put for $2 with exercise price of $100. (a) What is your maximum profit and maximum loss of...
[Design Pattern] Think of a scenario that can be solved using all of these 3 patterns...
[Design Pattern] Think of a scenario that can be solved using all of these 3 patterns - Strategy, Factory and Abstract Factory patterns. 1. Write the Scenario 2. Write the code for the 3 patterns 3. Create the UML diagram
Hi, I'm trying to make a basic GUI quiz in python using tkinter. I would like...
Hi, I'm trying to make a basic GUI quiz in python using tkinter. I would like the user to have to press a start button to begin the quiz and then be asked 5 different questions with the total score showing at the end. Ideally it would be a multiple choice quiz with the user having 4 different answers to choose from. A very basic example of this would be appreciated so I can understand where exactly I'm going wrong....
Provide an example of changing a behavior using the components of the PRECEDE-PROCEED model to improve...
Provide an example of changing a behavior using the components of the PRECEDE-PROCEED model to improve the health of individuals. Hints: 1. Use the 2 attached examples as a guideline. 2. Create a similar example in a different topic - such as smoking, obesity, drug abuse, or any other health issue - to improve the quality of life (at least 400 words)
Do you think certain types of office design can be utilized can be to create a...
Do you think certain types of office design can be utilized can be to create a more ethical or spiritual culture? Why or why not? If you answered yes, how can office design be utilized to create an ethical culture?
You will design and create your own GUI application for the Bank project. This project should...
You will design and create your own GUI application for the Bank project. This project should be designed and written by Java programming. The requirements of the program: 1. The program will be best implemented as a multi-file program for each class. 2. The parameters and return types of each function and class member should be decided in advance. You may need to add more member variables and functions to the classes than those listed below. Also, you can throws...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT