import javax.swing.*;
import javax.swing.event.*;
public class NewGUIStuff{
public static void main(String args[]){
NewGUIStuff gui = new NewGUIStuff();
gui.go();
}
class handlesListListeners implements ListSelectionListener{
public void valueChanged(ListSelectionEvent lse){
list.setVisibleRowCount(4);
}
}
public void valueChanged(ListSelectionEvent lse){
}
public void go(){
JFrame frame = new JFrame();
JPanel panel = new JPanel();
JList list;
String[] aList = {"alpha","beta","gamma","delta","epsilon","zeta","eta","theta"};
list = new JList(aList);
list.addListSelectionListener(new handlesListListeners());
JScrollPane scroller = new JScrollPane(list);
scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
frame.setContentPane(scroller);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300,300);
frame.setVisible(true);
}
}
ここで私の質問は、内部クラスが外部クラスの変数とオブジェクトを表示できる場合、外部クラスで作成しhandlesListListeners
たlist
オブジェクトを内部クラスが表示できないのはなぜNewGUIStuff
ですか?