-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVowelsAndConsonantsGUI.java
56 lines (50 loc) · 2.08 KB
/
VowelsAndConsonantsGUI.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
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class VowelsAndConsonantsGUI extends JFrame implements ActionListener{
JButton start;
static String alp;
static String a;
VowelsAndConsonantsGUI(){
super("Vowels And Consonants");
setSize(300, 220);
setExtendedState(JFrame.MAXIMIZED_BOTH);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel pane=new JPanel();
start= new JButton("Start");
start.addActionListener(this);
GridLayout bord=new GridLayout();
setLayout(bord);
pane.add(start);
add (pane);
pack();
setVisible(true);
}
public void actionPerformed(ActionEvent evt){
Object source=evt.getSource();
if (source == start){
alp=JOptionPane.showInputDialog(null, "Enter an alphabet", "Alphabet", JOptionPane.QUESTION_MESSAGE);
a=alp.toUpperCase();
if ((a.equals("A"))||(a.equals("E"))||(a.equals("I"))||(a.equals("O"))||(a.equals("U")))
JOptionPane.showMessageDialog(null, "The letter"+" "+alp+" "+"is a vowel", "Answer", JOptionPane.PLAIN_MESSAGE);
else if ((a.equals("B"))||(a.equals("C"))||(a.equals("D"))||(a.equals("F"))||(a.equals("G"))||(a.equals("H"))||(a.equals("J"))||(a.equals("K"))||(a.equals("L"))||(a.equals("M"))||(a.equals("N"))||(a.equals("P"))||(a.equals("Q"))||(a.equals("R"))||(a.equals("S"))||(a.equals("T"))||(a.equals("V"))||(a.equals("W"))||(a.equals("X"))||(a.equals("Y"))||(a.equals("Z")))
JOptionPane.showMessageDialog(null, "The letter"+" "+alp+" "+"is a consonant", "Answer", JOptionPane.PLAIN_MESSAGE);
else
JOptionPane.showMessageDialog(null, "Invalid Input. Please enter an Alphabet.", "Error", JOptionPane.ERROR_MESSAGE);
}
repaint();
}
void setLookAndFeel() {
try{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
SwingUtilities.updateComponentTreeUI(this);
}
catch (Exception exc) {
System.err.println("Couldn't use the system "+"look and feel:"+exc);
}
}
public static void main(String[] args){
VowelsAndConsonantsGUI vacgui=new VowelsAndConsonantsGUI();
vacgui.setLookAndFeel();
}
}