SlideShare une entreprise Scribd logo
1  sur  54
Saurabh Jain
Assistant. Professor,CSE
OCT BHOPAL
ORIENTAL COLLEGE OF TECHNOLOGY, BHOPAL
(Formerly known as Thakral College of Technology, Bhopal)
Approved by AICTE New Delhi & Govt. of M.P. and Affiliated to Rajiv
Gandhi Proudyogiki Vishwavidhyalaya Bhopal (M.P.)
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
CERTIFICATE
This is to Certify that the Minor Project Entitled “Run@Timer” Being
Submitted By Swapnil Dubey and Radhika Shrivastava in Partial fulfillment
of the Requirement for the Award Of B.E Degree In Computer Science &
Engineering To Oriental College Of Technology, Bhopal(M.P) is a Record Of
Bonafide work done by her under my Guidance.
Prof. Rachana Mishra
Head of Department, CSE
OCT BHOPAL
Page | - 2 -
ACKNOWLEDGEMENT
I am heartily thankful to the Management of Oriental College of Technology for providing
me all the facilities and infrastructure to take my work to the final stage.
I would like to express my deep sense of respect and gratitude towards my advisor and guide
Saurabh Jain, A.P,CSE Deptt. Oriental College of Technology, Bhopal who has given me
an opportunity to work under him. He has been a constant source of inspiration throughout
my work. His invaluable knowledge and innovative ideas helped me to take the work to the
final stage.
I express my respect to Dr. Kavita Burse, Director, Oriental College of Technology for her
constant encouragement and invaluable advice in every aspect of my academic life.
I would like to express my sincere thanks to Prof. Rachana Mishra, Head, Computer
Science Engineering Department, Oriental College of Technology and all faculty members of
Computer Science and Engineering Department for their support and guidance.
I am especially thankful to our Parents and our siblings for their love, sacrifice and support
on every path of my life..
Last but not the least I am extremely thankful to all who have directly or indirectly helped me
for the completion of my work.
Page | - 3 -
INDEX
1.Abstract……………………………………..
2.Introduction…………………………………
3.Brief explanation………………………………..
4.Software requirement specification…………..
i) Requirement
ii) Hardware
iii) Scope
iv) Tools used
5. Software engineering methods used……..
6. Related and proposed scenario…………….
7. Limitations and further scope……………..
8. Source codes snapshots………………………
9. Conclusions………………………………….
10. References……………………………………
Page | - 4 -
ABSTRACT
We now a days are so busy in handling things on our
computer systems that we often miss a task during our
work, and then realize after sometime that if we’d have
done this task results would have been different. That’s
where the application developed by me and my team
comes into existence. Run@timer is a timer application
developed in J2SE platform and takes time and task to
be done as input and then at given time performs that
task. This project report intends to give an overview of
Run@Timer, its uses and techniques. It also attempts to
identify the requirements of a good algorithm to be
followed and briefly reflects on which methods to be
used to make a good project on this topic and which
techniques are more suitable for which application.
Page | - 5 -
INTRODUCTION
Timer in Java is a utility class which is used to schedule
tasks for both one time and repeated execution. Timer is
similar to alarm facility many people use in mobile
phone.
Just like you can have one time alarm or repeated
alarm, you can use java.util.Timer to schedule one time
task or repeated task.
In fact we can implement a Reminder utility using
Timer in Java and that's what we are going to see in this
example of Timer in Java. Two classes java.util.Timer
and java.util.TimerTask is used to schedule jobs in Java
and forms Timer API.
TimerTask is actual task which is executed by Timer.
Similar to Thread in Java, TimerTask also implements
Runnable interface and overrides run method to specify
task details.
Timer and TimerTask example in Java Timer in Java is
a utility class form java.util package which provides
facility to schedule task at any time in future.
Page | - 6 -
As I said earlier, Timer is analogues to alarm clock you
setup in your smartphone. Just like alarm can be either
one time or recurring, You can also schedule task for
one time and recurring time interval using Timer API.
Timer provides method to schedule Task where task is
instance of TimerTask class, which implements
Runnable interface and overrides run() method to define
task which is called on scheduled time.
Page | - 7 -
SYNOPSIS
Project Name: RUN@TIMER
Project Members:
This Project is done in a group of two people. Project
members are:
1.Swapnil Dubey
2.Radhika Shrivastava
Page | - 8 -
BRIEF EXPLANATION
What is Timer and Timertask() in Java?
Timer class in Java maintains a background Thread
(this could be either daemon thread or user thread,
based on how you created your Timer object), also
called as timer's task execution thread.
For each Timer there would be corresponding task
processing Thread which run scheduled task at
specified time.
If your Timer thread is not daemon then it will stop
your application from exits until it completes all
schedule task. Its recommended that TimerTask should
not be very long otherwise it can keep this thread busy
and not allow other scheduled task to get completed.
This can delay execution of other scheduled task, which
may queue up and execute in quick succession once
offending task completed.
Page | - 9 -
Difference between Timer and TimerTask in Java:
As seen , I have seen programmers getting confused
between Timer and TimerTask, which is quite
unnecessary because these two are altogether different.
You just need to remember:
1) Timer in Java schedules and execute TimerTask
which is an implementation of Runnable interface and
overrides run method to defined actual task performed
by that TimerTask.
2) Both Timer and TimerTask provides cancel()
method. Timer's cancel() method cancels whole timer
while TimerTask's one cancels only a particular task. I
think this is the wroth noting difference between Timer
and TimerTask in Java.
Page | - 10 -
Canceling Timer in Java
Now talking about the cancelation of Timer task in java,
You can cancel Java Timer by calling cancel() method
of java.util.Timer class, this would result in following:
1)Timer will not cancel any currently executing task.
2)Timer will discard other scheduled task and will
not execute them.
3)Once currently executing task will be finished,
timer thread will terminate gracefully.
4) Calling Timer.cancel() more than one time will not
affect. second call will be ignored.
In addition to cancelling Timer, You can also cancel
individual TimerTask by using cancel() method of
TimerTask itself.
Page | - 11 -
Important points on Timer and TimerTask in Java
Now as we have got a knowledge about Timer and
TimerTask in Java, we need to remember the following
points:
1.One Thread will be created corresponding ot each
Timer in Java, which could be either daemon or
user thread.
2.You can schedule multiple TimerTask with one
Timer.
3.You can schedule task for either one time execution
or recurring execution.
4.TimerTask.cancel() cancels only that particular
task, while Timer.cancel() cancel all task scheduled
in Timer.
5.Timer in Java will throw IllegalStateException if
you try to schedule task on a Timer which has been
cancelled or whose Task execution Thread has
been terminated.
Page | - 12 -
When there is a need to trigger a task automatically
based on time we should schedule it using a timer api.
The requirement can vary from a single execution on a
fixed time to high complex recurring event. For
example take our regular alarm clock where we fix a
time and it beeps coming day on the fixed time.
Similarly a high complex example would be the MS
outlook where we can schedule events with a different
combination.
Following are the things in consideration
When does the event starts (first time) execution – It
may be a day / date / time in future.
Is it a one time event or a recurring event?
If recurring, what is the periodicity? –
In recurrence there are two types, like all the events
will be on a fixed time which is planned at the time of
scheduling. It may be daily / weekly / monthly / yearly /
a day of a week / alternate days / only working days.
Second type is, the recurring event can start after the
completion of previous occurrence. There can be a
delay between events.
Page | - 13 -
When does it end, after a constant number of
executions or after a time is reached like till Friday
only.
java.util.Timer and TimerTask :
It gives facility to schedule a task for future execution
in a background thread.
Task can be scheduled for single or recurring execution.
In recurrence, consecutive tasks will have regular
intervals.
Timer has got a cancel method using which all the
scheduled tasks can be cancelled.
Timer can be chosen to run as a daemon thread.
It can be scheduled to start with respect to current
time using fixed-delay.
TimerTask is a thread handle using which we register
tasks with the timer.
Page | - 14 -
Important Variations:
This api provides two important variations that needs to
be noted.
Fixed-delay
Each task execution is scheduled relative to the actual
execution time of the previous execution. So what is
actual execution?
This says that, there is no guarantee that the task will be
executed at the pre-planned time and it may be delayed
due to garbage collection or some background activity.
We should also not confuse with triggering of task and
completion of task.
Triggering is the moment at which the Timer fires start
a task. If a thread is asked to send email, it may wait for
access to the resource like mail server.
Only after the email is sent this task is considered to be
completed. We need to have this duration in mind when
we schedule recurrence tasks.
If the recurrence time is shorter and already the
previous task is not completed, the subsequent tasks
will join the queue.
Page | - 15 -
Fixed-rate
Here each recurring tasks are scheduled relative to the
start time of the timer.
If there is any delay in execution subsequent executions
will occur in quick succession to catch up with the
original scheduled time.
In previous case, subsequent execution will depend on
just previous execution time.
Page | - 16 -
Project scope:
This project is developed for anybody who is busy
doing multiple tasks on his system and wants an
application to run at a specific time but has a chance
that he might not remember to start it. Hence by using it
he can save his time, remain stress free, do his work and
leave rest on our developed application.
Methodology:
User needs to run the application. The user has a option
of “select file/Program” he wants to run at the specific
time. If the user successfully selects it, the application
asks him the time at which he want to run that
file/program. And after desired value when he clicks
OK then the timer starts and then after desired time
given by user the selected file/program execution takes
place .
Page | - 17 -
Software Requirements:
 Netbeans
