SlideShare a Scribd company logo
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class StopWatch extends JPanel
{
private Timer myTimer1;
public static final int ONE_SEC = 1000; //time step in milliseconds
public static final int TENTH_SEC = 100;
private Font myClockFont;
private JButton startBtn, stopBtn, resetBtn;
private JLabel timeLbl;
private JPanel topPanel, bottomPanel;
private int clockTick; //number of clock ticks; tick can be 1.0 s or 0.1 s
private double clockTime; //time in seconds
private String clockTimeString;
public StopWatch()
{
clockTick = 0; //initial clock setting in clock ticks
clockTime = ((double)clockTick)/10.0;
clockTimeString = new Double(clockTime).toString();
myClockFont = new Font("Serif", Font.PLAIN, 50);
timeLbl = new JLabel();
timeLbl.setFont(myClockFont);
timeLbl.setText(clockTimeString);
startBtn = new JButton("Start");
stopBtn = new JButton("Stop");
resetBtn = new JButton("Reset");
myTimer1 = new Timer(TENTH_SEC, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
clockTick++;
clockTime = ((double)clockTick)/10.0;
clockTimeString = new Double(clockTime).toString();
timeLbl.setText(clockTimeString);
//System.out.println(clockTime);
}
});
startBtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
myTimer1.start();
}
});
stopBtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
myTimer1.stop();
}
});
resetBtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
clockTick = 0;
clockTime = ((double)clockTick)/10.0;
clockTimeString = new Double(clockTime).toString();
timeLbl.setText(clockTimeString);
}
});
}//end of StopWatch constructor
public void launchStopWatch()
{
topPanel = new JPanel();
topPanel.setBackground(Color.orange);
bottomPanel = new JPanel();
bottomPanel.setBackground(Color.yellow);
topPanel.add(timeLbl);
bottomPanel.add(startBtn);
bottomPanel.add(stopBtn);
bottomPanel.add(resetBtn);
this.setLayout(new BorderLayout());
add(topPanel, BorderLayout.CENTER);
add(bottomPanel, BorderLayout.SOUTH);
setSize(300,200);
setBackground(Color.orange);
}//end of launchClock
public static void main(String[] args)
{
MyTestFrame myTestFrame1 = new MyTestFrame();
}
}
class MyTestFrame extends JFrame
{
StopWatch StopWatch1;
public MyTestFrame()
{
super("My Stop Watch");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container myPane = getContentPane();
StopWatch1 = new StopWatch();
StopWatch1.launchStopWatch();
myPane.add(StopWatch1);
pack();
setVisible(true);
}
}
Solution
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class StopWatch extends JPanel
{
private Timer myTimer1;
public static final int ONE_SEC = 1000; //time step in milliseconds
public static final int TENTH_SEC = 100;
private Font myClockFont;
private JButton startBtn, stopBtn, resetBtn;
private JLabel timeLbl;
private JPanel topPanel, bottomPanel;
private int clockTick; //number of clock ticks; tick can be 1.0 s or 0.1 s
private double clockTime; //time in seconds
private String clockTimeString;
public StopWatch()
{
clockTick = 0; //initial clock setting in clock ticks
clockTime = ((double)clockTick)/10.0;
clockTimeString = new Double(clockTime).toString();
myClockFont = new Font("Serif", Font.PLAIN, 50);
timeLbl = new JLabel();
timeLbl.setFont(myClockFont);
timeLbl.setText(clockTimeString);
startBtn = new JButton("Start");
stopBtn = new JButton("Stop");
resetBtn = new JButton("Reset");
myTimer1 = new Timer(TENTH_SEC, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
clockTick++;
clockTime = ((double)clockTick)/10.0;
clockTimeString = new Double(clockTime).toString();
timeLbl.setText(clockTimeString);
//System.out.println(clockTime);
}
});
startBtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
myTimer1.start();
}
});
stopBtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
myTimer1.stop();
}
});
resetBtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
clockTick = 0;
clockTime = ((double)clockTick)/10.0;
clockTimeString = new Double(clockTime).toString();
timeLbl.setText(clockTimeString);
}
});
}//end of StopWatch constructor
public void launchStopWatch()
{
topPanel = new JPanel();
topPanel.setBackground(Color.orange);
bottomPanel = new JPanel();
bottomPanel.setBackground(Color.yellow);
topPanel.add(timeLbl);
bottomPanel.add(startBtn);
bottomPanel.add(stopBtn);
bottomPanel.add(resetBtn);
this.setLayout(new BorderLayout());
add(topPanel, BorderLayout.CENTER);
add(bottomPanel, BorderLayout.SOUTH);
setSize(300,200);
setBackground(Color.orange);
}//end of launchClock
public static void main(String[] args)
{
MyTestFrame myTestFrame1 = new MyTestFrame();
}
}
class MyTestFrame extends JFrame
{
StopWatch StopWatch1;
public MyTestFrame()
{
super("My Stop Watch");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container myPane = getContentPane();
StopWatch1 = new StopWatch();
StopWatch1.launchStopWatch();
myPane.add(StopWatch1);
pack();
setVisible(true);
}
}

