-
Notifications
You must be signed in to change notification settings - Fork 1
/
HolidayRequest.java
104 lines (98 loc) · 2.62 KB
/
HolidayRequest.java
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import javax.swing.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
public class HolidayRequest //extends JFrame implements ActionListener
{
public static void main(String[] args)
{
String[] colours = {"b","g","y"};
JComboBox box = new JComboBox(colours);
int result;
do
{
String[] choice = {"Enter Your UserName", "Holidays Avaliblity", "Quit"};
result = JOptionPane.showOptionDialog
(null,"Choose an option", "Holiday Request",
JOptionPane.DEFAULT_OPTION,
JOptionPane.PLAIN_MESSAGE,
null, choice, "Enter a word");
switch(result)
{
case 0: enterUserName();
break;
case 1: HolidaysAvaliblity();
break;
}
}
while(result != 2);
System.exit(0);
}
/*String[] colours = {"b","g","y"};
JComboBox box = new JComboBox(colours);
public HolidayRequest()
{
setTitle("Combom Box");
setLayout(new FlowLayout());
add(box);
box.addActionListener(this);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(250, 250);
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
String item = (String) box.getSelectedItem();
if(item.equals("b"))
{
getContentPane().setBackground(Color.red);
}
box.setSelectedIndex(0);
}*/
private static void enterUserName()
{
char first, last;
String word, message;
word = JOptionPane.showInputDialog(null, "EnterUserID",null,
JOptionPane.PLAIN_MESSAGE);
if(word != null)
{
if(word.length() != 0)
{
word = word.toUpperCase();
first = word.charAt(0);
last = word.charAt(word.length() -1);
if(first == last)
{
message = "You entered the Correct ID \n StartDate Request \n EndDate";
}
else
{
message = "you did not enter the Correct ID";
}
JOptionPane.showMessageDialog(null, message, null,
JOptionPane.INFORMATION_MESSAGE);
}
else
{
message = "you did not enter the Correct ID!";
JOptionPane.showMessageDialog(null, message, null,
JOptionPane.ERROR_MESSAGE);
}
}
}
private static void HolidaysAvaliblity()
{
int answer;
answer = JOptionPane.showConfirmDialog(null,
"are you sure you want to know the avaliblities?",
null,
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
if(answer == JOptionPane.YES_OPTION)
{
JOptionPane.showMessageDialog(null,
"The Avaliblity Table is listed below");
}
}
}