package McWoo;
import java.awt.Font;
import java.sql.Date;
import java.sql.Time;
import java.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.xml.stream.Location;
import org.xml.sax.Locator;
public class Testing extends JFrame {
private JMenu menu,menu2,menu3, menu4;
private JMenuBar mBar;
private JPanel panel;
public Testing()
{
setTitle("Testing");
panel = new JPanel();
panel.setVisible(true);
mBar = new JMenuBar();
setJMenuBar(mBar);
mBar.setVisible(true);
menu = new JMenu("");
mBar.add(menu);
menu2 = new JMenu("");
mBar.add(menu2);
menu3 = new JMenu("");
mBar.add(menu3);
menu4 = new JMenu("");
mBar.add(menu4);
Calendar c = Calendar.getInstance();
Locale[] loc = c.getAvailableLocales() ;
System.out.println(loc[0].getDisplayName());
System.out.println(Locale.getDefault().getDisplayName());
menu4.setText("Language(Country): " + Locale.getDefault().getDisplayName());
System.out.println("Is Visible:" + this.isVisible());
if(panel.isVisible())
{
int hour = c.get(Calendar.HOUR);
int meridan = c.get(Calendar.AM_PM);
int minute = c.get(Calendar.MINUTE);
int second = c.get(Calendar.SECOND);
if (meridan == Calendar.AM)
{
if (minute < 10 && second < 10)
menu2.setText(hour + ":" + "0" + minute+ ":" + "0" + second + " A.M.");
else if (minute < 10 && second >=10)
menu2.setText(hour + ":" + "0" + minute+ ":" + second + " A.M.");
else if (second < 10 && minute >=10)
menu2.setText(hour + ":" + minute+ ":" + "0" + second + " A.M.");
else
menu2.setText(hour + ":" + minute+ ":" + second + " A.M.");
}
else
{
if (minute < 10 && second < 10)
menu2.setText(hour + ":" + "0" + minute+ ":" + "0" + second + " P.M.");
else if (minute < 10 && second >=10)
menu2.setText(hour + ":" + "0" + minute+ ":" + second + " P.M.");
else if (second < 10 && minute >=10)
menu2.setText(hour + ":" + minute+ ":" + "0" + second + " P.M.");
else
menu2.setText(hour + ":" + minute+ ":" + second + " P.M.");
}
}
System.out.println(Calendar.SATURDAY);
String str = "Time Zone is: " + c.getTimeZone().getID();
menu3.setText(str);
c.setFirstDayOfWeek(Calendar.SUNDAY);
System.out.println(c.getFirstDayOfWeek());
int weekday = c.get(Calendar.DAY_OF_WEEK);
System.out.println("Weekday " +weekday);
int monthDay = c.get(Calendar.DAY_OF_MONTH);
int month = c.get(Calendar.MONTH);
int year = c.get(Calendar.YEAR);
System.out.println(weekday);
TimeZone t2 = c.getTimeZone();
System.out.println(t2.toString());
menu.setToolTipText("This is the menu when the program was opened, which usually will be the same day as today.");
Font aFont= menu.getFont();
Font anotherFont = aFont.deriveFont(Font.BOLD);
menu.setFont(anotherFont);
if (month == Calendar.JANUARY)
{
if (weekday ==1 )
{
menu.setText("Sunday January " + monthDay + "," + year);
}
else if (weekday ==2 )
{
menu.setText("Monday January " + monthDay + "," + year);
}
else if (weekday == 3)
{
menu.setText("Tuesday January " + monthDay + "," + year);
}
else if (weekday ==4 )
{
menu.setText("Wednesday January " + monthDay + "," + year);
}
else if (weekday == 5)
{
menu.setText("Thursday January " + monthDay + "," + year);
}
else if (weekday ==6)
{
menu.setText("Friday January " + monthDay + "," + year);
}
else
menu.setText("Saturday January " + monthDay + "," + year);
}
else if (month == Calendar.FEBRUARY)
{
if (weekday == 1)
{
menu.setText("Sunday February " + monthDay + "," + year);
}
else if (weekday ==2)
{
menu.setText("Monday February " + monthDay + "," + year);
}
else if (weekday ==3)
{
menu.setText("Tuesday February " + monthDay + "," + year);
}
else if (weekday ==4)
{
menu.setText("Wednesday February " + monthDay + "," + year);
}
else if (weekday ==5)
{
menu.setText("Thursday February " + monthDay + "," + year);
}
else if (weekday ==6)
{
menu.setText("Friday February " + monthDay + "," + year);
}
else
menu.setText("Saturday February " + monthDay + "," + year);
}
else if (month == Calendar.MARCH)
{
if (weekday ==1)
{
menu.setText("Sunday March " + monthDay + "," + year);
}
else if (weekday ==2)
{
menu.setText("Monday March " + monthDay + "," + year);
}
else if (weekday ==3)
{
menu.setText("Tuesday March " + monthDay + "," + year);
}
else if (weekday ==4)
{
menu.setText("Wednesday March " + monthDay + "," + year);
}
else if (weekday == 5)
{
menu.setText("Thursday March " + monthDay + "," + year);
}
else if (weekday ==6)
{
menu.setText("Friday March " + monthDay + "," + year);
}
else
menu.setText("Saturday March " + monthDay + "," + year);
}
else if (month == Calendar.APRIL)
{
if (weekday ==1)
{
menu.setText("Sunday April " + monthDay + "," + year);
}
else if (weekday ==2)
{
menu.setText("Monday April " + monthDay + "," + year);
}
else if (weekday ==3)
{
menu.setText("Tuesday April " + monthDay + "," + year);
}
else if (weekday ==4)
{
menu.setText("Wednesday April " + monthDay + "," + year);
}
else if (weekday ==5)
{
menu.setText("Thursday April " + monthDay + "," + year);
}
else if (weekday ==6)
{
menu.setText("Friday April " + monthDay + "," + year);
}
else
menu.setText("Saturday April " + monthDay + "," + year);
}
else if (month == Calendar.MAY)
{
if (weekday ==1)
{
menu.setText("Sunday May " + monthDay + "," + year);
}
else if (weekday ==2)
{
menu.setText("Monday May " + monthDay + "," + year);
}
else if (weekday ==3)
{
menu.setText("Tuesday May " + monthDay + "," + year);
}
else if (weekday ==4)
{
menu.setText("Wednesday May " + monthDay + "," + year);
}
else if (weekday ==5)
{
menu.setText("Thursday May " + monthDay + "," + year);
}
else if (weekday ==6)
{
menu.setText("Friday May " + monthDay + "," + year);
}
else
menu.setText("Saturday May " + monthDay + "," + year);
}
else if (month== Calendar.JUNE)
{
if (weekday ==1)
{
menu.setText("Sunday June " + monthDay + "," + year);
}
else if (weekday ==2)
{
menu.setText("Monday June " + monthDay + "," + year);
}
else if (weekday ==3)
{
menu.setText("Tuesday June " + monthDay + "," + year);
}
else if (weekday ==4)
{
menu.setText("Wednesday June " + monthDay + "," + year);
}
else if (weekday ==5)
{
menu.setText("Thursday June " + monthDay + "," + year);
}
else if (weekday ==6)
{
menu.setText("Friday June " + monthDay + "," + year);
}
else
menu.setText("Saturday June " + monthDay + "," + year);
}
else if (month == Calendar.JULY)
{
if (weekday ==1)
{
menu.setText("Sunday July " + monthDay + "," + year);
}
else if (weekday ==2)
{
menu.setText("Monday July " + monthDay + "," + year);
}
else if (weekday ==3)
{
menu.setText("Tuesday July " + monthDay + "," + year);
}
else if (weekday ==4)
{
menu.setText("Wednesday July " + monthDay + "," + year);
}
else if (weekday ==5)
{
menu.setText("Thursday July " + monthDay + "," + year);
}
else if (weekday ==6)
{
menu.setText("Friday July " + monthDay + "," + year);
}
else
menu.setText("Saturday July " + monthDay + "," + year);
}
else if (month == Calendar.AUGUST)
{
if (weekday ==1)
{
menu.setText("Sunday August " + monthDay + "," + year);
}
else if (weekday ==2)
{
menu.setText("Monday August " + monthDay + "," + year);
}
else if (weekday ==3)
{
menu.setText("Tuesday August " + monthDay + "," + year);
}
else if (weekday ==4)
{
menu.setText("Wednesday August " + monthDay + "," + year);
}
else if (weekday ==5)
{
menu.setText("Thursday August " + monthDay + "," + year);
}
else if (weekday ==6)
{
menu.setText("Friday August " + monthDay + "," + year);
}
else
menu.setText("Saturday August " + monthDay + "," + year);
}
else if (month ==Calendar.SEPTEMBER)
{
if (weekday ==1)
{
menu.setText("Sunday September " + monthDay + "," + year);
}
else if (weekday ==2)
{
menu.setText("Monday September " + monthDay + "," + year);
}
else if (weekday ==3)
{
menu.setText("Tuesday September " + monthDay + "," + year);
}
else if (weekday ==4)
{
menu.setText("Wednesday September " + monthDay + "," + year);
}
else if (weekday ==5)
{
menu.setText("Thursday September " + monthDay + "," + year);
}
else if (weekday ==6)
{
menu.setText("Friday September " + monthDay + "," + year);
}
else
menu.setText("Saturday September " + monthDay + "," + year);
}
else if (month== Calendar.OCTOBER)
{
if (weekday ==1)
{
menu.setText("Sunday October " + monthDay + "," + year);
}
else if (weekday ==2)
{
menu.setText("Monday October " + monthDay + "," + year);
}
else if (weekday ==3)
{
menu.setText("Tuesday October " + monthDay + "," + year);
}
else if (weekday ==4)
{
menu.setText("Wednesday October " + monthDay + "," + year);
}
else if (weekday ==5)
{
menu.setText("Thursday October " + monthDay + "," + year);
}
else if (weekday ==6)
{
menu.setText("Friday October " + monthDay + "," + year);
}
else
menu.setText("Saturday October " + monthDay + "," + year);
}
else if (month==Calendar.NOVEMBER)
{
if (weekday ==1)
{
menu.setText("Sunday November " + monthDay + "," + year);
}
else if (weekday ==2)
{
menu.setText("Monday November " + monthDay + "," + year);
}
else if (weekday ==3)
{
menu.setText("Tuesday November " + monthDay + "," + year);
}
else if (weekday ==4)
{
menu.setText("Wednesday November " + monthDay + "," + year);
}
else if (weekday ==5)
{
menu.setText("Thursday November " + monthDay + "," + year);
}
else if (weekday ==6)
{
menu.setText("Friday November " + monthDay + "," + year);
}
else
menu.setText("Saturday November " + monthDay + "," + year);
}
else
{
if (weekday ==1)
{
menu.setText("Sunday December " + monthDay + "," + year);
}
else if (weekday ==2)
{
menu.setText("Monday December " + monthDay + "," + year);
}
else if (weekday ==3)
{
menu.setText("Tuesday December " + monthDay + "," + year);
}
else if (weekday ==4)
{
menu.setText("Wednesday December " + monthDay + "," + year);
}
else if (weekday ==5)
{
menu.setText("Thursday December " + monthDay + "," + year);
}
else if (weekday ==6)
{
menu.setText("Friday December " + monthDay + "," + year);
}
else
menu.setText("Saturday December " + monthDay + "," + year);
}
setContentPane(panel);
}
public void update(JMenu menu2)
{
Calendar c2 = Calendar.getInstance();
int hour = c2.get(Calendar.HOUR);
int meridan = c2.get(Calendar.AM_PM);
int minute = c2.get(Calendar.MINUTE);
int second = c2.get(Calendar.SECOND);
if (meridan == Calendar.AM)
{
if (minute < 10 && second < 10)
menu2.setText(hour + ":" + "0" + minute+ ":" + "0" + second + " A.M.");
else if (minute < 10 && second >=10)
menu2.setText(hour + ":" + "0" + minute+ ":" + second + " A.M.");
else if (second < 10 && minute >=10)
menu2.setText(hour + ":" + minute+ ":" + "0" + second + " A.M.");
else
menu2.setText(hour + ":" + minute+ ":" + second + " A.M.");
}
else
{
if (minute < 10 && second < 10)
menu2.setText(hour + ":" + "0" + minute+ ":" + "0" + second + " P.M.");
else if (minute < 10 && second >=10)
menu2.setText(hour + ":" + "0" + minute+ ":" + second + " P.M.");
else if (second < 10 && minute >=10)
menu2.setText(hour + ":" + minute+ ":" + "0" + second + " P.M.");
else
menu2.setText(hour + ":" + minute+ ":" + second + " P.M.");
}
}
public static void main(String[] args)
{
Testing t = new Testing();
t.setVisible(true);
}
}