0
JList
に要素を追加できますが、選択した要素を削除するにはどうすればよいですか?jlistからテキストを削除するにはどうしたらいいですか?
DefaultListModel<String> model = new DefaultListModel<>();
button1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// int n = JOptionPane.showConfirmDialog(Jframe.this,"Clicked?");System.out.println(n);
String name = textfield1.getText();
model.addElement(name);
custList.setModel(model);
}
});
button2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
です。 – duffymo
[DefaultListModel#removeElement'](https://docs.oracle.com/javase/8/docs/api/javax/swing/DefaultListModel.html#removeElement-java.lang.Object-)または[DefaultListModel# ' removeElementAt'](https://docs.oracle.com/javase/8/docs/api/javax/swing/DefaultListModel.html#removeElementAt-int-)? – bradimus
これは私にとって重要な例にしてください – kingramx