More Related Content

Similar to import java.awt.; import java.awt.event.; import javax.swing..pdf

Android Architecture Component in Real Life
Android Architecture Component in Real LifeAndroid Architecture Component in Real Life
Android Architecture Component in Real Life
Somkiat Khitwongwattana
 
Chat application in java using swing and socket programming.
Chat application in java using swing and socket programming.Chat application in java using swing and socket programming.
Chat application in java using swing and socket programming.
Kuldeep Jain
 
Lab 1 izz
Lab 1 izzLab 1 izz
Lab 1 izz
Sivanraaj
 
Sumsem2014 15 cp0399-13-jun-2015_rm01_programs
Sumsem2014 15 cp0399-13-jun-2015_rm01_programsSumsem2014 15 cp0399-13-jun-2015_rm01_programs
Sumsem2014 15 cp0399-13-jun-2015_rm01_programs
Abhijit Borah
 
Tdd iPhone For Dummies
Tdd iPhone For DummiesTdd iPhone For Dummies
Tdd iPhone For Dummies
Giordano Scalzo
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
DroidConTLV
 
Android TDD
Android TDDAndroid TDD
Android TDD
Godfrey Nolan
 
The Ring programming language version 1.8 book - Part 88 of 202
The Ring programming language version 1.8 book - Part 88 of 202The Ring programming language version 1.8 book - Part 88 of 202
The Ring programming language version 1.8 book - Part 88 of 202
Mahmoud Samir Fayed
 
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdf
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdfpublic void turnRight(double degrees) {rotationInDegrees + - = deg.pdf
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdf
isenbergwarne4100
 
Infinum iOS Talks #1 - Swift under the hood: Method Dispatching by Vlaho Poluta
Infinum iOS Talks #1 - Swift under the hood: Method Dispatching by Vlaho PolutaInfinum iOS Talks #1 - Swift under the hood: Method Dispatching by Vlaho Poluta
Infinum iOS Talks #1 - Swift under the hood: Method Dispatching by Vlaho Poluta
Infinum
 
CSharp for Unity Day2
CSharp for Unity Day2CSharp for Unity Day2
CSharp for Unity Day2
Duong Thanh
 
Psychtoolbox (PTB) practical course by Volodymyr B. Bogdanov, Lyon/Kyiv 2018...
Psychtoolbox (PTB) practical course  by Volodymyr B. Bogdanov, Lyon/Kyiv 2018...Psychtoolbox (PTB) practical course  by Volodymyr B. Bogdanov, Lyon/Kyiv 2018...
Psychtoolbox (PTB) practical course by Volodymyr B. Bogdanov, Lyon/Kyiv 2018...
Volodymyr Bogdanov
 
Thread
ThreadThread
Thread
phanleson
 
Android TDD & CI
Android TDD & CIAndroid TDD & CI
Android TDD & CI
Marcin Gryszko
 
Implementing STM in Java
Implementing STM in JavaImplementing STM in Java
Implementing STM in Java
Misha Kozik
 
Microkernel Development
Microkernel DevelopmentMicrokernel Development
Microkernel Development
Rodrigo Almeida
 
Proyecto Poogame Tic Tac Toe
Proyecto Poogame Tic Tac ToeProyecto Poogame Tic Tac Toe
Proyecto Poogame Tic Tac Toe
EPN
 
662305 11
662305 11662305 11
import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdf
import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdfimport java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdf
import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdf
adhityalapcare
 
import java.applet.; import java.awt.; import java.awt.event.A.pdf
import java.applet.; import java.awt.; import java.awt.event.A.pdfimport java.applet.; import java.awt.; import java.awt.event.A.pdf
import java.applet.; import java.awt.; import java.awt.event.A.pdf
apnafreez
 

Similar to import java.awt.; import java.awt.event.; import javax.swing..pdf (20)

Android Architecture Component in Real Life
Android Architecture Component in Real LifeAndroid Architecture Component in Real Life
Android Architecture Component in Real Life
 
Chat application in java using swing and socket programming.
Chat application in java using swing and socket programming.Chat application in java using swing and socket programming.
Chat application in java using swing and socket programming.
 
Lab 1 izz
Lab 1 izzLab 1 izz
Lab 1 izz
 
Sumsem2014 15 cp0399-13-jun-2015_rm01_programs
Sumsem2014 15 cp0399-13-jun-2015_rm01_programsSumsem2014 15 cp0399-13-jun-2015_rm01_programs
Sumsem2014 15 cp0399-13-jun-2015_rm01_programs
 
Tdd iPhone For Dummies
Tdd iPhone For DummiesTdd iPhone For Dummies
Tdd iPhone For Dummies
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
 
Android TDD
Android TDDAndroid TDD
Android TDD
 
The Ring programming language version 1.8 book - Part 88 of 202
The Ring programming language version 1.8 book - Part 88 of 202The Ring programming language version 1.8 book - Part 88 of 202
The Ring programming language version 1.8 book - Part 88 of 202
 
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdf
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdfpublic void turnRight(double degrees) {rotationInDegrees + - = deg.pdf
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdf
 
Infinum iOS Talks #1 - Swift under the hood: Method Dispatching by Vlaho Poluta
Infinum iOS Talks #1 - Swift under the hood: Method Dispatching by Vlaho PolutaInfinum iOS Talks #1 - Swift under the hood: Method Dispatching by Vlaho Poluta
Infinum iOS Talks #1 - Swift under the hood: Method Dispatching by Vlaho Poluta
 
CSharp for Unity Day2
CSharp for Unity Day2CSharp for Unity Day2
CSharp for Unity Day2
 
Psychtoolbox (PTB) practical course by Volodymyr B. Bogdanov, Lyon/Kyiv 2018...
Psychtoolbox (PTB) practical course  by Volodymyr B. Bogdanov, Lyon/Kyiv 2018...Psychtoolbox (PTB) practical course  by Volodymyr B. Bogdanov, Lyon/Kyiv 2018...
Psychtoolbox (PTB) practical course by Volodymyr B. Bogdanov, Lyon/Kyiv 2018...
 
Thread
ThreadThread
Thread
 
Android TDD & CI
Android TDD & CIAndroid TDD & CI
Android TDD & CI
 
Implementing STM in Java
Implementing STM in JavaImplementing STM in Java
Implementing STM in Java
 
Microkernel Development
Microkernel DevelopmentMicrokernel Development
Microkernel Development
 
Proyecto Poogame Tic Tac Toe
Proyecto Poogame Tic Tac ToeProyecto Poogame Tic Tac Toe
Proyecto Poogame Tic Tac Toe
 
662305 11
662305 11662305 11
662305 11
 
import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdf
import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdfimport java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdf
import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdf
 
import java.applet.; import java.awt.; import java.awt.event.A.pdf
import java.applet.; import java.awt.; import java.awt.event.A.pdfimport java.applet.; import java.awt.; import java.awt.event.A.pdf
import java.applet.; import java.awt.; import java.awt.event.A.pdf
 

More from aparnawatchcompany

I am sorry . image is too small. the expression is not clearly.pdf
 I am sorry . image is too small. the expression is not clearly.pdf I am sorry . image is too small. the expression is not clearly.pdf
I am sorry . image is too small. the expression is not clearly.pdf
aparnawatchcompany
 
the molar ratio of Na2S2O3 CL2 = 1 4 moles of.pdf
                     the molar ratio of Na2S2O3  CL2 = 1  4 moles of.pdf                     the molar ratio of Na2S2O3  CL2 = 1  4 moles of.pdf
the molar ratio of Na2S2O3 CL2 = 1 4 moles of.pdf
aparnawatchcompany
 
object persistence formats Sequential access optimized for operat.pdf
  object persistence formats   Sequential access  optimized for operat.pdf  object persistence formats   Sequential access  optimized for operat.pdf
object persistence formats Sequential access optimized for operat.pdf
aparnawatchcompany
 
The answer is b.) 4 Distribution coefficient = .pdf
                     The answer is b.) 4  Distribution coefficient = .pdf                     The answer is b.) 4  Distribution coefficient = .pdf
