komlaaa
asked on
Adding a Container within a Container
Why this coder is not working?
What should i do?
ERROR MESSAGE: "java.lang.IllegalArgument Exception: 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 studentAndCourseContentPan e = getContentPane();
studentAndCourseContentPan e.setLayou t( new FlowLayout( ) );
studentAndCourseContentPan e.add( student ) ;
studentAndCourseContentPan e.add( course ) ;
Container professorAndExamContentPan e = getContentPane();
professorAndExamContentPan e.setLayou t( new FlowLayout( ) );
professorAndExamContentPan e.add( professor );
professorAndExamContentPan e.add( exam );
JLayeredPane rootPane = getLayeredPane(); <=============== ERROR MESSAGE
rootPane.add(studentAndCou rseContent Pane, BorderLayout.NORTH ) ;
rootPane.add(professorAndE xamContent Pane , BorderLayout.CENTER );
rootPane.add( controls, BorderLayout.SOUTH );
//Container controlsContenPane = getContentPane();
//controlsContenPane.add(c ontrols, BorderLayout.SOUTH );
pack();
show();
}
public static void main( String [] args )
{
(new StudentSupportServices()). addWindowL istener
(
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.RIGH T, 20, 10));
setBorder(new CompoundBorder(
BorderFactory.createLineBo rder(Color .BLACK,1),
BorderFactory.createBevelB order(Beve lBorder.RA ISED)));
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;
}
}
What should i do?
ERROR MESSAGE: "java.lang.IllegalArgument
=============== 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 studentAndCourseContentPan
studentAndCourseContentPan
studentAndCourseContentPan
studentAndCourseContentPan
Container professorAndExamContentPan
professorAndExamContentPan
professorAndExamContentPan
professorAndExamContentPan
JLayeredPane rootPane = getLayeredPane(); <=============== ERROR MESSAGE
rootPane.add(studentAndCou
rootPane.add(professorAndE
rootPane.add( controls, BorderLayout.SOUTH );
//Container controlsContenPane = getContentPane();
//controlsContenPane.add(c
pack();
show();
}
public static void main( String [] args )
{
(new StudentSupportServices()).
(
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.RIGH
setBorder(new CompoundBorder(
BorderFactory.createLineBo
BorderFactory.createBevelB
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;
}
}
Same Q as always: At what line do you get that error?
Sorry, didn't see the pointer ;°)
>> JLayeredPane rootPane = getLayeredPane(); <=============== ERROR MESSAGE
don't you mean
Container cont = getContentPane();
don't you mean
Container cont = getContentPane();
This is strange:
Container studentAndCourseContentPan e = getContentPane(); // <<<<<<<< 1st time
studentAndCourseContentPan e.setLayou t( new FlowLayout( ) );
studentAndCourseContentPan e.add( student ) ;
studentAndCourseContentPan e.add( course ) ;
Container professorAndExamContentPan e = getContentPane(); // <<<<<<<<<< 2nd time
professorAndExamContentPan e.setLayou t( new FlowLayout( ) );
professorAndExamContentPan e.add( professor );
professorAndExamContentPan e.add( exam );
???
Container studentAndCourseContentPan
studentAndCourseContentPan
studentAndCourseContentPan
studentAndCourseContentPan
Container professorAndExamContentPan
professorAndExamContentPan
professorAndExamContentPan
professorAndExamContentPan
???
Are you aware of the fact that the above equals:
Container c = getContentPane();
c.setLayout( new FlowLayout( ) );
c.add( student ) ;
c.add( course ) ;
c.add( professor );
c.add( exam );
Container c = getContentPane();
c.setLayout( new FlowLayout( ) );
c.add( student ) ;
c.add( course ) ;
c.add( professor );
c.add( exam );
ASKER
I am trying to add studentAndCourseContentPan e <<<<<<< #1)
and professorAndExamContentPan e <<<<< #2)
to JLayeredPane rootPane = getLayeredPane();
Basically trying to add two container into another one. Not feasable?
and professorAndExamContentPan
to JLayeredPane rootPane = getLayeredPane();
Basically trying to add two container into another one. Not feasable?
>> Basically trying to add two container into another one. Not feasable?
Sure.
What are
studentAndCourseContentPan e & professorAndExamContentPan e ?
I guess you want:
JPanel studentAndCoursePanel = new JPanel();
studentAndCoursePanel.setL ayout( new FlowLayout( ) );
studentAndCoursePanel.add( student ) ;
studentAndCoursePanel.add( course ) ;
JPanel professorAndExamPanel = new JPanel();
professorAndExamPanel.setL ayout( new FlowLayout( ) );
professorAndExamPanel.add( professor );
professorAndExamPanel.add( exam );
Container c = getContentPane();
c.add(studentAndCourseCont entPane, BorderLayout.NORTH ) ;
c.add(professorAndExamCont entPane , BorderLayout.CENTER );
c.add( controls, BorderLayout.SOUTH );
Sure.
What are
studentAndCourseContentPan
I guess you want:
JPanel studentAndCoursePanel = new JPanel();
studentAndCoursePanel.setL
studentAndCoursePanel.add(
studentAndCoursePanel.add(
JPanel professorAndExamPanel = new JPanel();
professorAndExamPanel.setL
professorAndExamPanel.add(
professorAndExamPanel.add(
Container c = getContentPane();
c.add(studentAndCourseCont
c.add(professorAndExamCont
c.add( controls, BorderLayout.SOUTH );
I think that the content pane of a JFrame uses the BorderLayout by default but if you want to be sure,
you can add:
JPanel studentAndCoursePanel = new JPanel();
studentAndCoursePanel.setL ayout( new FlowLayout( ) );
studentAndCoursePanel.add( student ) ;
studentAndCoursePanel.add( course ) ;
JPanel professorAndExamPanel = new JPanel();
professorAndExamPanel.setL ayout( new FlowLayout( ) );
professorAndExamPanel.add( professor );
professorAndExamPanel.add( exam );
Container c = getContentPane();
c.setLayout( new BorderLayout() ); // <<<<<<<<<<<<<<<<<<<<<<<< 2B sure
c.add(studentAndCourseCont entPane, BorderLayout.NORTH ) ;
c.add(professorAndExamCont entPane , BorderLayout.CENTER );
c.add( controls, BorderLayout.SOUTH );
you can add:
JPanel studentAndCoursePanel = new JPanel();
studentAndCoursePanel.setL
studentAndCoursePanel.add(
studentAndCoursePanel.add(
JPanel professorAndExamPanel = new JPanel();
professorAndExamPanel.setL
professorAndExamPanel.add(
professorAndExamPanel.add(
Container c = getContentPane();
c.setLayout( new BorderLayout() ); // <<<<<<<<<<<<<<<<<<<<<<<< 2B sure
c.add(studentAndCourseCont
c.add(professorAndExamCont
c.add( controls, BorderLayout.SOUTH );
ASKER
This version run fine but the panel are being displayed?
why is that?
=========CODE==========
/*
* StudentInformations.java
*
* Created on January 9, 2005, 3:02 AM
*/
package sss;
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");
course = new CoursePanel();
student = new StudentPanel();
professor = new ProfessorPanel();
exam = new ExamPanel();
controls = new ControlPanel();
JPanel StudentCourseProfessorExam Panel = new JPanel();
StudentCourseProfessorExam Panel.setL ayout(new GridLayout(2,2) );
StudentCourseProfessorExam Panel.add( course );
StudentCourseProfessorExam Panel.add( student );
StudentCourseProfessorExam Panel.add( professor );
StudentCourseProfessorExam Panel.add( exam );
Container c = getContentPane();
c.setLayout( new BorderLayout() );
c.add(StudentCourseProfess orExamPane l, BorderLayout.CENTER ) ;
c.add( controls, BorderLayout.SOUTH );
pack();
show();
}
public static void main( String [] args )
{
(new StudentSupportServices()). addWindowL istener
(
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.RIGH T, 20, 10));
setBorder(new CompoundBorder(
BorderFactory.createLineBo rder(Color .BLACK,1),
BorderFactory.createBevelB order(Beve lBorder.RA ISED)));
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.*;
import javax.swing.border.*;
/**
*
* @author Agbeko Komla
*/
public class CoursePanel extends JPanel
{
/** Creates a new instance of Course */
public CoursePanel()
{
JPanel exam = new JPanel();
exam.setLayout( new FlowLayout() );
exam.setBorder(new TitledBorder(new EtchedBorder(),"Just Trying"));
exam.add(new JButton( "Place Holder") );
}
}
========================== =
/*
* StudentSchedule.java
*
* Created on January 9, 2005, 3:09 AM
*/
package sss;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;
/**
*
* @author Agbeko Komla
*/
public class ExamPanel extends JPanel
{
/** Creates a new instance of StudentSchedule */
public ExamPanel()
{
JPanel exam = new JPanel();
exam.setLayout( new FlowLayout() );
exam.setBorder(new TitledBorder(new EtchedBorder(),"Just Trying"));
exam.add(new JButton( "Place Holder") );
}
}
========================== ==========
/*
* Professor.java
*
* Created on January 19, 2005, 8:20 AM
*/
package sss;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
/**
*
* @author Agbeko Komla
*/
public class ProfessorPanel extends JPanel
{
/** Creates a new instance of Professor */
public ProfessorPanel()
{
JPanel exam = new JPanel();
exam.setLayout( new FlowLayout() );
exam.setBorder(new TitledBorder(new EtchedBorder(),"Just Trying"));
exam.add(new JButton( "Place Holder") );
}
}
========================== ========== =====
/*
* StudentPanel.java
*
* Created on January 9, 2005, 3:09 AM
*/
package sss;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
/**
*
* @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()
{
for(int i = 0; i < fields.length; i++)
{
fields[i] = new JTextField(10);
add( new JLabel( labels[i], JLabel.CENTER ));
add( fields[i] );
}
}
public int getLabelLength()
{
return labels.length;
}
}
why is that?
=========CODE==========
/*
* StudentInformations.java
*
* Created on January 9, 2005, 3:02 AM
*/
package sss;
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");
course = new CoursePanel();
student = new StudentPanel();
professor = new ProfessorPanel();
exam = new ExamPanel();
controls = new ControlPanel();
JPanel StudentCourseProfessorExam
StudentCourseProfessorExam
StudentCourseProfessorExam
StudentCourseProfessorExam
StudentCourseProfessorExam
StudentCourseProfessorExam
Container c = getContentPane();
c.setLayout( new BorderLayout() );
c.add(StudentCourseProfess
c.add( controls, BorderLayout.SOUTH );
pack();
show();
}
public static void main( String [] args )
{
(new StudentSupportServices()).
(
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.RIGH
setBorder(new CompoundBorder(
BorderFactory.createLineBo
BorderFactory.createBevelB
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.*;
import javax.swing.border.*;
/**
*
* @author Agbeko Komla
*/
public class CoursePanel extends JPanel
{
/** Creates a new instance of Course */
public CoursePanel()
{
JPanel exam = new JPanel();
exam.setLayout( new FlowLayout() );
exam.setBorder(new TitledBorder(new EtchedBorder(),"Just Trying"));
exam.add(new JButton( "Place Holder") );
}
}
==========================
/*
* StudentSchedule.java
*
* Created on January 9, 2005, 3:09 AM
*/
package sss;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;
/**
*
* @author Agbeko Komla
*/
public class ExamPanel extends JPanel
{
/** Creates a new instance of StudentSchedule */
public ExamPanel()
{
JPanel exam = new JPanel();
exam.setLayout( new FlowLayout() );
exam.setBorder(new TitledBorder(new EtchedBorder(),"Just Trying"));
exam.add(new JButton( "Place Holder") );
}
}
==========================
/*
* Professor.java
*
* Created on January 19, 2005, 8:20 AM
*/
package sss;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
/**
*
* @author Agbeko Komla
*/
public class ProfessorPanel extends JPanel
{
/** Creates a new instance of Professor */
public ProfessorPanel()
{
JPanel exam = new JPanel();
exam.setLayout( new FlowLayout() );
exam.setBorder(new TitledBorder(new EtchedBorder(),"Just Trying"));
exam.add(new JButton( "Place Holder") );
}
}
==========================
/*
* StudentPanel.java
*
* Created on January 9, 2005, 3:09 AM
*/
package sss;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
/**
*
* @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()
{
for(int i = 0; i < fields.length; i++)
{
fields[i] = new JTextField(10);
add( new JLabel( labels[i], JLabel.CENTER ));
add( fields[i] );
}
}
public int getLabelLength()
{
return labels.length;
}
}
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
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");
course = new CoursePanel();
student = new StudentPanel();
professor = new ProfessorPanel();
exam = new ExamPanel();
controls = new ControlPanel();
JPanel StudentCourseProfessorExam Panel = new JPanel();
StudentCourseProfessorExam Panel.setL ayout(new GridLayout(2,2) );
StudentCourseProfessorExam Panel.add( course );
StudentCourseProfessorExam Panel.add( student );
StudentCourseProfessorExam Panel.add( professor );
StudentCourseProfessorExam Panel.add( exam );
Container c = getContentPane();
c.setLayout( new BorderLayout() );
c.add(StudentCourseProfess orExamPane l, BorderLayout.CENTER ) ;
c.add( controls, BorderLayout.SOUTH );
pack();
show(); <<<<<<<<<< I add show here,... no need to apply show in main, I tried that but didn't change much.
}
=====================
Container c = getContentPane();
c.setLayout( new BorderLayout() ); // <<<<<<<<<<<<<<<<<<<<<<<< 2B sure
c.add(studentAndCourseCont entPane, BorderLayout.NORTH ) ;
c.add(professorAndExamCont entPane , BorderLayout.CENTER );
c.add( controls, BorderLayout.SOUTH );
Makes sens but i don't want the GUI to have that look.
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");
course = new CoursePanel();
student = new StudentPanel();
professor = new ProfessorPanel();
exam = new ExamPanel();
controls = new ControlPanel();
JPanel StudentCourseProfessorExam
StudentCourseProfessorExam
StudentCourseProfessorExam
StudentCourseProfessorExam
StudentCourseProfessorExam
StudentCourseProfessorExam
Container c = getContentPane();
c.setLayout( new BorderLayout() );
c.add(StudentCourseProfess
c.add( controls, BorderLayout.SOUTH );
pack();
show(); <<<<<<<<<< I add show here,... no need to apply show in main, I tried that but didn't change much.
}
=====================
Container c = getContentPane();
c.setLayout( new BorderLayout() ); // <<<<<<<<<<<<<<<<<<<<<<<< 2B sure
c.add(studentAndCourseCont
c.add(professorAndExamCont
c.add( controls, BorderLayout.SOUTH );
Makes sens but i don't want the GUI to have that look.
ASKER
>>>I found out why<<<<<<<<<
i am creating another panel intead of the current one
>>>>>> JPanel exam = new JPanel(); <<<< shouldn't be there.
public class ExamPanel extends JPanel
{
/** Creates a new instance of StudentSchedule */
public ExamPanel()
{
JPanel exam = new JPanel();
exam.setLayout( new FlowLayout() );
exam.setBorder(new TitledBorder(new EtchedBorder(),"Just Trying"));
exam.add(new JButton( "Place Holder") );
}
i am creating another panel intead of the current one
>>>>>> JPanel exam = new JPanel(); <<<< shouldn't be there.
public class ExamPanel extends JPanel
{
/** Creates a new instance of StudentSchedule */
public ExamPanel()
{
JPanel exam = new JPanel();
exam.setLayout( new FlowLayout() );
exam.setBorder(new TitledBorder(new EtchedBorder(),"Just Trying"));
exam.add(new JButton( "Place Holder") );
}
What does your getLayeredPane() method look like?
ASKER
>What does your getLayeredPane() method look like?
it just like other Container, but i thought that should have the ability to hold other Containers
its name "Layered" means it.
it just like other Container, but i thought that should have the ability to hold other Containers
its name "Layered" means it.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.