私はJFrameをほとんど持っていません。そのうちの 1 つ (textBox を含む) を使用して、入力データを別のクラスの変数に転送したいと考えています。この変数は、JComboBox 選択リストを作成するために使用されます。JButton 経由で入力データを転送しようとしましたが、結局何も転送されず、JComboBox は空のままです。どうにかして JComboBox などを更新する必要がありますか? 私のコード:
...
DataBase toTable = new DataBase();
...
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent click) {
toTable.data[0] = textField.getText();
}
});
データベース クラスの変数:
....
String data[] = {"","","","",""};
....
And the Main Class (it contains JComboBox):
...
DataBase data0 = new DataBase();
final JComboBox list0 = new JComboBox(data0.data);
list0.setBounds(10, 61, 110, 22);
contentPane.add(list0);