Hardware Requirements:
 Processor: Preferably 1.0 GHz or greater.
 RAM: 512 MB or Greater
Future Enhancements:
To make it available at Windows Market so that the
common people can also use it and take maximum
benefit of this application.
Page | - 18 -
SCREENSHOTS OF WORKING
APPLICATION(USER MANUAL) :
1.When the application starts it looks like this. User
sees a window in which the name of application
Run@timer is displayed and also option to Select file
/Program is there. The look and feel of the
application is made very easy to use and user
friendly.
Page | - 19 -
2.Then to start the application, user has to click the
Select File/Program button.
Page | - 20 -
3.As soon as the user clicks the button, a File
chooser window opens and we select file.
Page | - 21 -
4.When we open it we can browse anywhere for
file in the computer. As in this example user is
selecting music folder and then a song from that
folder.
Page | - 22 -
Page | - 23 -
5.As soon as he clicks the open button, he returns
to the main window and then he is asked to put
the timer.
Page | - 24 -
6.The user selects the time, as in this example , he
selected 1 minute:
Page | - 25 -
7.Then he clicks Strt which is the button ehich
starts the timer of the application:
Page | - 26 -
8.The timer starts and the second window opens
where he can see the time getting reduced
second by second:
Page | - 27 -
Page | - 28 -
Page | - 29 -
9.When the timer time which was given by user
completes, a message is displayed which says
successfully executed and then, we get this
screen.
Page | - 30 -
10.As the user selected the song , we can see that the
song is played as soon as the time completes.
Page | - 31 -
Coding Screenshots to prove the project is a pure
innovational concept and is not copied from
anywhere:
For the first frame:
1.
Page | - 32 -
Page | - 33 -
Page | - 34 -
For the second frame:
Page | - 35 -
Page | - 36 -
Page | - 37 -
Page | - 38 -
Page | - 39 -
Detailed and clear coding for the first Frame of
application:
/*
* To change this license header, choose License Headers in
Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author swapnil dubey
*/
import java.awt.Desktop;
import java.awt.Toolkit;
import java.awt.event.WindowEvent;
import java.io.File;
import java.net.URL;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
public class FirstFrame extends javax.swing.JFrame {
/**
* Creates new form FirstFrame
*/
public FirstFrame() {
initComponents();
}
/**
* This method is called from within the constructor to
initialize the form.
* WARNING: Do NOT modify this code. The content of this
method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated
Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jSpinner1 = new javax.swing.JSpinner();
jSpinner2 = new javax.swing.JSpinner();
Page | - 40 -
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_O
N_CLOSE);
jLabel1.setFont(new java.awt.Font("Lucida Sans", 1,
48)); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 0, 0));
jLabel1.setText("Run@timer");
jButton1.setText("Select File/Program");
jButton1.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jSpinner1.setModel(new
javax.swing.SpinnerNumberModel(Integer.valueOf(0),
Integer.valueOf(0), null, Integer.valueOf(1)));
jSpinner2.setModel(new
javax.swing.SpinnerNumberModel(Integer.valueOf(0),
Integer.valueOf(0), null, Integer.valueOf(5)));
jLabel2.setText("minutes");
jLabel3.setText("hours");
jButton2.setFont(new java.awt.Font("Times New Roman",
1, 48)); // NOI18N
jButton2.setForeground(new java.awt.Color(255, 0,
102));
jButton2.setIcon(new
javax.swing.ImageIcon("C:Usersswapnil
dubeyDesktopicon-start-play-128.png")); // NOI18N
jButton2.setText("Start");
jButton2.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
Page | - 41 -
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(130, 130, 130)
.addComponent(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE, 287,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(40, 40, 40)
.addComponent(jTextField1,
javax.swing.GroupLayout.PREFERRED_SIZE, 385,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton1))
.addGroup(layout.createSequentialGroup()
.addGap(153, 153, 153)
.addComponent(jButton2,
javax.swing.GroupLayout.PREFERRED_SIZE, 340,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(115, 115, 115)
.addComponent(jSpinner1,
javax.swing.GroupLayout.PREFERRED_SIZE, 51,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(26, 26, 26)
.addComponent(jLabel2)
.addGap(43, 43, 43)
.addComponent(jSpinner2,
javax.swing.GroupLayout.PREFERRED_SIZE, 44,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(32, 32, 32)
.addComponent(jLabel3)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addGroup(layout.createSequentialGroup()
Page | - 42 -
.addGap(46, 46, 46)
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jTextField1,
javax.swing.GroupLayout.PREFERRED_SIZE, 45,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1,
javax.swing.GroupLayout.PREFERRED_SIZE, 45,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(83, 83, 83)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.TRAILING)
.addComponent(jSpinner1,
javax.swing.GroupLayout.PREFERRED_SIZE, 34,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2)))
.addGroup(layout.createSequentialGroup()
.addGap(85, 85, 85)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.TRAILING)
.addComponent(jLabel3)
.addComponent(jSpinner2,
javax.swing.GroupLayout.PREFERRED_SIZE, 33,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RE
LATED, 73, Short.MAX_VALUE)
.addComponent(jButton2,
javax.swing.GroupLayout.PREFERRED_SIZE, 128,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(27, 27, 27))
);
pack();
}// </editor-fold>//GEN-END:initComponents
public void close(){
WindowEvent winClosingEvent = new
WindowEvent(this,WindowEvent.WINDOW_CLOSING);
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(wi
nClosingEvent);
Page | - 43 -
}
private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_jButton1ActionPerformed
JFileChooser fileChooser = new JFileChooser();
int returnValue = fileChooser.showOpenDialog(null);
if (returnValue== JFileChooser.APPROVE_OPTION) {
File file=fileChooser.getSelectedFile();
jTextField1.setText(file.getAbsolutePath());
ff=jTextField1.getText();
}
}//GEN-LAST:event_jButton1ActionPerformed
private void
jButton2ActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_jButton2ActionPerformed
if("".equals(jTextField1.getText()))
{
JOptionPane.showMessageDialog(this, "Select a file or process
first", "Warning", JOptionPane.ERROR_MESSAGE);
}
else{
close();
int
mins=Integer.valueOf(jSpinner1.getValue().toString());
int
hours=Integer.valueOf(jSpinner2.getValue().toString());
int tot=(hours*60)+mins;
if(tot==0)
JOptionPane.showMessageDialog(this, "Timer can't be Zero",
"Warning", JOptionPane.ERROR_MESSAGE);
else
{
seconds=60*tot;
SecondFrame form= new SecondFrame();
form.setLocationRelativeTo(null);
form.setVisible(true);
}
}
}//GEN-LAST:event_jButton2ActionPerformed
/**
* @param args the command line arguments
*/
static String ff;
static int seconds;
Page | - 44 -
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look
and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not
available, stay with the default look and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel
/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(FirstFrame.class.getName())
.log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(FirstFrame.class.getName())
.log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(FirstFrame.class.getName())
.log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException
ex) {
java.util.logging.Logger.getLogger(FirstFrame.class.getName())
.log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new FirstFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-
BEGIN:variables
Page | - 45 -
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JSpinner jSpinner1;
private javax.swing.JSpinner jSpinner2;
private javax.swing.JTextField jTextField1;
// End of variables declaration//GEN-END:variables
}
Page | - 46 -
Detailed coding for the second Frame:
/*
* To change this license header, choose License Headers in
Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;
/**
*
* @author swapnil dubey
*/
public class SecondFrame extends javax.swing.JFrame {
/**
* Creates new form SecondFrame
*/
public SecondFrame() {
initComponents();
startime();
}
TimerTask task = new SecondFrame.RunMeTask1();
Timer timer = new Timer();
public void startime()
{
jTextField1.setText(s);
timer.schedule(task, 0,1000);
}
/**
* This method is called from within the constructor to
initialize the form.
* WARNING: Do NOT modify this code. The content of this
method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated
Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
Page | - 47 -
jTextField1 = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_C
LOSE);
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 36));
// NOI18N
jLabel1.setText("To Run");
jScrollPane1.setViewportView(jTextField1);
jButton1.setFont(new java.awt.Font("Tahoma", 1, 48));
// NOI18N
jButton1.setForeground(new java.awt.Color(255, 0,
102));
jButton1.setIcon(new
javax.swing.ImageIcon("C:Usersswapnil
dubeyDesktopcancel_red.png")); // NOI18N
jButton1.setText("Stop");
jButton1.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(32, 32, 32)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 363,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(71, 71, 71)
Page | - 48 -
.addComponent(jLabel2,
javax.swing.GroupLayout.PREFERRED_SIZE, 385,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(166, 166, 166)
.addComponent(jButton1,
javax.swing.GroupLayout.PREFERRED_SIZE, 301,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(44, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(73, 73, 73)
.addComponent(jLabel1))
.addGroup(layout.createSequentialGroup()
.addGap(50, 50, 50)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 100,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(74, 74, 74)
.addComponent(jLabel2,
javax.swing.GroupLayout.PREFERRED_SIZE, 61,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RE
LATED, 47, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(35, 35, 35))
);
pack();
}// </editor-fold>//GEN-END:initComponents
FirstFrame steg = new FirstFrame();
String s=steg.ff;
private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_jButton1ActionPerformed
timer.cancel();
jLabel2.setText("Stopped");
}//GEN-LAST:event_jButton1ActionPerformed
public class RunMeTask1 extends TimerTask
{
int seconds=steg.seconds;
Page | - 49 -
public void run()
{
if (seconds > 0)
{
int r=seconds/60;
int rem=seconds%60;
int hr=r/60;
int rr=r%60;
if(r==0)
{
jLabel2.setText(seconds + " secs Remaining");
seconds--;
}
else if(hr==0)
{
jLabel2.setText(r+" Mins and "+rem+" secs
Remaining");
seconds--;
}
else
{
jLabel2.setText(hr+" hours "+rr+" Mins and
"+rem+" secs Remaining");
seconds--;
}
}
else if(seconds==-1)
{
return;
}
else if(seconds==0)
{
try{
File f = new File(s);
Desktop dt = Desktop.getDesktop();
dt.open(f);
}catch(IOException e){
e.printStackTrace();
}
jLabel2.setText(" Successfully Executed ");
seconds=-1;
//System.exit(0);
}
}
Page | - 50 -
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look
and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not
available, stay with the default look and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel
/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(SecondFrame.class.getName()
).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(SecondFrame.class.getName()
).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(SecondFrame.class.getName()
).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException
ex) {
java.util.logging.Logger.getLogger(SecondFrame.class.getName()
).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new SecondFrame().setVisible(true);
}
});
}
Page | - 51 -
// Variables declaration - do not modify//GEN-
BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextField jTextField1;
// End of variables declaration//GEN-END:variables
}
Page | - 52 -
Detailed coding for main class :
/*
* To change this license header, choose License Headers in
Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author swapnil dubey
*/
public class main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
FirstFrame form=new FirstFrame ();
form.setLocationRelativeTo(null);
form.setVisible(true);
}
}
Page | - 53 -
Conclusion:
Applications like this should be developed more
frequently so that more amount of work can be done in
a short span of time and not worrying anything about
the upcoming tasks.
Page | - 54 -
Refrences:
www.google.com
www.wickepedia.org
www.examples.codegeeks.com/core-java
www.javarevisited.blogspot.in
www.mkyong.com/java

