请教两个问题:
下面这段代码已经被编译成功,但不知:
1)为什么不能把JList控件显示出来,
2)如何处理它的事件(如Change 或click事件)呢?
3)JPane是不是JFrame的子类?
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JFrame;
public class ListPanel extends JPanel
{
String[] labels={"Choice1","Choice2","Choice3","Choice4"};
public ListPanel(){
setLayout(new BorderLayout());
JList myList=new JList(labels);
ScrollPane pane=new ScrollPane();
pane.add(myList);
add(pane,BorderLayout.CENTER);
}
public static void main(String[] args)
{
System.out.println("Hello World!");
ListPanel myListPanel=new ListPanel();
}
}