Update data on a page without refreshing

This is typically achieved with a technique called AJAX. This technique loads data asynchronously (in the background) so it can update your content without needing to reload the page. The easiest way to implement AJAX is with the jQuery load() method. This method provides a simple way to load data asynchronous from a web server … Read more

JTable How to refresh table model after insert delete or update the data.

If you want to notify your JTable about changes of your data, use tableModel.fireTableDataChanged() From the documentation: Notifies all listeners that all cell values in the table’s rows may have changed. The number of rows may also have changed and the JTable should redraw the table from scratch. The structure of the table (as in … Read more

Refresh Part of Page (div)

Use Ajax for this. Build a function that will fetch the current page via ajax, but not the whole page, just the div in question from the server. The data will then (again via jQuery) be put inside the same div in question and replace old content with new one. Relevant function: http://api.jquery.com/load/ e.g. $(‘#thisdiv’).load(document.URL … Read more

SwingPropertyChangeSupport to dynamically update JTextArea

Here is a complete example that uses ObservedPanel in a modeless dialog. public class PropertyChangeDialog extends JPanel { private JLabel label = new JLabel(“null”, JLabel.CENTER); private ObservedPanel observed = new ObservedPanel(); public PropertyChangeDialog() { this.setBorder(BorderFactory.createTitledBorder(“Observer”)); this.add(label); observed.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName().equals(ObservedPanel.PHYSICIST)) { String value = e.getNewValue().toString(); label.setText(value); } } … Read more

refreshing background color for a row in jtable

for example, import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Random; import java.util.Vector; import javax.swing.*; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import javax.swing.table.AbstractTableModel; import javax.swing.table.TableCellRenderer; public class Forum implements ListSelectionListener { private JFrame frame = new JFrame(“Frame”); private JPanel fatherCenter = new JPanel(); private JScrollPane tableScroll = new JScrollPane(); private myTableModel tableModel; private JTable … Read more