0
목록의 각 버튼에 대해 ActionListener를 수행하려면 어떻게해야합니까? 나는 JGraphMenu
&을 사용하여 각 항목에 대한 경고를 표시하려고합니다.JGraphMenu를 사용하는 메뉴 항목의 ActionListener
public static void main(String[] args){
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
List<String> MenuItem = new ArrayList<String>();
MenuItem.add("Choose The XML File");
MenuItem.add("Generate the tree");
MenuItem.add("Generate the latex code");
MenuItem.add("Generate automata");
List<ActionListener> listeners = new ArrayList<ActionListener();
for(int i=0; i<4; i++){
listeners.add(null);
}
JGraphMenu menu = new JGraphMenu(
ConstantesStyles.NOIR,
JGraphMenu.VERTICAL,
MenuItem, listeners
);
JPanel panel = new JPanel();
panel.add(menu);
panel.setSize(50, 100);
f.add(panel, BorderLayout.WEST);
f.setSize(500, 400);
f.setLocationRelativeTo(null);
f.setVisible(true);
}
}