private JTextField _listSelection;
private JButton _deleteButton;
JListPanel() {
setBorder(new TitledBorder("JList"));
setLayout(new BorderLayout());
add(new JLabel("Use UP, DOWN, PGUP, PGDN, HOME & END to navigate"),
BorderLayout.NORTH);
String[] vehicles = { "Volkswagen", "Rolls-Royce", "Toyota",
"Chrysler", "Mercedes Benz", "Bentley", "Bugatti",
"Maserati", "Porsche"};
DefaultListModel model = new DefaultListModel();
int columns = 0;
for (int i = 0; i < vehicles.length; i++) {
model.addElement(vehicles[ i]);
if (vehicles[ i].length() > columns)
columns = vehicles[ i].length();
}
model.addListDataListener(this);
_vehicleList = new JList(model);
_vehicleList.setVisibleRowCount(5);
_vehicleList.setColumns(columns);
_vehicleList.addListSelectionListener(this);
JScrollPane scrollpane = new JScrollPane(_vehicleList);
scrollpane.setViewportBorder(new TitledBorder("Vehicles"));
add(scrollpane, BorderLayout.WEST);
_selectionMode = new JCheckBox("Selection Mode = Multiple");
_selectionMode.addItemListener(this);