Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ufk-dev] Swing ObservableListTableModel remove glitch

Hi there!

I think there is a problem with the way ObservableListTableModel
handles row delete.
If multiple top rows are removed from the model for some reason a part
of the JTable is not updated.
I cannot pinpoint what causes this problem, mimicking the same
scenario with DefaultTableModel works just fine.
ObservableListTableModel handles all the remove operations correctly,
all the required events are fired... but still.

Could anyone help me?

Thank you!



A simple demo to demonstrate the issue - run and click the "Remove"
button:the result will be just like it on the attached screenshot.

SwingUtilities.invokeLater(new Runnable() {

			@Override
			public void run() {
				SwingRealm.createDefault();
				final IObservableList l = WritableList.withElementType(Object.class);
				l.add("1");
				l.add("2");
				l.add("3");
				ObservableListTableModel model = new ObservableListTableModel(l);
				model.addColumn("val");
				JTable t = new JTable(model);

				JFrame f = new JFrame();
				f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				f.setLayout(new BorderLayout());
				f.add(t, BorderLayout.CENTER);
				f.add(new JButton(new AbstractAction("Remove") {

					@Override
					public void actionPerformed(ActionEvent e) {
						l.removeAll(Arrays.asList("1", "2"));
					}
				}), BorderLayout.NORTH);

				f.pack();
				f.setVisible(true);
			}
		});

Attachment: remove.png
Description: PNG image


Back to the top