Questo e il codice puoi aiutarmi ?
codice:
//JLIST///////////////////////////////////
model = new DefaultListModel<Object>();
list = new JList<Object>(model);
list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
list.setSelectedIndex(0);
list.setBounds(20,140,140,100);
public void actionPerformed(ActionEvent e) {
if(e.getSource() == add) {
int a = list.getSelectedIndex();
indice = new String[10];
indice[0] = t2.getText();
indice[1] = t1.getText();
indice[2] = t3.getText();
indice[3] = t4.getText();
if(a == -1) {
a = 0;
} else {
a++;
}
model.addElement(indice[0].toString());
t1.requestFocus();
t1.setText(""); t2.setText(""); t3.setText(""); t4.setText("");
list.setSelectedIndex(a);
list.ensureIndexIsVisible(a);
}
if(e.getSource() == cancella) {
int a = list.getSelectedIndex();
model.remove(a);
int dim = model.getSize();
if (a == dim) {
a--;
}
list.setSelectedIndex(a);
list.ensureIndexIsVisible(a);