import java.util.Calendar;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
/**
*
* @author RK
*/
public class ClockFrame extends javax.swing.JFrame implements Runnable
{
/** Creates new form ClockFrame */
Calendar cal=null;
Thread thr=null;
private int INFORMATION_MESSAGE=1;
public ClockFrame()
{
this.setUndecorated(true);
this.setResizable(false);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setVisible(true);
this.setSize(220,300);
initComponents();
cal=Calendar.getInstance();
Hour.setMinorTickSpacing(1);
Hour.setBorder(BorderFactory.createTitledBorder("Hours"));
Hour.setMajorTickSpacing(1);
Hour.setPaintTicks(true);
Hour.setPaintLabels(true);
//Minute=new JSlider(0,59,5);
Minute.setBorder(BorderFactory.createTitledBorder("Minutes"));
Minute.setMajorTickSpacing(5);
Minute.setMinorTickSpacing(1);
Minute.setPaintTicks(true);
Minute.setPaintLabels(true);
Minute.getLabelTable().put(new Integer(59),new JLabel(new Integer(59).toString(), JLabel.CENTER));
Minute.setLabelTable( Minute.getLabelTable() );
Second.setBorder(BorderFactory.createTitledBorder("Seconds"));
Second.setMajorTickSpacing(5);
Second.setMinorTickSpacing(1);
Second.setPaintTicks(true);
Second.setPaintLabels(true);
Second.getLabelTable().put(new Integer(59),new JLabel(new Integer(59).toString(), JLabel.CENTER));
Second.setLabelTable( Second.getLabelTable() );
by.setToolTipText("rajkirpal.er@live.com");
thr=new Thread(this,"TIME");
thr.start();
}
/** 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")
//
private void initComponents() {
Hour = new javax.swing.JSlider();
Minute = new javax.swing.JSlider();
Second = new javax.swing.JSlider();
FullDate = new javax.swing.JLabel();
WeekDay = new javax.swing.JLabel();
SpHr = new javax.swing.JSpinner();
SpMn = new javax.swing.JSpinner();
SpSc = new javax.swing.JSpinner();
by = new javax.swing.JLabel();
am_pm = new javax.swing.JLabel();
close = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(null);
Hour.setBackground(new java.awt.Color(255, 153, 0));
Hour.setForeground(new java.awt.Color(0, 0, 0));
Hour.setMajorTickSpacing(1);
Hour.setMaximum(12);
Hour.setMinimum(1);
Hour.setMinorTickSpacing(1);
Hour.setOrientation(javax.swing.JSlider.VERTICAL);
Hour.setPaintLabels(true);
Hour.setPaintTicks(true);
Hour.setSnapToTicks(true);
Hour.setValue(1);
Hour.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 0))); // NOI18N
getContentPane().add(Hour);
Hour.setBounds(20, 10, 60, 200);
Minute.setBackground(new java.awt.Color(255, 255, 255));
Minute.setMajorTickSpacing(5);
Minute.setMaximum(59);
Minute.setMinorTickSpacing(1);
Minute.setOrientation(javax.swing.JSlider.VERTICAL);
Minute.setPaintLabels(true);
Minute.setPaintTicks(true);
Minute.setSnapToTicks(true);
Minute.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 0))); // NOI18N
getContentPane().add(Minute);
Minute.setBounds(80, 10, 60, 200);
Second.setBackground(new java.awt.Color(102, 153, 0));
Second.setMajorTickSpacing(5);
Second.setMaximum(59);
Second.setMinorTickSpacing(1);
Second.setOrientation(javax.swing.JSlider.VERTICAL);
Second.setPaintLabels(true);
Second.setPaintTicks(true);
Second.setSnapToTicks(true);
Second.setValue(1);
Second.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 0))); // NOI18N
getContentPane().add(Second);
Second.setBounds(140, 10, 60, 200);
FullDate.setFont(new java.awt.Font("Arial", 0, 14));
FullDate.setText(":");
getContentPane().add(FullDate);
FullDate.setBounds(130, 250, 70, 17);
WeekDay.setFont(new java.awt.Font("Arial", 0, 14));
WeekDay.setText(":");
getContentPane().add(WeekDay);
WeekDay.setBounds(30, 250, 90, 14);
getContentPane().add(SpHr);
SpHr.setBounds(30, 220, 40, 20);
getContentPane().add(SpMn);
SpMn.setBounds(70, 220, 40, 20);
getContentPane().add(SpSc);
SpSc.setBounds(110, 220, 40, 20);
by.setText(" By R.K");
getContentPane().add(by);
by.setBounds(140, 270, 80, 14);
am_pm.setText(":");
getContentPane().add(am_pm);
am_pm.setBounds(160, 220, 60, 20);
close.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
close.setForeground(new java.awt.Color(255, 0, 0));
close.setText(" X");
close.setToolTipText("CLOSE");
close.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
closeMouseClicked(evt);
}
});
getContentPane().add(close);
close.setBounds(0, 260, 20, 30);
pack();
}// //GEN-END:initComponents
private void closeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_closeMouseClicked
// TODO add your handling code here:
this.dispose();
System.exit(0);
}//GEN-LAST:event_closeMouseClicked
/**
* @param RK the command line arguments
*/
public static void main(String RK[]) {
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e)
{}
ClockFrame win=new ClockFrame();
win.setLocation(550, 05);
win.setSize(220,290);
win.setVisible(true);
win.setTitle("STRIPE CLOCK");
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel FullDate;
private javax.swing.JSlider Hour;
private javax.swing.JSlider Minute;
private javax.swing.JSlider Second;
private javax.swing.JSpinner SpHr;
private javax.swing.JSpinner SpMn;
private javax.swing.JSpinner SpSc;
private javax.swing.JLabel WeekDay;
private javax.swing.JLabel am_pm;
public javax.swing.JLabel by;
private javax.swing.JLabel close;
// End of variables declaration//GEN-END:variables
@SuppressWarnings("static-access")
public void run()
{
try
{
while(true)
{
thr.sleep(100);
cal=Calendar.getInstance();
int hr=cal.get(Calendar.HOUR);
int min=cal.get(Calendar.MINUTE);
int sec=cal.get(Calendar.SECOND);
int ampm=cal.get(Calendar.AM_PM);
if(ampm==0)
{
am_pm.setText("AM");
}
else
{
am_pm.setText("PM");
}
if(hr==0)
{
hr=12;
}
Hour.setValue(hr);
Minute.setValue(min);
Second.setValue(sec);
SpHr.setValue(hr);
SpMn.setValue(min);
SpSc.setValue(sec);
int day=cal.get(Calendar.DAY_OF_MONTH);
int month=cal.get(Calendar.MONTH);
int year=cal.get(Calendar.YEAR);
int weekday=cal.get(Calendar.DAY_OF_WEEK);
switch(weekday)
{
case 1:
WeekDay.setText("Sunday");
break;
case 2:
WeekDay.setText("Monday");
break;
case 3:
WeekDay.setText("Tuesday");
break;
case 4:
WeekDay.setText("Wednesday");
break;
case 5:
WeekDay.setText("Thursday");
break;
case 6:
WeekDay.setText("Friday");
break;
case 7:
WeekDay.setText("Saturday");
break;
default:
break;
}
FullDate.setText(day+"/"+month+"/"+year);
}
}catch(Exception e)
{
JOptionPane.showMessageDialog(null,"ERROR WHILE RTRIEVING TIME INFORMATION","ERROR",INFORMATION_MESSAGE);
}
}
}
can you please send me this project? Actually i dont have the knowledge to get the coding in sequenced folders so i cant create a whole project out of this code. Can you like send me this project in a zip file? thanks in advance :)
ReplyDelete