Contenu connexe

En vedette

Manual NGL-841-tvattstallsblandare
Manual NGL-841-tvattstallsblandareManual NGL-841-tvattstallsblandare
Manual NGL-841-tvattstallsblandareNGL Teknik AB
 
Manual NGL-832-koksblandare
Manual NGL-832-koksblandareManual NGL-832-koksblandare
Manual NGL-832-koksblandareNGL Teknik AB
 
Hamilton Bradshaw Careers
Hamilton Bradshaw CareersHamilton Bradshaw Careers
Hamilton Bradshaw Careersmljdwc
 
Manual NGL-831-koksblandare
Manual NGL-831-koksblandareManual NGL-831-koksblandare
Manual NGL-831-koksblandareNGL Teknik AB
 
Manual NGL-861-badkarsblandare
Manual NGL-861-badkarsblandareManual NGL-861-badkarsblandare
Manual NGL-861-badkarsblandareNGL Teknik AB
 
Installation specifikation-NGL-842-8 sid utan ritn
Installation specifikation-NGL-842-8 sid utan ritnInstallation specifikation-NGL-842-8 sid utan ritn
Installation specifikation-NGL-842-8 sid utan ritnNGL Teknik AB
 
Manual NGL-824-duschset
Manual NGL-824-duschsetManual NGL-824-duschset
Manual NGL-824-duschsetNGL Teknik AB
 