The answer is b.) 4 Distribution coefficient = .pdf
aparnawatchcompany
 
Not all analytes re non-polar hydrophobic substan.pdf
                     Not all analytes re non-polar hydrophobic substan.pdf                     Not all analytes re non-polar hydrophobic substan.pdf
Not all analytes re non-polar hydrophobic substan.pdf
aparnawatchcompany
 
Off-balance sheet problems have recurred throughout history, with .pdf
    Off-balance sheet problems have recurred throughout history, with .pdf    Off-balance sheet problems have recurred throughout history, with .pdf
Off-balance sheet problems have recurred throughout history, with .pdf
aparnawatchcompany
 
Well the only difference between the two structur.pdf
                     Well the only difference between the two structur.pdf                     Well the only difference between the two structur.pdf
Well the only difference between the two structur.pdf
aparnawatchcompany
 
Compunds composed of hydrogen and either fluorine.pdf
                     Compunds composed of hydrogen and either fluorine.pdf                     Compunds composed of hydrogen and either fluorine.pdf
Compunds composed of hydrogen and either fluorine.pdf
aparnawatchcompany
 
The Seliwanoffs Test is a test for ketoses. Of .pdf
                     The Seliwanoffs Test is a test for ketoses. Of .pdf                     The Seliwanoffs Test is a test for ketoses. Of .pdf
