Hello,
I'm really new to doing Java only been doing it about 2 month so really a novice. I'm currently attempting to make my first app that is not a school project. I want to embed the current time in my application that is pulled from the local system. It is a time card program and when I create my time function I'm just unsure where to call it so that it comes up in the main frame. If I'm making any glaring errors please be gentle ass this is also my first time posting on this site.
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.Border;
import java.util.Calendar;
import java.text.SimpleDateFormat;
public class TimeCard {
int Date;
int Time;
int Hours;
int timeStart;
int timeStop;
int time2Start;
int time2Stop;
public TimeCard() {
}
/**
* @param args
*/
public static void myWindow() {
JFrame mainFrame = new JFrame("Time Card"); // Creates JFrame object
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainFrame.setSize(600,400); // Size of JFrame 600x400.
mainFrame.setVisible(true); // Make Visible
// Create a panel and add components to it
JPanel cPane = new JPanel();
// Create a Content Pane lowered and sunk in
Border loweredbevel = BorderFactory.createLoweredBevelBorder();
cPane.setBorder(loweredbevel);
mainFrame.add(cPane);
JOptionPane.showMessageDialog(cPane, "Welcome to Time Card");
}
public String timeNow(){
Calendar cal = Calendar.getInstance();
String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
return sdf.format(cal.getTime());
}
public static void main(String[] args) {