NGL tak- o antivandaldusch-120312-web
NGL tak- o antivandaldusch-120312-webNGL tak- o antivandaldusch-120312-web
NGL tak- o antivandaldusch-120312-webNGL Teknik AB
 
Ecofunktioner ngl-kok
Ecofunktioner ngl-kokEcofunktioner ngl-kok
Ecofunktioner ngl-kokNGL Teknik AB
 
鲜果联播产品及团队介绍
鲜果联播产品及团队介绍鲜果联播产品及团队介绍
鲜果联播产品及团队介绍diyizixun
 
2012 eng-broschyr web
2012 eng-broschyr web2012 eng-broschyr web
2012 eng-broschyr webNGL Teknik AB
 
NGL rostfria broschyr-web
NGL rostfria broschyr-webNGL rostfria broschyr-web
NGL rostfria broschyr-webNGL Teknik AB
 
Oxygen presentation
Oxygen presentationOxygen presentation
Oxygen presentationericadung
 
Progetto e realizzazione di uno strumento per l'acquisizione e trasmissione d...
Progetto e realizzazione di uno strumento per l'acquisizione e trasmissione d...Progetto e realizzazione di uno strumento per l'acquisizione e trasmissione d...
Progetto e realizzazione di uno strumento per l'acquisizione e trasmissione d...Gabriele Formisano
 
Presentazione, progetto e realizzazione di uno strumento per l'acquisizione e...
Presentazione, progetto e realizzazione di uno strumento per l'acquisizione e...Presentazione, progetto e realizzazione di uno strumento per l'acquisizione e...
Presentazione, progetto e realizzazione di uno strumento per l'acquisizione e...Gabriele Formisano
 
Project report format
Project report formatProject report format
Project report formatreddy13sara
 
MINOR PROJECT REPORT ON KFC
MINOR PROJECT REPORT ON KFCMINOR PROJECT REPORT ON KFC
MINOR PROJECT REPORT ON KFCSimar ੴ Singh
 

En vedette (20)

Manual NGL-841-tvattstallsblandare
Manual NGL-841-tvattstallsblandareManual NGL-841-tvattstallsblandare
Manual NGL-841-tvattstallsblandare
 
Manual NGL-832-koksblandare
Manual NGL-832-koksblandareManual NGL-832-koksblandare
Manual NGL-832-koksblandare
 
Hamilton Bradshaw Careers
Hamilton Bradshaw CareersHamilton Bradshaw Careers
Hamilton Bradshaw Careers
 
Manual NGL-831-koksblandare
Manual NGL-831-koksblandareManual NGL-831-koksblandare
Manual NGL-831-koksblandare
 
Manual NGL-861-badkarsblandare
Manual NGL-861-badkarsblandareManual NGL-861-badkarsblandare
Manual NGL-861-badkarsblandare
 
Installation specifikation-NGL-842-8 sid utan ritn
Installation specifikation-NGL-842-8 sid utan ritnInstallation specifikation-NGL-842-8 sid utan ritn
Installation specifikation-NGL-842-8 sid utan ritn
 
Manual NGL-824-duschset
Manual NGL-824-duschsetManual NGL-824-duschset
Manual NGL-824-duschset
 