The Seliwanoffs Test is a test for ketoses. Of .pdf
aparnawatchcompany
 
The short answer is no. SN2 reactions are governed by several factor.pdf
The short answer is no. SN2 reactions are governed by several factor.pdfThe short answer is no. SN2 reactions are governed by several factor.pdf
The short answer is no. SN2 reactions are governed by several factor.pdf
aparnawatchcompany
 
Technology has taking milestone forwarding steps and they are using .pdf
Technology has taking milestone forwarding steps and they are using .pdfTechnology has taking milestone forwarding steps and they are using .pdf
Technology has taking milestone forwarding steps and they are using .pdf
aparnawatchcompany
 
Solution(a)Basic DefLet R be a binary relation on a set A.R i.pdf
Solution(a)Basic DefLet R be a binary relation on a set A.R i.pdfSolution(a)Basic DefLet R be a binary relation on a set A.R i.pdf
Solution(a)Basic DefLet R be a binary relation on a set A.R i.pdf
aparnawatchcompany
 
Section 4 we describe how theSolutionSection 4 we describe how.pdf
Section 4 we describe how theSolutionSection 4 we describe how.pdfSection 4 we describe how theSolutionSection 4 we describe how.pdf
Section 4 we describe how theSolutionSection 4 we describe how.pdf
aparnawatchcompany
 
probability= 10100=0.1Simple.Solutionprobability= 10100=0..pdf
probability= 10100=0.1Simple.Solutionprobability= 10100=0..pdfprobability= 10100=0.1Simple.Solutionprobability= 10100=0..pdf
probability= 10100=0.1Simple.Solutionprobability= 10100=0..pdf
aparnawatchcompany
 
Plantaris muscleThe plantaris is one of the superficial muscles of.pdf
Plantaris muscleThe plantaris is one of the superficial muscles of.pdfPlantaris muscleThe plantaris is one of the superficial muscles of.pdf
Plantaris muscleThe plantaris is one of the superficial muscles of.pdf
aparnawatchcompany
 
I think... Highest energy = most polarized = h.pdf
                     I think...  Highest energy = most polarized = h.pdf                     I think...  Highest energy = most polarized = h.pdf
I think... Highest energy = most polarized = h.pdf
aparnawatchcompany
 
