Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Add a pause/resume button to the Welcome Students that will stop/resume the movement of the text. code>>>>>> import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*;

Add a pause/resume button to the Welcome Students that will stop/resume the movement of the text.

code>>>>>>

import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; public class WelcomeStudents extends JFrame { String welcome = "Welcome"; String students = "Students"; JButton b=new JButton("pause/resume"); int y_welcome = 50; int y_students = 150; int x_welcome = 10; int x_students= 10; int welcome_inc = 1; int students_inc = 1; public WelcomeStudents(){ setSize(250,100); setDefaultCloseOperation(EXIT_ON_CLOSE); add(b,BorderLayout.SOUTH); setVisible(true); b.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ if(e.getSource()==b){ } }}); } public void paint(Graphics g){ super.paint(g); g.setFont(new Font("Times New Roman",Font.BOLD,20)); g.drawString(welcome , y_welcome , x_welcome); g.drawString(students , y_students , x_students); x_welcome = x_welcome + welcome_inc; x_students = students_inc + x_students; if(x_welcome == getWidth()-60 || x_welcome == 0) welcome_inc = welcome_inc* (-1); if(x_students == getWidth()-77 || x_students == 0) x_students = x_students * (-1); try{ Thread.sleep(200); } catch(InterruptedException r){ System.out.println(r.getMessage()); } repaint(); } public static void main(String[]args){ new WelcomeStudents(); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 11G SQL

Authors: Joan Casteel

2nd Edition

1133947360, 978-1133947363

More Books

Students also viewed these Databases questions

Question

I Which of your reasons (if any) were not under your controli>

Answered: 1 week ago