NGL tak- o antivandaldusch-120312-web
NGL tak- o antivandaldusch-120312-webNGL tak- o antivandaldusch-120312-web
NGL tak- o antivandaldusch-120312-web
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
Ecofunktioner ngl-kok
Ecofunktioner ngl-kokEcofunktioner ngl-kok
Ecofunktioner ngl-kok
 
鲜果联播产品及团队介绍
鲜果联播产品及团队介绍鲜果联播产品及团队介绍
鲜果联播产品及团队介绍
 
Manual NGL-823
Manual NGL-823Manual NGL-823
Manual NGL-823
 
2012 eng-broschyr web
2012 eng-broschyr web2012 eng-broschyr web
2012 eng-broschyr web
 
Wu wei coaching
Wu wei coachingWu wei coaching
Wu wei coaching
 
NGL rostfria broschyr-web
NGL rostfria broschyr-webNGL rostfria broschyr-web
NGL rostfria broschyr-web
 
Oxygen presentation
Oxygen presentationOxygen presentation
Oxygen presentation
 
Progetto e realizzazione di uno strumento per l'acquisizione e trasmissione d...
Progetto e realizzazione di uno strumento per l'acquisizione e trasmissione d...Progetto e realizzazione di uno strumento per l'acquisizione e trasmissione d...
Progetto e realizzazione di uno strumento per l'acquisizione e trasmissione d...
 
Presentazione, progetto e realizzazione di uno strumento per l'acquisizione e...
Presentazione, progetto e realizzazione di uno strumento per l'acquisizione e...Presentazione, progetto e realizzazione di uno strumento per l'acquisizione e...
Presentazione, progetto e realizzazione di uno strumento per l'acquisizione e...
 
Project report format
Project report formatProject report format
Project report format
 
MINOR PROJECT REPORT ON KFC
MINOR PROJECT REPORT ON KFCMINOR PROJECT REPORT ON KFC
MINOR PROJECT REPORT ON KFC
 

Similaire à A Project Run@Timer, J2SE,

Asynchronous and parallel programming
Asynchronous and parallel programmingAsynchronous and parallel programming
Asynchronous and parallel programmingAnil Kumar
 
Java Performance, Threading and Concurrent Data Structures
Java Performance, Threading and Concurrent Data StructuresJava Performance, Threading and Concurrent Data Structures
Java Performance, Threading and Concurrent Data StructuresHitendra Kumar
 
On the benchmark of Chainer
On the benchmark of ChainerOn the benchmark of Chainer
On the benchmark of ChainerKenta Oono
 
Analysing in depth work manager
Analysing in depth work managerAnalysing in depth work manager
Analysing in depth work managerlpu
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in javaRaghu nath
 
Document 14 (6).pdf
Document 14 (6).pdfDocument 14 (6).pdf
Document 14 (6).pdfRajMantry
 
Analysing in depth work manager
Analysing in depth work managerAnalysing in depth work manager
Analysing in depth work managerbhatnagar.gaurav83
 
Using spring scheduler mule
Using spring scheduler muleUsing spring scheduler mule
Using spring scheduler muleSon Nguyen
 
Async Await for Mobile Apps
Async Await for Mobile AppsAsync Await for Mobile Apps
Async Await for Mobile AppsCraig Dunn
 
An eternal question of timing
An eternal question of timingAn eternal question of timing
An eternal question of timingPVS-Studio
 
Java concurrency model - The Future Task
Java concurrency model - The Future TaskJava concurrency model - The Future Task
Java concurrency model - The Future TaskSomenath Mukhopadhyay
 
ScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency InjectionScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency Injection7mind
 
Multi t hreading_14_10
Multi t hreading_14_10Multi t hreading_14_10
Multi t hreading_14_10Minal Maniar
 
Reactive programming with rx java
Reactive programming with rx javaReactive programming with rx java
Reactive programming with rx javaCongTrung Vnit
 
66781291 java-lab-manual
66781291 java-lab-manual66781291 java-lab-manual
66781291 java-lab-manualLaura Popovici
 

Similaire à A Project Run@Timer, J2SE, (20)

Asynchronous and parallel programming
Asynchronous and parallel programmingAsynchronous and parallel programming
Asynchronous and parallel programming
 
Java Performance, Threading and Concurrent Data Structures
Java Performance, Threading and Concurrent Data StructuresJava Performance, Threading and Concurrent Data Structures
Java Performance, Threading and Concurrent Data Structures
 
Training – Going Async
Training – Going AsyncTraining – Going Async
Training – Going Async
 
On the benchmark of Chainer
On the benchmark of ChainerOn the benchmark of Chainer
On the benchmark of Chainer
 
Analysing in depth work manager
Analysing in depth work managerAnalysing in depth work manager
Analysing in depth work manager
 
Von neumann workers
Von neumann workersVon neumann workers
Von neumann workers
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Document 14 (6).pdf
Document 14 (6).pdfDocument 14 (6).pdf
Document 14 (6).pdf
 
Analysing in depth work manager
Analysing in depth work managerAnalysing in depth work manager
Analysing in depth work manager
 
Using spring scheduler mule
Using spring scheduler muleUsing spring scheduler mule
Using spring scheduler mule
 
Async Await for Mobile Apps
Async Await for Mobile AppsAsync Await for Mobile Apps
Async Await for Mobile Apps
 
An eternal question of timing
An eternal question of timingAn eternal question of timing
An eternal question of timing
 
Java concurrency model - The Future Task
Java concurrency model - The Future TaskJava concurrency model - The Future Task
Java concurrency model - The Future Task
 
ScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency InjectionScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency Injection
 
Concurrency and parallel in .net
Concurrency and parallel in .netConcurrency and parallel in .net
Concurrency and parallel in .net
 
Multi t hreading_14_10
Multi t hreading_14_10Multi t hreading_14_10
Multi t hreading_14_10
 
RxJava@Android
RxJava@AndroidRxJava@Android
RxJava@Android
 
Reactive programming with rx java
Reactive programming with rx javaReactive programming with rx java
Reactive programming with rx java
 
66781291 java-lab-manual
66781291 java-lab-manual66781291 java-lab-manual
66781291 java-lab-manual
 
concurrency
concurrencyconcurrency
concurrency
 

Dernier

Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - GuideGOPINATHS437943
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptMadan Karki
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitterShivangiSharma879191
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 

Dernier (20)

Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - Guide
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.ppt
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 