P( 0 Z 1.5 )= P(Z1.5) - P(Z0)= 0.9332 - 0.5 (from table)= .pdf
P( 0 Z 1.5 )= P(Z1.5) - P(Z0)= 0.9332 - 0.5 (from table)= .pdfP( 0 Z 1.5 )= P(Z1.5) - P(Z0)= 0.9332 - 0.5 (from table)= .pdf
P( 0 Z 1.5 )= P(Z1.5) - P(Z0)= 0.9332 - 0.5 (from table)= .pdf
aparnawatchcompany
 
Non-coded RNA are small RNA molecule that cannot be translated by ho.pdf
Non-coded RNA are small RNA molecule that cannot be translated by ho.pdfNon-coded RNA are small RNA molecule that cannot be translated by ho.pdf
Non-coded RNA are small RNA molecule that cannot be translated by ho.pdf
aparnawatchcompany
 
Option b is Settlement risk The Nonschedule L off-balance-sheet ri.pdf
Option b is Settlement risk The Nonschedule L off-balance-sheet ri.pdfOption b is Settlement risk The Nonschedule L off-balance-sheet ri.pdf
Option b is Settlement risk The Nonschedule L off-balance-sheet ri.pdf
aparnawatchcompany
 
mSolutionm.pdf
mSolutionm.pdfmSolutionm.pdf
mSolutionm.pdf
aparnawatchcompany
 

More from aparnawatchcompany (20)

I am sorry . image is too small. the expression is not clearly.pdf
 I am sorry . image is too small. the expression is not clearly.pdf I am sorry . image is too small. the expression is not clearly.pdf
I am sorry . image is too small. the expression is not clearly.pdf
 
the molar ratio of Na2S2O3 CL2 = 1 4 moles of.pdf
                     the molar ratio of Na2S2O3  CL2 = 1  4 moles of.pdf                     the molar ratio of Na2S2O3  CL2 = 1  4 moles of.pdf
the molar ratio of Na2S2O3 CL2 = 1 4 moles of.pdf
 
object persistence formats Sequential access optimized for operat.pdf
  object persistence formats   Sequential access  optimized for operat.pdf  object persistence formats   Sequential access  optimized for operat.pdf
object persistence formats Sequential access optimized for operat.pdf
 
The answer is b.) 4 Distribution coefficient = .pdf
                     The answer is b.) 4  Distribution coefficient = .pdf                     The answer is b.) 4  Distribution coefficient = .pdf
The answer is b.) 4 Distribution coefficient = .pdf
 
Not all analytes re non-polar hydrophobic substan.pdf
                     Not all analytes re non-polar hydrophobic substan.pdf                     Not all analytes re non-polar hydrophobic substan.pdf
Not all analytes re non-polar hydrophobic substan.pdf
 
Off-balance sheet problems have recurred throughout history, with .pdf
    Off-balance sheet problems have recurred throughout history, with .pdf    Off-balance sheet problems have recurred throughout history, with .pdf
Off-balance sheet problems have recurred throughout history, with .pdf
 
Well the only difference between the two structur.pdf
                     Well the only difference between the two structur.pdf                     Well the only difference between the two structur.pdf
Well the only difference between the two structur.pdf
 
Compunds composed of hydrogen and either fluorine.pdf
                     Compunds composed of hydrogen and either fluorine.pdf                     Compunds composed of hydrogen and either fluorine.pdf
Compunds composed of hydrogen and either fluorine.pdf
 
The Seliwanoffs Test is a test for ketoses. Of .pdf
                     The Seliwanoffs Test is a test for ketoses. Of .pdf                     The Seliwanoffs Test is a test for ketoses. Of .pdf
The Seliwanoffs Test is a test for ketoses. Of .pdf
 
The short answer is no. SN2 reactions are governed by several factor.pdf
The short answer is no. SN2 reactions are governed by several factor.pdfThe short answer is no. SN2 reactions are governed by several factor.pdf
The short answer is no. SN2 reactions are governed by several factor.pdf
 
Technology has taking milestone forwarding steps and they are using .pdf
Technology has taking milestone forwarding steps and they are using .pdfTechnology has taking milestone forwarding steps and they are using .pdf
Technology has taking milestone forwarding steps and they are using .pdf
 
Solution(a)Basic DefLet R be a binary relation on a set A.R i.pdf
Solution(a)Basic DefLet R be a binary relation on a set A.R i.pdfSolution(a)Basic DefLet R be a binary relation on a set A.R i.pdf
Solution(a)Basic DefLet R be a binary relation on a set A.R i.pdf
 
