Question: LANGUAGE: JAVA Created a GUI, not showing. I believe I need to create another class but I am lost. Please explain anyhting added on to

LANGUAGE: JAVA

Created a GUI, not showing. I believe I need to create another class but I am lost. Please explain anyhting added on to the code.

import java.awt.event.ActionListener;

import java.awt.event.ActionEvent; import javax.swing.JPanel; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JTextField;

import java.awt.Color;

public class MyNamePlease extends JPanel implements ActionListener{ private JButton identityButton; private JLabel titleDisplay; private JTextField firstName; private JTextField lastName; public MyNamePlease() { setBackground(Color.green); titleDisplay = new JLabel ("Name Please!"); firstName = new JTextField(5); lastName = new JTextField(7); identityButton = new JButton ("OK"); identityButton.addActionListener(this); add(identityButton); add(titleDisplay); } @Override public void actionPerformed (ActionEvent A) { titleDisplay.setText("Clicked"); } }

TESTER

import java.awt.GridLayout;

import javax.swing.JFrame;

public class tester extends JFrame{ public static void main (String[]args) { }

public tester() { MyNamePlease A1 = new MyNamePlease(); add(A1); setLayout(new GridLayout(2,1)); setSize(200,100); setVisible(true); setDefaultCloseOperation(EXIT_ON_CLOSE);

} }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!