Can anyone help me with this program?

I have to make program that asks the user for information that they would want on a business card. Then, I am supposed ot take that information that was gathered with a listener and display it on a second panel using graphicsstuff (such as g.drawString(VARIABLEHERE, int x, int y). I can get thepart of the program that would ask for the information, but I can't figure out where to go from there on how to display the information. If anyone could help I would be enternally gratefully. This assignment is due Friday morning at 9:00. Thanks!
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class PanelPractice extends JPanel
     private static JButton insert;
     private static JTextField nameField, positionField, areaField, telField, faxField, emailField, add1Field, add2Field, add3Field;
     private static String nameText, positionText, areaText, telText, faxText, emailText, add1Text, add2Text, add3Text;
     public static void main (String[] args)
          //Makes two colored panels that are nested within a third.
          JFrame frame = new JFrame ("Business Card");
          frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
          //Makes the first subpanel
          JPanel subPanel1 = new JPanel();
               JLabel nameLabel, positionLabel, areaLabel, telLabel, faxLabel, emailLabel, add1Label, add2Label, add3Label;
               //     Sets up the GUI
                    //Creates labels for the information questions
                    nameLabel = new JLabel ("Type the name you want on the card: ");
                    positionLabel = new JLabel ("Type the person's position: ");
                    areaLabel = new JLabel ("Type the person's area of business: ");
                    telLabel = new JLabel ("Type the person's telephone number: ");
                    faxLabel = new JLabel ("Type the person's fax number: ");
                    emailLabel = new JLabel ("Type the person's e-mail address: ");
                    add1Label = new JLabel ("Type the person's place of business: ");
                    add2Label = new JLabel ("Type the business' street address: ");
                    add3Label = new JLabel ("Type the business' city, state, and zip: ");
                    //Creates a JTextField to hold the person's name
                    nameField = new JTextField (10);
                    positionField = new JTextField (10);
                    areaField = new JTextField (10);
                    telField = new JTextField (10);
                    faxField = new JTextField (10);
                    emailField = new JTextField (10);
                    add1Field = new JTextField (10);
                    add2Field = new JTextField (10);
                    add3Field = new JTextField (10);
                    //add the nameLabel and nameField to the panel
                    subPanel1.add (nameLabel);
                    subPanel1.add (nameField);
                    //add the positionLabel and positionField to the panel
                    subPanel1.add (positionLabel);
                    subPanel1.add (positionField);
                    //add the areaLabel and areaField to the panel
                    subPanel1.add (areaLabel);
                    subPanel1.add (areaField);
                    //add the telLabel and telField to the panel
                    subPanel1.add (telLabel);
                    subPanel1.add (telField);
                    //add the faxLabel and faxField to the panel
                    subPanel1.add (faxLabel);
                    subPanel1.add (faxField);
                    //add the emailLabel and emailField to the panel
                    subPanel1.add (emailLabel);
                    subPanel1.add (emailField);
                    //add the add1Label and add1Field to the panel
                    subPanel1.add (add1Label);
                    subPanel1.add (add1Field);
                    //add the add2Label and add2Field to the panel
                    subPanel1.add (add2Label);
                    subPanel1.add (add2Field);
                    //add the add3Label and add3Field to the panel
                    subPanel1.add (add3Label);
                    subPanel1.add (add3Field);
                    //Creates a button to press to insert the information onto the card
                    insert = new JButton ("Insert Information!");
                    //Creates a Listener and makes it listen for the button to be pressed
                    insert.addActionListener (new ButtonListener());
                    //add the button to the panel
                    subPanel1.add (insert);
                    //set the size of the panel to the width and height constants
                    subPanel1.setPreferredSize (new Dimension (350, 300));
                    //set the color of the panel to whatever you choose
                    subPanel1.setBackground (Color.red);
          //Makes the second subpanel
          JPanel subPanel2 = new JPanel();
          subPanel2.setPreferredSize (new Dimension(500,300));
          subPanel2.setBackground (Color.blue);
          //Makes the primary panel
          JPanel primary = new JPanel();
          primary.setBackground (Color.black);
          primary.add (subPanel1);
          primary.add (subPanel2);
          frame.getContentPane().add(primary);
          frame.pack();
          frame.setVisible(true);
               //     Represents an action listener for the insert button.
               private static class ButtonListener implements ActionListener
                    public void actionPerformed (ActionEvent event)
                         //get the text from the textfields
                         nameText = nameField.getText();
                         positionText = positionField.getText();
                         areaText = areaField.getText();
                         telText = telField.getText();
                         faxText = faxField.getText();
                         emailText = emailField.getText();
                         add1Text = add1Field.getText();
                         add2Text = add2Field.getText();
                         add3Text = add3Field.getText();
               public static class CustomComponent extends JPanel
               public void paintComponent(Graphics g)
               super.paintComponent(g);
               g.drawString(nameText, 5, 5);
}