Section 4 we describe how theSolutionSection 4 we describe how.pdf
Section 4 we describe how theSolutionSection 4 we describe how.pdfSection 4 we describe how theSolutionSection 4 we describe how.pdf
Section 4 we describe how theSolutionSection 4 we describe how.pdf
 
probability= 10100=0.1Simple.Solutionprobability= 10100=0..pdf
probability= 10100=0.1Simple.Solutionprobability= 10100=0..pdfprobability= 10100=0.1Simple.Solutionprobability= 10100=0..pdf
probability= 10100=0.1Simple.Solutionprobability= 10100=0..pdf
 
Plantaris muscleThe plantaris is one of the superficial muscles of.pdf
Plantaris muscleThe plantaris is one of the superficial muscles of.pdfPlantaris muscleThe plantaris is one of the superficial muscles of.pdf
Plantaris muscleThe plantaris is one of the superficial muscles of.pdf
 
I think... Highest energy = most polarized = h.pdf
                     I think...  Highest energy = most polarized = h.pdf                     I think...  Highest energy = most polarized = h.pdf
I think... Highest energy = most polarized = h.pdf
 
P( 0 Z 1.5 )= P(Z1.5) - P(Z0)= 0.9332 - 0.5 (from table)= .pdf
P( 0 Z 1.5 )= P(Z1.5) - P(Z0)= 0.9332 - 0.5 (from table)= .pdfP( 0 Z 1.5 )= P(Z1.5) - P(Z0)= 0.9332 - 0.5 (from table)= .pdf
P( 0 Z 1.5 )= P(Z1.5) - P(Z0)= 0.9332 - 0.5 (from table)= .pdf
 
Non-coded RNA are small RNA molecule that cannot be translated by ho.pdf
Non-coded RNA are small RNA molecule that cannot be translated by ho.pdfNon-coded RNA are small RNA molecule that cannot be translated by ho.pdf
Non-coded RNA are small RNA molecule that cannot be translated by ho.pdf
 
Option b is Settlement risk The Nonschedule L off-balance-sheet ri.pdf
Option b is Settlement risk The Nonschedule L off-balance-sheet ri.pdfOption b is Settlement risk The Nonschedule L off-balance-sheet ri.pdf
Option b is Settlement risk The Nonschedule L off-balance-sheet ri.pdf
 
mSolutionm.pdf
mSolutionm.pdfmSolutionm.pdf
mSolutionm.pdf
 

Recently uploaded

Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
MysoreMuleSoftMeetup
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
Wahiba Chair Training & Consulting
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
 
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
สมใจ จันสุกสี
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
PsychoTech Services
 
ZK on Polkadot zero knowledge proofs - sub0.pptx
ZK on Polkadot zero knowledge proofs - sub0.pptxZK on Polkadot zero knowledge proofs - sub0.pptx
ZK on Polkadot zero knowledge proofs - sub0.pptx
dot55audits
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 

Recently uploaded (20)

Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
 
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
 
ZK on Polkadot zero knowledge proofs - sub0.pptx
ZK on Polkadot zero knowledge proofs - sub0.pptxZK on Polkadot zero knowledge proofs - sub0.pptx
ZK on Polkadot zero knowledge proofs - sub0.pptx
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 

