我正在尝试添加此面板:
import javax.swing.*;
import java.awt.*;
class TopPanel extends JPanel{
public TopPanel() {
JPanel panel = new JPanel();
JLabel label = new JLabel("Course Lookup GUI");
panel.add(label);
panel.setVisible(true);
}
}
像这样的框架:
import javax.swing.*;
import java.awt.*;
class CourseGUI extends JFrame{
public CourseGUI() {
this.setLayout(new FlowLayout());
this.setLocation(200,200);
TopPanel tPan = new TopPanel();
MiddlePanel mPan = new MiddlePanel();
this.add(tPan);
this.add(mPan);
this.setVisible(true);
}
public static void main(String[] args){
CourseGUI cGUI = new CourseGUI();
}
}
但是没有任何东西添加到框架中,我得到一个空窗口。我究竟做错了什么?