Hello
I'm new learner in java, and I'm facing a problem to develop a Java application that will ask the user for the time in terms of hour and minutes and display the time by drawing a clock.
I have created two classes, and the code is below.
Please could you figure out my problem in the code.
this is the main class
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package lab4;
import java.awt.*;
import javax.swing.*;
/**
*
* @author Alsobhi
*/
public class ClockDisplays extends JFrame
{
public class ClockDisplay
{
// TO creat a frame that the user can enters Hour and minutes
/**
*
*
*/
SimpleClock clock = new SimpleClock();
MessagePanel mp = new MessagePanel(clock.getHour()+":"+clock.getMinute()+":"+clock.getSecond());
// add(clock);
// add(mp,BorderLayout.South);
}
public static void main (String[] args)
{
ClockDisplays frame = new ClockDisplays();
frame.setTitle("DisplayClock");
frame.setSize(400, 400);
frame.setLocationRelativeTo(null); // center the frame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
String stringHours;
// The user enters the hour and minutes
stringHours = JOptionPane.showInputDialog("Enter the hour:");
int hour = Integer.parseInt(stringHours);
String StringMinute = JOptionPane.showInputDialog ("Enter the minute");
int minute = Integer.parseInt(StringMinute);
SimpleClock sc = new SimpleClock();
sc.setHour(hour);
sc.setMinute(minute);
}
}