import java.awt.; import java.awt.event.; import javax.swing..pdf

  • 1. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class StopWatch extends JPanel { private Timer myTimer1; public static final int ONE_SEC = 1000; //time step in milliseconds public static final int TENTH_SEC = 100; private Font myClockFont; private JButton startBtn, stopBtn, resetBtn; private JLabel timeLbl; private JPanel topPanel, bottomPanel; private int clockTick; //number of clock ticks; tick can be 1.0 s or 0.1 s private double clockTime; //time in seconds private String clockTimeString; public StopWatch() { clockTick = 0; //initial clock setting in clock ticks clockTime = ((double)clockTick)/10.0; clockTimeString = new Double(clockTime).toString(); myClockFont = new Font("Serif", Font.PLAIN, 50); timeLbl = new JLabel(); timeLbl.setFont(myClockFont); timeLbl.setText(clockTimeString); startBtn = new JButton("Start"); stopBtn = new JButton("Stop"); resetBtn = new JButton("Reset"); myTimer1 = new Timer(TENTH_SEC, new ActionListener() { public void actionPerformed(ActionEvent evt) { clockTick++; clockTime = ((double)clockTick)/10.0; clockTimeString = new Double(clockTime).toString(); timeLbl.setText(clockTimeString);
  • 2. //System.out.println(clockTime); } }); startBtn.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt){ myTimer1.start(); } }); stopBtn.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt){ myTimer1.stop(); } }); resetBtn.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt){ clockTick = 0; clockTime = ((double)clockTick)/10.0; clockTimeString = new Double(clockTime).toString(); timeLbl.setText(clockTimeString); } }); }//end of StopWatch constructor public void launchStopWatch() { topPanel = new JPanel(); topPanel.setBackground(Color.orange); bottomPanel = new JPanel(); bottomPanel.setBackground(Color.yellow); topPanel.add(timeLbl); bottomPanel.add(startBtn); bottomPanel.add(stopBtn); bottomPanel.add(resetBtn); this.setLayout(new BorderLayout()); add(topPanel, BorderLayout.CENTER); add(bottomPanel, BorderLayout.SOUTH);
  • 3. setSize(300,200); setBackground(Color.orange); }//end of launchClock public static void main(String[] args) { MyTestFrame myTestFrame1 = new MyTestFrame(); } } class MyTestFrame extends JFrame { StopWatch StopWatch1; public MyTestFrame() { super("My Stop Watch"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container myPane = getContentPane(); StopWatch1 = new StopWatch(); StopWatch1.launchStopWatch(); myPane.add(StopWatch1); pack(); setVisible(true); } } Solution import java.awt.*; import java.awt.event.*; import javax.swing.*; public class StopWatch extends JPanel { private Timer myTimer1; public static final int ONE_SEC = 1000; //time step in milliseconds public static final int TENTH_SEC = 100; private Font myClockFont;
  • 4. private JButton startBtn, stopBtn, resetBtn; private JLabel timeLbl; private JPanel topPanel, bottomPanel; private int clockTick; //number of clock ticks; tick can be 1.0 s or 0.1 s private double clockTime; //time in seconds private String clockTimeString; public StopWatch() { clockTick = 0; //initial clock setting in clock ticks clockTime = ((double)clockTick)/10.0; clockTimeString = new Double(clockTime).toString(); myClockFont = new Font("Serif", Font.PLAIN, 50); timeLbl = new JLabel(); timeLbl.setFont(myClockFont); timeLbl.setText(clockTimeString); startBtn = new JButton("Start"); stopBtn = new JButton("Stop"); resetBtn = new JButton("Reset"); myTimer1 = new Timer(TENTH_SEC, new ActionListener() { public void actionPerformed(ActionEvent evt) { clockTick++; clockTime = ((double)clockTick)/10.0; clockTimeString = new Double(clockTime).toString(); timeLbl.setText(clockTimeString); //System.out.println(clockTime); } }); startBtn.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt){ myTimer1.start(); } }); stopBtn.addActionListener(new ActionListener(){
  • 5. public void actionPerformed(ActionEvent evt){ myTimer1.stop(); } }); resetBtn.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt){ clockTick = 0; clockTime = ((double)clockTick)/10.0; clockTimeString = new Double(clockTime).toString(); timeLbl.setText(clockTimeString); } }); }//end of StopWatch constructor public void launchStopWatch() { topPanel = new JPanel(); topPanel.setBackground(Color.orange); bottomPanel = new JPanel(); bottomPanel.setBackground(Color.yellow); topPanel.add(timeLbl); bottomPanel.add(startBtn); bottomPanel.add(stopBtn); bottomPanel.add(resetBtn); this.setLayout(new BorderLayout()); add(topPanel, BorderLayout.CENTER); add(bottomPanel, BorderLayout.SOUTH); setSize(300,200); setBackground(Color.orange); }//end of launchClock public static void main(String[] args) { MyTestFrame myTestFrame1 = new MyTestFrame(); } } class MyTestFrame extends JFrame
  • 6. { StopWatch StopWatch1; public MyTestFrame() { super("My Stop Watch"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container myPane = getContentPane(); StopWatch1 = new StopWatch(); StopWatch1.launchStopWatch(); myPane.add(StopWatch1); pack(); setVisible(true); } }