0

Hi,

I am getting this error and just can not figure out what is causing it. I have looked at code from 2 different books. I have google searched.

Here is part of my program that contains the code giving me problems. I posted the program from the beginning to the problem code in case there is something up above it that I don't have coded right yielding the error.

import java.awt.EventQueue;

import javax.swing.JFrame;
import java.awt.Label;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.TextArea;
import java.awt.Choice;
import javax.swing.JRadioButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextPane;
import javax.swing.JTextField;
import javax.swing.ButtonGroup;

public class PayRoll{

Hi,

I am getting this error and just can not figure out what is causing it.  I have looked at code from 2 different books.  I have google searched.


Here is part of my program that contains the code giving me problems.  I posted the program from the beginning to the problem code in case there is something up above it that I don't have coded right yielding the error.

import java.awt.EventQueue;

import javax.swing.JFrame;
import java.awt.Label;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.TextArea;
import java.awt.Choice;
import javax.swing.JRadioButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextPane;
import javax.swing.JTextField;
import javax.swing.ButtonGroup;


public class PayRoll{

    public static final int NUM_PAY_EMP_RECORDS = 3;
    public static Employee[] employees = new Employee[NUM_PAY_EMP_RECORDS];
    public static PayRecord2[] payRecords = new PayRecord2[NUM_PAY_EMP_RECORDS];

    private JFrame frame;
    private JTextField textField_1;
    private final ButtonGroup buttonGroup = new ButtonGroup();
    private JTextField textField_2;
    private JTextField textField_3;
    private JTextField textField_4;
    private JTextField textField_5;
    private JTextField textField_6;
    private JTextField textField_7;
    private JTextField textField_8;
    private JTextField textField_9;
    private JTextField textField_10;
    private JTextField textField_11;

    /**
     * Launch the application.
    */
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    PayRoll window = new PayRoll();
                    window.frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }); 
    }   

    /**
     * Create the application.
     */
    public PayRoll() {
        initialize();
    }

    /**
     * Initialize the contents of the frame.
     */
    private void initialize() {
        frame = new JFrame();
        frame.setBounds(200, 400, 525, 750);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().setLayout(null);

        JRadioButton rdbtnNewRadioButton_1 = new JRadioButton("FullTime");
        buttonGroup.add(rdbtnNewRadioButton_1);
        rdbtnNewRadioButton_1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
            }
        });
        rdbtnNewRadioButton_1.setBounds(83, 106, 143, 23);
        frame.getContentPane().add(rdbtnNewRadioButton_1);
        JRadioButton rdbtnNewRadioButton_2 = new JRadioButton("Hourly");
        buttonGroup.add(rdbtnNewRadioButton_2);
        rdbtnNewRadioButton_2.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
            }
        });

        rdbtnNewRadioButton_2.setBounds(83, 141, 143, 23);
        frame.getContentPane().add(rdbtnNewRadioButton_2);

        JTextPane textPane = new JTextPane();
        textPane.setBounds(58, 33, 1, 16);
        frame.getContentPane().add(textPane);

        JLabel lblEmployee = new JLabel("Employee:");
        lblEmployee.setBounds(8, 6, 70, 16);
        frame.getContentPane().add(lblEmployee);

        JLabel lblId = new JLabel("ID:");
        lblId.setBounds(5, 33, 30, 16);
        frame.getContentPane().add(lblId);

        textField_1 = new JTextField();
        textField_1.setBounds(33, 27, 42, 28);
        frame.getContentPane().add(textField_1);
        textField_1.setColumns(10);

        JLabel lblFirstName = new JLabel("First Name: ");
        lblFirstName.setBounds(98, 33, 77, 16);
        frame.getContentPane().add(lblFirstName);

        textField_2 = new JTextField();
        textField_2.setBounds(172, 27, 98, 28);
        frame.getContentPane().add(textField_2);
        textField_2.setColumns(10);

        JLabel lblLastName = new JLabel("Last Name: ");
        lblLastName.setBounds(304, 33, 77, 16);
        frame.getContentPane().add(lblLastName);

        textField_3 = new JTextField();
        textField_3.setBounds(385, 27, 98, 28);
        frame.getContentPane().add(textField_3);
        textField_3.setColumns(10);

        JLabel lblEmployeeStatus = new JLabel("Employee Status:");
        lblEmployeeStatus.setBounds(10, 76, 111, 16);
        frame.getContentPane().add(lblEmployeeStatus);

        JButton btnAddEmployee = new JButton("Add Employee");
        btnAddEmployee.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                 actionPerformed(e);    

            }
        });

        btnAddEmployee.setBounds(189, 176, 117, 29);
        frame.getContentPane().add(btnAddEmployee);

        public void actionPerformed(ActionEvent e){
             String fullName = textField_2.getText();   (The public void actionPerformed(ActionEvent e){ is where the error shows up)
             String lastName = textField_3.getText();
             String eID      = textField_1.getText();
        } 


Any help is much appreciated.


Janet




public static final int NUM_PAY_EMP_RECORDS = 3;
public static Employee[] employees = new Employee[NUM_PAY_EMP_RECORDS];
public static PayRecord2[] payRecords = new PayRecord2[NUM_PAY_EMP_RECORDS];

private JFrame frame;
private JTextField textField_1;
private final ButtonGroup buttonGroup = new ButtonGroup();
private JTextField textField_2;
private JTextField textField_3;
private JTextField textField_4;
private JTextField textField_5;
private JTextField textField_6;
private JTextField textField_7;
private JTextField textField_8;
private JTextField textField_9;
private JTextField textField_10;
private JTextField textField_11;

/**
 * Launch the application.
*/
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                PayRoll window = new PayRoll();
                window.frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }); 
}   

