Why this coder is not working?
What should i do?
ERROR MESSAGE: "java.lang.IllegalArgumentException: illegal component position"
=============== Code ==================
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
/**
*
* @author Agbeko Komla
*/
public class StudentSupportServices extends JFrame {
private StudentPanel student;
private CoursePanel course;
private ProfessorPanel professor;
private ExamPanel exam;
private ControlPanel controls;
private Connection connect;
/** Creates a new instance of StudentInformations */
public StudentSupportServices() {
super("Student Support Services");
//These are all JPanels that i create externally
course = new CoursePanel();
student = new StudentPanel();
professor = new ProfessorPanel();
exam = new ExamPanel();
controls = new ControlPanel();
Container studentAndCourseContentPane = getContentPane();
studentAndCourseContentPane.setLayout( new FlowLayout( ) );
studentAndCourseContentPane.add( student ) ;
studentAndCourseContentPane.add( course ) ;
Container professorAndExamContentPane = getContentPane();
professorAndExamContentPane.setLayout( new FlowLayout( ) );
professorAndExamContentPane.add( professor );
professorAndExamContentPane.add( exam );
JLayeredPane rootPane = getLayeredPane(); <=============== ERROR MESSAGE
rootPane.add(studentAndCourseContentPane, BorderLayout.NORTH ) ;
rootPane.add(professorAndExamContentPane , BorderLayout.CENTER );
rootPane.add( controls, BorderLayout.SOUTH );
//Container controlsContenPane = getContentPane();
//controlsContenPane.add(controls, BorderLayout.SOUTH );
pack();
show();
}
public static void main( String [] args )
{
(new StudentSupportServices()).addWindowListener
(
new WindowAdapter()
{
public void windowClosing( WindowEvent e)
{
System.exit( 0 );
}
}
);
}
}
==================
/*
* ControlPanel.java
*
* Created on January 9, 2005, 3:10 AM
*/
package sss;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
/**
*
* @author Agbeko Komla
*/
public class ControlPanel extends JPanel
{
private JButton findData,findSchedule, addData, updateData, clear, help;
/** Creates a new instance of ControlPanel */
public ControlPanel()
{
super();
setLayout(new FlowLayout(FlowLayout.RIGHT, 20, 10));
setBorder(new CompoundBorder(
BorderFactory.createLineBorder(Color.BLACK,1),
BorderFactory.createBevelBorder(BevelBorder.RAISED)));
findData = new JButton( "Find" );
//add actionListner later
add(findData);
findSchedule = new JButton( "Schedule" );
//add actionListner later
add(findSchedule);
addData = new JButton( "Add" );
//add actionListner later
add(addData);
updateData = new JButton( "Update" );
//add actionListner later
add(updateData);
clear = new JButton( "Clear" );
//add actionListner later
add(clear);
help = new JButton( "Help" );
//add actionListner later
add(help);
}
}
============================
/*
* Course.java
*
* Created on January 19, 2005, 8:19 AM
*/
package sss;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
*
* @author Agbeko Komla
*/
public class CoursePanel extends JPanel
{
/** Creates a new instance of Course */
public CoursePanel()
{
super();
}
}
========================
/*
* StudentSchedule.java
*
* Created on January 9, 2005, 3:09 AM
*/
package sss;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
/**
*
* @author Agbeko Komla
*/
public class ExamPanel extends JPanel
{
/** Creates a new instance of StudentSchedule */
public ExamPanel()
{
super();
}
}
========================
/*
* Professor.java
*
* Created on January 19, 2005, 8:20 AM
*/
package sss;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
*
* @author Agbeko Komla
*/
public class ProfessorPanel extends JPanel
{
/** Creates a new instance of Professor */
public ProfessorPanel()
{
super();
}
}
====================
/*
* StudentPanel.java
*
* Created on January 9, 2005, 3:09 AM
*/
package sss;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
*
* @author Agbeko Komla
*/
public class StudentPanel extends JPanel
{
private String labels[] =
{"ID:", "Last Name:", "First Name:", "Student Phone:", "Box #:"};
JTextField last, first, id, phone, box;
JTextField fields[] = {id, last, first, phone, box};
/** Creates a new instance of StudentPanel */
public StudentPanel()
{
super();
/*
for(int i = 0; i < fields.length; i++)
{
fields[i] = new JTextField(10);
add( new JLabel( labels[i], JLabel.CENTER ));
add( fields[i] );
}
*/
JPanel p1 = new JPanel( );
//add actionListner later
add(p1);
JPanel p2 = new JPanel( );
//add actionListner later
add(p2);
}
public int getLabelLength()
{
return labels.length;
}
}