Java Reference
In-Depth Information
Enumeration newValues = defaults.elements();
values.removeAllElements();
while (newValues.hasMoreElements()) {
values.addElement(newValues.nextElement());
}
fireTableDataChanged();
}
}
public static void main(String args[]) {
Runnable runner = new Runnable() {
public void run() {
final JFrame frame = new JFrame("List Properties");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final CustomTableModel model = new CustomTableModel();
model.uiDefaultsUpdate(UIManager.getDefaults());
TableSorter sorter = new TableSorter(model);
JTable table = new JTable(sorter);
TableHeaderSorter.install(sorter, table);
table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
UIManager.LookAndFeelInfo looks[] =
UIManager.getInstalledLookAndFeels();
ActionListener actionListener = new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
final String lafClassName = actionEvent.getActionCommand();
Runnable runnable = new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel(lafClassName);
SwingUtilities.updateComponentTreeUI(frame);
model.uiDefaultsUpdate(UIManager.getDefaults());
} catch (Exception exception) {
JOptionPane.showMessageDialog (
frame, "Can't change look and feel",
"Invalid PLAF", JOptionPane.ERROR_MESSAGE);
}
}
};
EventQueue.invokeLater(runnable);
}
};
Search WWH ::




Custom Search