Need to add a JCombobox to select the user’s State of birth, and a JRadio buttons to indicate their gender. Also, add a JTextArea to the form. Once the user clicks on the JButton the application will display all of the user’s information in the JTextearea.

All the classes work properly I need to figure out how to get them to work together and properly. Any assistance will be greatly appreciated.

justindillingerHW3.java

package justindillingerhw3;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.border.TitledBorder;

public class JustinDillingerHW3 extends JFrame{

//Create text fields and labels
private JTextField jtfFirstName = new JTextField(15);
private JTextField jtfLastName = new JTextField(15);
private JTextField jtfAge = new JTextField(2);
private JRadioButton Male;
private JRadioButton Female;
private JLabel WelcomeMessage;    

public static void main(String[] args){

    JustinDillingerHW3 frame = new JustinDillingerHW3();
    frame.setTitle("Hello User!!");
    frame.setSize(1000, 1000);
    frame.setLocationRelativeTo(null);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.setVisible(true);
}

public JustinDillingerHW3(){

    setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));

    //add labels and text fields to the frame
    add(new JLabel("First Name"));
    add(jtfFirstName);
    add(new JLabel("Last Name"));
    add(jtfLastName);
    add(new JLabel("Age"));
    add(jtfAge);


    //Create Welcome button
    JButton Welcome = new JButton("Click Here!!");
    add(Welcome);

    Welcome.addActionListener(new SubmitListener());
    WelcomeMessage = (new JLabel(" "));
    add(WelcomeMessage);

}
class SubmitListener implements ActionListener{
    public void actionPerformed(ActionEvent e){

        String FirstName = jtfFirstName.getText();
        String SurName = jtfLastName.getText();
        WelcomeMessage.setText("Welcome, " + FirstName + " " + SurName);
    }
}
} 

createradiobutton.java

package createradiobutton;

import javax.swing.*;
import java.awt.*;

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

CreateRadioButton radioButton = new CreateRadioButton();
  }

  public CreateRadioButton(){
JRadioButton Male,Female;

JFrame frame = new JFrame("Gender");
JPanel panel = new JPanel();

//Group radio buttons male & female
ButtonGroup buttonGroup = new ButtonGroup();
Male = new JRadioButton("Male");
buttonGroup.add(Male);
panel.add(Male);
Female = new JRadioButton("Female");
buttonGroup.add(Female);
panel.add(Female);

//Set initial selection to male
Male.setSelected(true);
frame.add(panel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(250, 250);
frame.setVisible(true);
  }
}

createcombobox.java

 package createcombobox;

import java.awt.FlowLayout;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class CreateComboBox extends JFrame {

public static void main(String[] args) {
    CreateComboBox frame = new CreateComboBox();
    frame.setTitle("States");
    frame.setSize(200, 100);
    frame.setLocationRelativeTo(null);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);       
    frame.setVisible(true);
}

public CreateComboBox(){
JComboBox jComboBox1 = new JComboBox();
jComboBox1.addItem("Alabama");
jComboBox1.addItem("Alaska");
jComboBox1.addItem("Arizona");
jComboBox1.addItem("Arkansas");
jComboBox1.addItem("California");
jComboBox1.addItem("Colorado");
jComboBox1.addItem("Connecticut");
jComboBox1.addItem("Delaware");
jComboBox1.addItem("Florida");
jComboBox1.addItem("Georgia");
jComboBox1.addItem("Hawaii");
jComboBox1.addItem("Idaho");
jComboBox1.addItem("Illinois");
jComboBox1.addItem("Indiana");
jComboBox1.addItem("Iowa");
jComboBox1.addItem("Kansas");
jComboBox1.addItem("Kentucky");
jComboBox1.addItem("Louisiana");
jComboBox1.addItem("Maryland");
jComboBox1.addItem("Massachusetts");
jComboBox1.addItem("Michigan");
jComboBox1.addItem("Minnesota");
jComboBox1.addItem("Mississippi");
jComboBox1.addItem("Missouri");
jComboBox1.addItem("Montana");
jComboBox1.addItem("Nebraska");
jComboBox1.addItem("Nevada");
jComboBox1.addItem("New Hampshire");
jComboBox1.addItem("New Jersey");
jComboBox1.addItem("New Mexico");
jComboBox1.addItem("New York");
jComboBox1.addItem("North Carolina");
jComboBox1.addItem("North Dakota");
jComboBox1.addItem("Ohio");
jComboBox1.addItem("Oklahoma");
jComboBox1.addItem("Oregon");
jComboBox1.addItem("Pennsylvania");
jComboBox1.addItem("Rhode Island");
jComboBox1.addItem("South Carolina");
jComboBox1.addItem("South Dakota");
jComboBox1.addItem("Tennessee");
jComboBox1.addItem("Texas");
jComboBox1.addItem("Utah");
jComboBox1.addItem("Vermont");
jComboBox1.addItem("Virginia");
jComboBox1.addItem("Washington");
jComboBox1.addItem("West Virginia");
jComboBox1.addItem("Wisconsin");
jComboBox1.addItem("Wyoming");    

Object StateList = jComboBox1.getSelectedItem();
System.out.println(StateList);

add(jComboBox1);

  }

}

createtextarea.java

 package createtextarea;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.*;

public class CreateTextArea { 

  public static void main(String[] args){
  JFrame frame= new JFrame("Output Frame");
  JPanel panel=new JPanel();
  JTextArea jt= new JTextArea("Hello everybody in CMIS-242", 5, 20);
  frame.add(panel);
  panel.add(jt);
  frame.setSize(250,200);
  frame.setVisible(true);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
}

Please help me figure this out.

need to figure out how to get them to work together and properly

Can you explain what problems you are having?

All the classes work properly I need to figure out how to get them to work together. Any assistance will be greatly appreciated.

I need to get them to work together or somehow combine all of them so it will works as an application. So, when a user enters their information it will display in the textfield.

Do some design work with paper and pencil to figure out what the GUI should look like and then
Try some copy and pasting from the working code into the new program.

I have already tried working in the other parts of code and I cannot figure it out. Trust me I have been working on this all week long.

Do it one step at a time. Merge one class into another and get it to compile and execute. The work on merging the next one in.

If you have code with problems, post it and your questions.

I will see what I can do, but you are not really assisting me in the slightest bit. No hints.

Its your project. You need to work through copying the code from each class to the final project.
Do you have the design for the GUI? You will need that before you can procede.
What layout manager have you chosen to position your components in the GUI?
Then pick one class to merge into. Copy the code from another class into the one that is to be the final project.
Compile often and fix the errors. When that code from that class is merged and compiles and executes ok, pick another class and do it again. Continue until done.

I'm not sure what you mean by hints. This is mostly a copy and paste problem with a few adjustments.

This article has been dead for over six months. Start a new discussion instead.