- Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathDayOfWeek_project.java
More file actions
Latest commit
57 lines (51 loc) · 1.41 KB
/
Copy pathDayOfWeek_project.java
File metadata and controls
57 lines (51 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
importjavax.swing.*;
importjava.awt.event.*;
importjava.awt.*;
importjava.io.*;
importjava.util.*;
importjava.text.*;
publicclassDayOfTheWeekService
{
JLabeloutputLabel;
JComboBoxmonth;
JTextFieldday;
JTextFieldyear;
publicJPanelgetGuiPanel()
{
JPanelpanel = newJPanel();
JButtonbutton = newJButton("Let's do it!");
button.addActionListener(newDoItListener());
outputLabel = newJLabel("Date appears here");
DateFormatSymbolsdateStuff = newDateFormatSymbols();
month = newJComboBox(dateStuff.getMonths());
day = newJTextField(8);
year = newJTextField(8);
JPanelinputPanel = newJPanel(newGridLayout(3,2));
inputPanel.add(newJLabel("Month"));
inputPanel.add(month);
inputPanel.add(newJLabel("Day"));
inputPanel.add(day);
inputPanel.add(newJLabel("Year"));
inputPanel.add(year);
panel.add(inputPanel);
panel.add(button);
panel.add(outputLabel);
returnpanel;
}
publicclassDoItListenerimplementsActionListener
{
publicvoidactionPerformed(ActionEventev)
{
intmonthNum = month.getSelectedIndex();
intdayNum = Integer.parseInt(day.getText());
intyearNum = Integer.parseInt(year.getText());
Calendarc = Calendar.getInstance();
c.set(Calendar.MONTH, monthNum);
c.set(Calendar.DAY_OF_MONTH, dayNum);
c.set(Calendar.YEAR, yearNum);
Datedate = c.getTime();
StringdayOfWeek = (newSimpleDateFormat(“EEEE”)).format(date);
outputLabel.setText(dayOfWeek);
}
}
}