Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/embl/ebi/escience/scuflui/workbench/GenericUIComponentFrame.java


1   /**
2    * This file is a component of the Taverna project,
3    * and is licensed under the GNU LGPL.
4    * Copyright Tom Oinn, EMBL-EBI
5    */
6   package org.embl.ebi.escience.scuflui.workbench;
7   
8   import javax.swing.JComponent;
9   import javax.swing.JInternalFrame;
10  import javax.swing.JScrollPane;
11  import javax.swing.event.InternalFrameAdapter;
12  import javax.swing.event.InternalFrameEvent;
13  import org.embl.ebi.escience.scufl.ScuflModel;
14  import org.embl.ebi.escience.scuflui.ScuflUIComponent;
15  
16  
17  /**
18   * An internal frame containing a class implementing the
19   * scuflui.ScuflUIComponent interface. This implementation
20   * places the component in a scroll pane inside an internal
21   * frame, registers it with the model and creates an event
22   * listener such that closing the internal frame will deregister
23   * the component from the model.
24   * @author Tom Oinn
25   */
26  public class GenericUIComponentFrame extends JInternalFrame {
27  
28      ScuflUIComponent component;
29     
30      public GenericUIComponentFrame(ScuflModel model, ScuflUIComponent component) {
31    super(component.getName(), true, true, true, true);
32    this.component = component;
33    JScrollPane pane = new JScrollPane((JComponent)component);
34    getContentPane().add(pane);
35    // Bind to the specified model
36    component.attachToModel(model);
37    // Unbind on window close
38    addInternalFrameListener(new InternalFrameAdapter() {
39      public void internalFrameClosing(InternalFrameEvent e) {
40          GenericUIComponentFrame.this.component.detachFromModel();
41      }
42        });
43    setSize(400,400);
44    moveToFront();
45    setVisible(true);
46      }
47      
48  }