このように、ComboBox から選択した値を出力できます。
public static String selectedString(ItemSelectable is) {
Object selected[] = is.getSelectedObjects();
return ((selected.length == 0) ? "null" : (String)selected[0]);
}
public static void main(String[] args) {
// Add ActionListener
ActionListener actionListener = new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
ItemSelectable is = (ItemSelectable)actionEvent.getSource();
String name=selectedString(is);
System.out.println(name);
}
};
// Add Actionlistener to ComboBox kundeAuswahl
kundeAuswahl.addActionListener(actionListener);
// i wanna have the value of name for use here:
// String test[] = getChildAsArray("kunde","projekt",name);
}
しかし、この関数から値の名前を取得したいのですが、通常は return を使用しますが、これによりエラーが発生します。では、どうすればいいですか?