public class MyScrollPane extends JScrollPane implements SwingViewer {
DataModel model;
public MyScrollPane() { }
public JComponent createJComponent(ViewerFactory factory) { try { // create a default viewer JComponent which is associated to the given model DataViewer dataViewer = factory.createDefaultViewer(model); JComponent comp = dataViewer.getJComponent();
// put the created JComponent into the JScrollPane (to be the actual viewport view) setViewportView(comp); } catch (Exception ex) { ex.printStackTrace(); }
return this; }
public boolean isEditor() { return false; }
public void setDataModel(DataModel model) { this.model = model; }
public DataModel getDataModel() { return model; } }
@author Marcel Baumann