/**
 * Create the application.
 */
public PayRoll() {
    initialize();
}

/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    frame = new JFrame();
    frame.setBounds(200, 400, 525, 750);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(null);

    JRadioButton rdbtnNewRadioButton_1 = new JRadioButton("FullTime");
    buttonGroup.add(rdbtnNewRadioButton_1);
    rdbtnNewRadioButton_1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
        }
    });
    rdbtnNewRadioButton_1.setBounds(83, 106, 143, 23);
    frame.getContentPane().add(rdbtnNewRadioButton_1);
    JRadioButton rdbtnNewRadioButton_2 = new JRadioButton("Hourly");
    buttonGroup.add(rdbtnNewRadioButton_2);
    rdbtnNewRadioButton_2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
        }
    });

    rdbtnNewRadioButton_2.setBounds(83, 141, 143, 23);
    frame.getContentPane().add(rdbtnNewRadioButton_2);

    JTextPane textPane = new JTextPane();
    textPane.setBounds(58, 33, 1, 16);
    frame.getContentPane().add(textPane);

    JLabel lblEmployee = new JLabel("Employee:");
    lblEmployee.setBounds(8, 6, 70, 16);
    frame.getContentPane().add(lblEmployee);

    JLabel lblId = new JLabel("ID:");
    lblId.setBounds(5, 33, 30, 16);
    frame.getContentPane().add(lblId);

    textField_1 = new JTextField();
    textField_1.setBounds(33, 27, 42, 28);
    frame.getContentPane().add(textField_1);
    textField_1.setColumns(10);

    JLabel lblFirstName = new JLabel("First Name: ");
    lblFirstName.setBounds(98, 33, 77, 16);
    frame.getContentPane().add(lblFirstName);

    textField_2 = new JTextField();
    textField_2.setBounds(172, 27, 98, 28);
    frame.getContentPane().add(textField_2);
    textField_2.setColumns(10);

    JLabel lblLastName = new JLabel("Last Name: ");
    lblLastName.setBounds(304, 33, 77, 16);
    frame.getContentPane().add(lblLastName);

    textField_3 = new JTextField();
    textField_3.setBounds(385, 27, 98, 28);
    frame.getContentPane().add(textField_3);
    textField_3.setColumns(10);

    JLabel lblEmployeeStatus = new JLabel("Employee Status:");
    lblEmployeeStatus.setBounds(10, 76, 111, 16);
    frame.getContentPane().add(lblEmployeeStatus);

    JButton btnAddEmployee = new JButton("Add Employee");
    btnAddEmployee.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
             actionPerformed(e);    

        }
    });

    btnAddEmployee.setBounds(189, 176, 117, 29);
    frame.getContentPane().add(btnAddEmployee);

    public void actionPerformed(ActionEvent e){
         String fullName = textField_2.getText();   (The public void actionPerformed(ActionEvent e){ is where the error shows up)
         String lastName = textField_3.getText();
         String eID      = textField_1.getText();
    } 

Any help is much appreciated.

Janet

2
Contributors
1
Reply
6
Views
2 Years
Discussion Span
Last Post by JamesCherrill
2

You are trying to define a method withiout finishing the previous method defintion. You canno define one method inside another method like that.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.