A Project Run@Timer, J2SE,

  • 1. Saurabh Jain Assistant. Professor,CSE OCT BHOPAL ORIENTAL COLLEGE OF TECHNOLOGY, BHOPAL (Formerly known as Thakral College of Technology, Bhopal) Approved by AICTE New Delhi & Govt. of M.P. and Affiliated to Rajiv Gandhi Proudyogiki Vishwavidhyalaya Bhopal (M.P.) DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING CERTIFICATE This is to Certify that the Minor Project Entitled “Run@Timer” Being Submitted By Swapnil Dubey and Radhika Shrivastava in Partial fulfillment of the Requirement for the Award Of B.E Degree In Computer Science & Engineering To Oriental College Of Technology, Bhopal(M.P) is a Record Of Bonafide work done by her under my Guidance. Prof. Rachana Mishra Head of Department, CSE OCT BHOPAL
  • 2. Page | - 2 - ACKNOWLEDGEMENT I am heartily thankful to the Management of Oriental College of Technology for providing me all the facilities and infrastructure to take my work to the final stage. I would like to express my deep sense of respect and gratitude towards my advisor and guide Saurabh Jain, A.P,CSE Deptt. Oriental College of Technology, Bhopal who has given me an opportunity to work under him. He has been a constant source of inspiration throughout my work. His invaluable knowledge and innovative ideas helped me to take the work to the final stage. I express my respect to Dr. Kavita Burse, Director, Oriental College of Technology for her constant encouragement and invaluable advice in every aspect of my academic life. I would like to express my sincere thanks to Prof. Rachana Mishra, Head, Computer Science Engineering Department, Oriental College of Technology and all faculty members of Computer Science and Engineering Department for their support and guidance. I am especially thankful to our Parents and our siblings for their love, sacrifice and support on every path of my life.. Last but not the least I am extremely thankful to all who have directly or indirectly helped me for the completion of my work.
  • 3. Page | - 3 - INDEX 1.Abstract…………………………………….. 2.Introduction………………………………… 3.Brief explanation……………………………….. 4.Software requirement specification………….. i) Requirement ii) Hardware iii) Scope iv) Tools used 5. Software engineering methods used…….. 6. Related and proposed scenario……………. 7. Limitations and further scope…………….. 8. Source codes snapshots……………………… 9. Conclusions…………………………………. 10. References……………………………………
  • 4. Page | - 4 - ABSTRACT We now a days are so busy in handling things on our computer systems that we often miss a task during our work, and then realize after sometime that if we’d have done this task results would have been different. That’s where the application developed by me and my team comes into existence. Run@timer is a timer application developed in J2SE platform and takes time and task to be done as input and then at given time performs that task. This project report intends to give an overview of Run@Timer, its uses and techniques. It also attempts to identify the requirements of a good algorithm to be followed and briefly reflects on which methods to be used to make a good project on this topic and which techniques are more suitable for which application.
  • 5. Page | - 5 - INTRODUCTION Timer in Java is a utility class which is used to schedule tasks for both one time and repeated execution. Timer is similar to alarm facility many people use in mobile phone. Just like you can have one time alarm or repeated alarm, you can use java.util.Timer to schedule one time task or repeated task. In fact we can implement a Reminder utility using Timer in Java and that's what we are going to see in this example of Timer in Java. Two classes java.util.Timer and java.util.TimerTask is used to schedule jobs in Java and forms Timer API. TimerTask is actual task which is executed by Timer. Similar to Thread in Java, TimerTask also implements Runnable interface and overrides run method to specify task details. Timer and TimerTask example in Java Timer in Java is a utility class form java.util package which provides facility to schedule task at any time in future.
  • 6. Page | - 6 - As I said earlier, Timer is analogues to alarm clock you setup in your smartphone. Just like alarm can be either one time or recurring, You can also schedule task for one time and recurring time interval using Timer API. Timer provides method to schedule Task where task is instance of TimerTask class, which implements Runnable interface and overrides run() method to define task which is called on scheduled time.
  • 7. Page | - 7 - SYNOPSIS Project Name: RUN@TIMER Project Members: This Project is done in a group of two people. Project members are: 1.Swapnil Dubey 2.Radhika Shrivastava
  • 8. Page | - 8 - BRIEF EXPLANATION What is Timer and Timertask() in Java? Timer class in Java maintains a background Thread (this could be either daemon thread or user thread, based on how you created your Timer object), also called as timer's task execution thread. For each Timer there would be corresponding task processing Thread which run scheduled task at specified time. If your Timer thread is not daemon then it will stop your application from exits until it completes all schedule task. Its recommended that TimerTask should not be very long otherwise it can keep this thread busy and not allow other scheduled task to get completed. This can delay execution of other scheduled task, which may queue up and execute in quick succession once offending task completed.
  • 9. Page | - 9 - Difference between Timer and TimerTask in Java: As seen , I have seen programmers getting confused between Timer and TimerTask, which is quite unnecessary because these two are altogether different. You just need to remember: 1) Timer in Java schedules and execute TimerTask which is an implementation of Runnable interface and overrides run method to defined actual task performed by that TimerTask. 2) Both Timer and TimerTask provides cancel() method. Timer's cancel() method cancels whole timer while TimerTask's one cancels only a particular task. I think this is the wroth noting difference between Timer and TimerTask in Java.
  • 10. Page | - 10 - Canceling Timer in Java Now talking about the cancelation of Timer task in java, You can cancel Java Timer by calling cancel() method of java.util.Timer class, this would result in following: 1)Timer will not cancel any currently executing task. 2)Timer will discard other scheduled task and will not execute them. 3)Once currently executing task will be finished, timer thread will terminate gracefully. 4) Calling Timer.cancel() more than one time will not affect. second call will be ignored. In addition to cancelling Timer, You can also cancel individual TimerTask by using cancel() method of TimerTask itself.
  • 11. Page | - 11 - Important points on Timer and TimerTask in Java Now as we have got a knowledge about Timer and TimerTask in Java, we need to remember the following points: 1.One Thread will be created corresponding ot each Timer in Java, which could be either daemon or user thread. 2.You can schedule multiple TimerTask with one Timer. 3.You can schedule task for either one time execution or recurring execution. 4.TimerTask.cancel() cancels only that particular task, while Timer.cancel() cancel all task scheduled in Timer. 5.Timer in Java will throw IllegalStateException if you try to schedule task on a Timer which has been cancelled or whose Task execution Thread has been terminated.
  • 12. Page | - 12 - When there is a need to trigger a task automatically based on time we should schedule it using a timer api. The requirement can vary from a single execution on a fixed time to high complex recurring event. For example take our regular alarm clock where we fix a time and it beeps coming day on the fixed time. Similarly a high complex example would be the MS outlook where we can schedule events with a different combination. Following are the things in consideration When does the event starts (first time) execution – It may be a day / date / time in future. Is it a one time event or a recurring event? If recurring, what is the periodicity? – In recurrence there are two types, like all the events will be on a fixed time which is planned at the time of scheduling. It may be daily / weekly / monthly / yearly / a day of a week / alternate days / only working days. Second type is, the recurring event can start after the completion of previous occurrence. There can be a delay between events.
  • 13. Page | - 13 - When does it end, after a constant number of executions or after a time is reached like till Friday only. java.util.Timer and TimerTask : It gives facility to schedule a task for future execution in a background thread. Task can be scheduled for single or recurring execution. In recurrence, consecutive tasks will have regular intervals. Timer has got a cancel method using which all the scheduled tasks can be cancelled. Timer can be chosen to run as a daemon thread. It can be scheduled to start with respect to current time using fixed-delay. TimerTask is a thread handle using which we register tasks with the timer.
  • 14. Page | - 14 - Important Variations: This api provides two important variations that needs to be noted. Fixed-delay Each task execution is scheduled relative to the actual execution time of the previous execution. So what is actual execution? This says that, there is no guarantee that the task will be executed at the pre-planned time and it may be delayed due to garbage collection or some background activity. We should also not confuse with triggering of task and completion of task. Triggering is the moment at which the Timer fires start a task. If a thread is asked to send email, it may wait for access to the resource like mail server. Only after the email is sent this task is considered to be completed. We need to have this duration in mind when we schedule recurrence tasks. If the recurrence time is shorter and already the previous task is not completed, the subsequent tasks will join the queue.
  • 15. Page | - 15 - Fixed-rate Here each recurring tasks are scheduled relative to the start time of the timer. If there is any delay in execution subsequent executions will occur in quick succession to catch up with the original scheduled time. In previous case, subsequent execution will depend on just previous execution time.
  • 16. Page | - 16 - Project scope: This project is developed for anybody who is busy doing multiple tasks on his system and wants an application to run at a specific time but has a chance that he might not remember to start it. Hence by using it he can save his time, remain stress free, do his work and leave rest on our developed application. Methodology: User needs to run the application. The user has a option of “select file/Program” he wants to run at the specific time. If the user successfully selects it, the application asks him the time at which he want to run that file/program. And after desired value when he clicks OK then the timer starts and then after desired time given by user the selected file/program execution takes place .
  • 17. Page | - 17 - Software Requirements:  Netbeans Hardware Requirements:  Processor: Preferably 1.0 GHz or greater.  RAM: 512 MB or Greater Future Enhancements: To make it available at Windows Market so that the common people can also use it and take maximum benefit of this application.
  • 18. Page | - 18 - SCREENSHOTS OF WORKING APPLICATION(USER MANUAL) : 1.When the application starts it looks like this. User sees a window in which the name of application Run@timer is displayed and also option to Select file /Program is there. The look and feel of the application is made very easy to use and user friendly.
  • 19. Page | - 19 - 2.Then to start the application, user has to click the Select File/Program button.
  • 20. Page | - 20 - 3.As soon as the user clicks the button, a File chooser window opens and we select file.
  • 21. Page | - 21 - 4.When we open it we can browse anywhere for file in the computer. As in this example user is selecting music folder and then a song from that folder.
  • 22. Page | - 22 -
  • 23. Page | - 23 - 5.As soon as he clicks the open button, he returns to the main window and then he is asked to put the timer.
  • 24. Page | - 24 - 6.The user selects the time, as in this example , he selected 1 minute:
  • 25. Page | - 25 - 7.Then he clicks Strt which is the button ehich starts the timer of the application:
  • 26. Page | - 26 - 8.The timer starts and the second window opens where he can see the time getting reduced second by second:
  • 27. Page | - 27 -
  • 28. Page | - 28 -
  • 29. Page | - 29 - 9.When the timer time which was given by user completes, a message is displayed which says successfully executed and then, we get this screen.
  • 30. Page | - 30 - 10.As the user selected the song , we can see that the song is played as soon as the time completes.
  • 31. Page | - 31 - Coding Screenshots to prove the project is a pure innovational concept and is not copied from anywhere: For the first frame: 1.
  • 32. Page | - 32 -
  • 33. Page | - 33 -
  • 34. Page | - 34 - For the second frame:
  • 35. Page | - 35 -
  • 36. Page | - 36 -
  • 37. Page | - 37 -
  • 38. Page | - 38 -
  • 39. Page | - 39 - Detailed and clear coding for the first Frame of application: /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author swapnil dubey */ import java.awt.Desktop; import java.awt.Toolkit; import java.awt.event.WindowEvent; import java.io.File; import java.net.URL; import javax.swing.JFileChooser; import javax.swing.JOptionPane; public class FirstFrame extends javax.swing.JFrame { /** * Creates new form FirstFrame */ public FirstFrame() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabel1 = new javax.swing.JLabel(); jTextField1 = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jSpinner1 = new javax.swing.JSpinner(); jSpinner2 = new javax.swing.JSpinner();
  • 40. Page | - 40 - jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jButton2 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_O N_CLOSE); jLabel1.setFont(new java.awt.Font("Lucida Sans", 1, 48)); // NOI18N jLabel1.setForeground(new java.awt.Color(255, 0, 0)); jLabel1.setText("Run@timer"); jButton1.setText("Select File/Program"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jSpinner1.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1))); jSpinner2.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(5))); jLabel2.setText("minutes"); jLabel3.setText("hours"); jButton2.setFont(new java.awt.Font("Times New Roman", 1, 48)); // NOI18N jButton2.setForeground(new java.awt.Color(255, 0, 102)); jButton2.setIcon(new javax.swing.ImageIcon("C:Usersswapnil dubeyDesktopicon-start-play-128.png")); // NOI18N jButton2.setText("Start"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } });
  • 41. Page | - 41 - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L EADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.A lignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(130, 130, 130) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 287, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(40, 40, 40) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 385, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jButton1)) .addGroup(layout.createSequentialGroup() .addGap(153, 153, 153) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 340, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(115, 115, 115) .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(26, 26, 26) .addComponent(jLabel2) .addGap(43, 43, 43) .addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(32, 32, 32) .addComponent(jLabel3))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L EADING) .addGroup(layout.createSequentialGroup()
  • 42. Page | - 42 - .addGap(46, 46, 46) .addComponent(jLabel1) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.A lignment.BASELINE) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.A lignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(83, 83, 83) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.A lignment.TRAILING) .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2))) .addGroup(layout.createSequentialGroup() .addGap(85, 85, 85) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.A lignment.TRAILING) .addComponent(jLabel3) .addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RE LATED, 73, Short.MAX_VALUE) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(27, 27, 27)) ); pack(); }// </editor-fold>//GEN-END:initComponents public void close(){ WindowEvent winClosingEvent = new WindowEvent(this,WindowEvent.WINDOW_CLOSING); Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(wi nClosingEvent);
  • 43. Page | - 43 - } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed JFileChooser fileChooser = new JFileChooser(); int returnValue = fileChooser.showOpenDialog(null); if (returnValue== JFileChooser.APPROVE_OPTION) { File file=fileChooser.getSelectedFile(); jTextField1.setText(file.getAbsolutePath()); ff=jTextField1.getText(); } }//GEN-LAST:event_jButton1ActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed if("".equals(jTextField1.getText())) { JOptionPane.showMessageDialog(this, "Select a file or process first", "Warning", JOptionPane.ERROR_MESSAGE); } else{ close(); int mins=Integer.valueOf(jSpinner1.getValue().toString()); int hours=Integer.valueOf(jSpinner2.getValue().toString()); int tot=(hours*60)+mins; if(tot==0) JOptionPane.showMessageDialog(this, "Timer can't be Zero", "Warning", JOptionPane.ERROR_MESSAGE); else { seconds=60*tot; SecondFrame form= new SecondFrame(); form.setLocationRelativeTo(null); form.setVisible(true); } } }//GEN-LAST:event_jButton2ActionPerformed /** * @param args the command line arguments */ static String ff; static int seconds;
  • 44. Page | - 44 - public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel /plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(FirstFrame.class.getName()) .log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(FirstFrame.class.getName()) .log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(FirstFrame.class.getName()) .log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(FirstFrame.class.getName()) .log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new FirstFrame().setVisible(true); } }); } // Variables declaration - do not modify//GEN- BEGIN:variables
  • 45. Page | - 45 - private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JSpinner jSpinner1; private javax.swing.JSpinner jSpinner2; private javax.swing.JTextField jTextField1; // End of variables declaration//GEN-END:variables }
  • 46. Page | - 46 - Detailed coding for the second Frame: /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.awt.Desktop; import java.io.File; import java.io.IOException; import java.util.Timer; import java.util.TimerTask; /** * * @author swapnil dubey */ public class SecondFrame extends javax.swing.JFrame { /** * Creates new form SecondFrame */ public SecondFrame() { initComponents(); startime(); } TimerTask task = new SecondFrame.RunMeTask1(); Timer timer = new Timer(); public void startime() { jTextField1.setText(s); timer.schedule(task, 0,1000); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabel1 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane();
  • 47. Page | - 47 - jTextField1 = new javax.swing.JTextField(); jLabel2 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_C LOSE); jLabel1.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N jLabel1.setText("To Run"); jScrollPane1.setViewportView(jTextField1); jButton1.setFont(new java.awt.Font("Tahoma", 1, 48)); // NOI18N jButton1.setForeground(new java.awt.Color(255, 0, 102)); jButton1.setIcon(new javax.swing.ImageIcon("C:Usersswapnil dubeyDesktopcancel_red.png")); // NOI18N jButton1.setText("Stop"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L EADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.A lignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel1) .addGap(32, 32, 32) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 363, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(71, 71, 71)
  • 48. Page | - 48 - .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 385, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(166, 166, 166) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 301, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(44, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L EADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.A lignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(73, 73, 73) .addComponent(jLabel1)) .addGroup(layout.createSequentialGroup() .addGap(50, 50, 50) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(74, 74, 74) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RE LATED, 47, Short.MAX_VALUE) .addComponent(jButton1) .addGap(35, 35, 35)) ); pack(); }// </editor-fold>//GEN-END:initComponents FirstFrame steg = new FirstFrame(); String s=steg.ff; private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed timer.cancel(); jLabel2.setText("Stopped"); }//GEN-LAST:event_jButton1ActionPerformed public class RunMeTask1 extends TimerTask { int seconds=steg.seconds;
  • 49. Page | - 49 - public void run() { if (seconds > 0) { int r=seconds/60; int rem=seconds%60; int hr=r/60; int rr=r%60; if(r==0) { jLabel2.setText(seconds + " secs Remaining"); seconds--; } else if(hr==0) { jLabel2.setText(r+" Mins and "+rem+" secs Remaining"); seconds--; } else { jLabel2.setText(hr+" hours "+rr+" Mins and "+rem+" secs Remaining"); seconds--; } } else if(seconds==-1) { return; } else if(seconds==0) { try{ File f = new File(s); Desktop dt = Desktop.getDesktop(); dt.open(f); }catch(IOException e){ e.printStackTrace(); } jLabel2.setText(" Successfully Executed "); seconds=-1; //System.exit(0); } }
  • 50. Page | - 50 - } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel /plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(SecondFrame.class.getName() ).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(SecondFrame.class.getName() ).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(SecondFrame.class.getName() ).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(SecondFrame.class.getName() ).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new SecondFrame().setVisible(true); } }); }
  • 51. Page | - 51 - // Variables declaration - do not modify//GEN- BEGIN:variables private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTextField jTextField1; // End of variables declaration//GEN-END:variables }
  • 52. Page | - 52 - Detailed coding for main class : /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author swapnil dubey */ public class main { /** * @param args the command line arguments */ public static void main(String[] args) { FirstFrame form=new FirstFrame (); form.setLocationRelativeTo(null); form.setVisible(true); } }
  • 53. Page | - 53 - Conclusion: Applications like this should be developed more frequently so that more amount of work can be done in a short span of time and not worrying anything about the upcoming tasks.
  • 54. Page | - 54 - Refrences: www.google.com www.wickepedia.org www.examples.codegeeks.com/core-java www.javarevisited.blogspot.in www.mkyong.com/java