Sorry about that...
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class PanelPractice extends JPanel
private static JButton insert;
private static JTextField nameField, positionField, areaField, telField, faxField, emailField, add1Field, add2Field, add3Field;
private static String nameText, positionText, areaText, telText, faxText, emailText, add1Text, add2Text, add3Text;
public static void main (String[] args)
//Makes two colored panels that are nested within a third.
JFrame frame = new JFrame ("Business Card");
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
//Makes the first subpanel
JPanel subPanel1 = new JPanel();
JLabel nameLabel, positionLabel, areaLabel, telLabel, faxLabel, emailLabel, add1Label, add2Label, add3Label;
// Sets up the GUI
//Creates labels for the information questions
nameLabel = new JLabel ("Type the name you want on the card: ");
positionLabel = new JLabel ("Type the person's position: ");
areaLabel = new JLabel ("Type the person's area of business: ");
telLabel = new JLabel ("Type the person's telephone number: ");
faxLabel = new JLabel ("Type the person's fax number: ");
emailLabel = new JLabel ("Type the person's e-mail address: ");
add1Label = new JLabel ("Type the person's place of business: ");
add2Label = new JLabel ("Type the business' street address: ");
add3Label = new JLabel ("Type the business' city, state, and zip: ");
//Creates a JTextField to hold the person's name
nameField = new JTextField (10);
positionField = new JTextField (10);
areaField = new JTextField (10);
telField = new JTextField (10);
faxField = new JTextField (10);
emailField = new JTextField (10);
add1Field = new JTextField (10);
add2Field = new JTextField (10);
add3Field = new JTextField (10);
//add the nameLabel and nameField to the panel
subPanel1.add (nameLabel);
subPanel1.add (nameField);
//add the positionLabel and positionField to the panel
subPanel1.add (positionLabel);
subPanel1.add (positionField);
//add the areaLabel and areaField to the panel
subPanel1.add (areaLabel);
subPanel1.add (areaField);
//add the telLabel and telField to the panel
subPanel1.add (telLabel);
subPanel1.add (telField);
//add the faxLabel and faxField to the panel
subPanel1.add (faxLabel);
subPanel1.add (faxField);
//add the emailLabel and emailField to the panel
subPanel1.add (emailLabel);
subPanel1.add (emailField);
//add the add1Label and add1Field to the panel
subPanel1.add (add1Label);
subPanel1.add (add1Field);
//add the add2Label and add2Field to the panel
subPanel1.add (add2Label);
subPanel1.add (add2Field);
//add the add3Label and add3Field to the panel
subPanel1.add (add3Label);
subPanel1.add (add3Field);
//Creates a button to press to insert the information onto the card
insert = new JButton ("Insert Information!");
//Creates a Listener and makes it listen for the button to be pressed
insert.addActionListener (new ButtonListener());
//add the button to the panel
subPanel1.add (insert);
//set the size of the panel to the width and height constants
subPanel1.setPreferredSize (new Dimension (350, 300));
//set the color of the panel to whatever you choose
subPanel1.setBackground (Color.red);
//Makes the second subpanel
JPanel subPanel2 = new JPanel();
subPanel2.setPreferredSize (new Dimension(500,300));
subPanel2.setBackground (Color.blue);
//Makes the primary panel
JPanel primary = new JPanel();
primary.setBackground (Color.black);
primary.add (subPanel1);
primary.add (subPanel2);
frame.getContentPane().add(primary);
frame.pack();
frame.setVisible(true);
// Represents an action listener for the insert button.
private static class ButtonListener implements ActionListener
public void actionPerformed (ActionEvent event)
//get the text from the textfields
nameText = nameField.getText();
positionText = positionField.getText();
areaText = areaField.getText();
telText = telField.getText();
faxText = faxField.getText();
emailText = emailField.getText();
add1Text = add1Field.getText();
add2Text = add2Field.getText();
add3Text = add3Field.getText();
public static class CustomComponent extends JPanel
public void paintComponent(Graphics g)
super.paintComponent(g);
g.drawString(nameText, 5, 5);
} No..I'm not expecting someone to do it for me. I am having trouble figuring out what to do next. I cannot get anything to show up on the second panel...the part that displays the information that the listener gathered.
If I could figure out how to get one thing to show up...then I could probably do the rest...it's getting it started that I can't get.

Similar Messages

Maybe you are looking for

  • How to calculate running balance

    can we calculate running balance in discoverer 3.1.36 thanx in anticipation

  • Invalid column name exception

    I am receiving an Invalid column name SQLException. I initially thought it was a problem with the computed fields, but was after making the usual changes to the model implementation the exception is still occurring. I can run the SQL statement in SQL

  • Camera raw vs. ps?

    Why would you color correct non raw related files in camera raw vs. ps? Why is camera raw not just a part of ps? Thanks.

  • Internet display messed up

    my internet page is only showing like half the page the bottom half is white and the top is my website but it aint the whole page. == This happened == Every time Firefox opened == a week ago

  • Why am I unable to open many applications on my macbook pro?

    Why am I unable to open many applications on my macbook pro?Uu