Update jButton from ListSelectionHandler
Hi,
Just starting a Java conversion from .NET so I do understand programming principals, just from the Microsoft world...
I'm trying to update a button on a jPanel, so that it is enabled/disabled if a table row is selected. I have looked at all the examples from sun.com etc for information but unable to figure it out.
I have a ListSelectionListener registered with the jTable selectionModel, but how do I reference the button in the jForm, as every time I write btnEdit, it is highlighted as an unrecognised variable?!?!
Thanks for all assistance in advance.
Code:
public class ReplicatorView extends FrameView implements WindowListener {
public ReplicatorView(SingleFrameApplication app) {
super(app);
initComponents();
...
...
// Now my extra setup component setup
this.getFrame().addWindowListener(this);
jTable1.setModel(_tableModel);
ListSelectionModel listSelectionModel = jTable1.getSelectionModel();
listSelectionModel.addListSelectionListener(new ReplicatorListSelectionHandler());
// Now initialise App
LoadConfig();
}
}
public class ReplicatorListSelectionHandler implements ListSelectionListener {
public void valueChanged(ListSelectionEvent e) {
ListSelectionModel lsm = (ListSelectionModel)e.getSource();
// as we only have single row selection, this should be adequate
if (!lsm.getValueIsAdjusting() && lsm.isSelectionEmpty())
{
btnEdit.setEnabled(false);
}
}
}