Class JDLibraryViewer

All Implemented Interfaces:
JDrawEditorListener, ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants

public class JDLibraryViewer extends JFrame implements ActionListener, JDrawEditorListener
Displays a JDraw file in a library view (only selection and clipboard operations allowed).

Example of use: (This example shows how to create a custom editor and add a component library)

 public class VacEdit extends JDrawEditorFrame {

  private JButton libButton;
  private JDLibraryViewer libViewer;
  private JDrawEditor ed = new JDrawEditor(JDrawEditor.MODE_EDIT);
  private JDrawEditor py = new JDrawEditor(JDrawEditor.MODE_PLAY);

public VacEdit() {

  ed = new JDrawEditor(JDrawEditor.MODE_EDIT);
  py = new JDrawEditor(JDrawEditor.MODE_PLAY);

  String libPath = System.getProperty("LIBPATH", "null");
  if( libPath.equals("null") )
   System.out.println("Warning LIBPATH is not defined.");

  // Customize the editor
  libViewer = new JDLibraryViewer(libPath+"/jvacuum_lib.jdw",ed);
  libViewer.setTitle("ESRF vacuum library");
  ATKGraphicsUtils.centerFrameOnScreen(libViewer);

  libButton = new JButton(new ImageIcon(getClass().getResource("/jvacuum/vac_button.gif")));
  libButton.setPressedIcon(new ImageIcon(getClass().getResource("/jvacuum/vac_button_push.gif")));
  libButton.setToolTipText("ESRF vacuum library");
  libButton.setMargin(new Insets(3,3,3,3));
  libButton.setBorder(null);

  libButton.addActionListener(this);
  editToolBar.add(new JLabel(new ImageIcon(getClass().getResource("/fr/esrf/tangoatk/widget/util/jdraw/gif/jdraw_separator.gif"))));
  editToolBar.add(libButton);

  setAppTitle("JVacuum Editor 1.0");
  setEditor(ed);
  setPlayer(py);

}

public void actionPerformed(ActionEvent e) {

  Object src = e.getSource();
  if( src== libButton ) {
    libViewer.setVisible(true);
  } else {
    super.actionPerformed(e);
  }

}


public static void main(String[] args) {

  VacEdit v = new VacEdit();
  ATKGraphicsUtils.centerFrameOnScreen(v);
  v.setVisible(true);

}

}
 
See Also: