Answered step by step
Verified Expert Solution
Question
1 Approved Answer
VERY EASY Code modification! Please read instructions at the bottom of the Java Code! You are free to use whatever idea or way you want
VERY EASY Code modification! Please read instructions at the bottom of the Java Code! You are free to use whatever idea or way you want to meet the requirement.
import javax.swing.*; import java.awt.*; public class Widget extends JFrame { JFrame f = new JFrame(); JLabel l1, l2, l3, l4, l5, l6, l7, l8; JTextField tf1, tf2, tf5, tf6, tf7; JPanel panel = new JPanel(); JButton btn1 = new JButton("Login"); JButton r = new JButton("Reset"); JLabel l9 = new JLabel(); JPasswordField p1, p2; JComboBox date; JComboBox month; JComboBox year; String dates[] = { "select", "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" }; String months[] = { "select", "Jan", "feb", "Mar", "Apr", "May", "Jun", "July", "Aug", "Sup", "Oct", "Nov", "Dec" }; String years[] = { "select", "1995", "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019" }; Widget() { setTitle("Registration Form in Java"); l1 = new JLabel("WK5 Java Registration From"); l1.setForeground(Color.blue); l1.setFont(new Font("Serif", Font.BOLD, 20)); l2 = new JLabel("User Name:"); l3 = new JLabel("Email-ID:"); l4 = new JLabel("Create Passowrd:"); l5 = new JLabel("Confirm Password:"); l6 = new JLabel("DOB:"); tf1 = new JTextField(); tf2 = new JTextField(); p1 = new JPasswordField(); p2 = new JPasswordField(); tf5 = new JTextField(); panel.setBounds(0, 0, 700, 700); panel.setBackground(Color.pink); panel.setLayout(null); l1.setBounds(100, 30, 400, 30); l2.setBounds(80, 70, 200, 30); l3.setBounds(80, 110, 200, 30); l4.setBounds(80, 150, 200, 30); l5.setBounds(80, 190, 200, 30); l6.setBounds(80, 230, 200, 30); tf1.setBounds(300, 70, 200, 30); tf2.setBounds(300, 110, 200, 30); p1.setBounds(300, 150, 200, 30); p2.setBounds(300, 190, 200, 30); btn1.setBounds(50, 300, 100, 30); r.setBounds(300, 300, 100, 30); panel.add(l1); panel.add(l2); panel.add(tf1); panel.add(l3); panel.add(tf2); panel.add(l4); panel.add(p1); panel.add(l5); panel.add(p2); panel.add(l6); panel.add(r); panel.add(btn1); f.add(panel); date = new JComboBox(dates); date.setFont(new Font("Arial", Font.PLAIN, 15)); date.setSize(70, 20); date.setLocation(200, 250); panel.add(date); month = new JComboBox(months); month.setFont(new Font("Arial", Font.PLAIN, 15)); month.setSize(70, 20); month.setLocation(280, 250); panel.add(month); year = new JComboBox(years); year.setFont(new Font("Arial", Font.PLAIN, 15)); year.setSize(70, 20); year.setLocation(360, 250); panel.add(year); f.add(l9); f.setVisible(true); f.setSize(700, 700); f.setLayout(null); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String args[]) { new Widget(); } }
Use the Java hierarchy my code above and add a user-defined exception that can be thrown by one of the methods as part of the validation or error checking. The main method should then make a instance of the class and call the method in such a way that the exception is thrown (e.g. invalid input or state of the system). Include a screenshot of the running modified code output. Please have all the code neatly in 1 file titled Widget.Java
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started