Jace Lander
@jacelander Tasks: 83
๐ ๏ธ 1 tool
๐ 12 karma
Apprentice
Web3, AI, Full-stack Dev
Joined: January 2025
Follow
Jace Lander's tools
-
49911Released 9mo ago100% Free```java import javax.swing.*; import java.awt.*; import java.awt.event.*; public class VowelChecker extends JFrame { private JTextField inputField; private JLabel resultLabel; public VowelChecker() { // Set up the frame setTitle("Vowel Checker"); setSize(300, 150); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new FlowLayout()); // Create and add components JLabel promptLabel = new JLabel("Enter a character:"); inputField = new JTextField(5); JButton checkButton = new JButton("Check"); resultLabel = new JLabel("Result will appear here"); add(promptLabel); add(inputField); add(checkButton); add(resultLabel); // Add action listener to the button checkButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { checkVowel(); } }); } private void checkVowel() { String input = inputField.getText(); if (input.length() != 1) { resultLabel.setText("Please enter a single character"); } else { char ch = input.charAt(0); if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') { resultLabel.setText(ch + " is a vowel"); } else { resultLabel.setText(ch + " is not a vowel"); } } } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new VowelChecker().setVisible(true); } }); } } ```