View Javadoc

1   /*
2    * CopyAction.java
3    *
4    * Created on 27. mai 2005, 21:24
5    */
6   
7   package com.vikash.firsttool.UI;
8   import com.vikash.firsttool.Diagram.ToolGraph;
9   import java.awt.event.*;
10  import java.net.URL;
11  import javax.swing.*;
12  
13  /***
14   *
15   * @author  studajb
16   */
17  public class CopyAction extends AbstractAction{
18      ToolGraph graph;
19      ToolInternalFrame internalframe;
20      MainFrame frame;
21      static CopyAction instance;
22      
23      
24      public static CopyAction getinstance(final MainFrame frame,boolean flag){ 
25          if(flag)
26              instance=null;
27          if(instance==null){
28              instance=new CopyAction(frame);
29          }
30          return instance;
31      }
32      
33      
34      
35      /*** Creates a new instance of CopyAction */
36      public CopyAction(MainFrame frame)  {
37          URL icon=getClass().getClassLoader().getResource("com/vikash/firsttool/resources/copy.gif");
38          putValue(Action.SMALL_ICON,new ImageIcon(icon));
39          putValue(Action.SHORT_DESCRIPTION,"Copy");
40          putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke(KeyEvent.VK_C,InputEvent.CTRL_MASK));
41          this.frame=frame;
42          
43      }
44      public void actionPerformed(ActionEvent e) {
45          internalframe=(ToolInternalFrame)frame.getDesktopPane().getSelectedFrame();
46          if(internalframe != null){
47              
48              graph=internalframe.getGraph();
49              TransferHandler .getCopyAction() .actionPerformed(
50              new ActionEvent(graph, e.getID() , e.getActionCommand(),e.getModifiers() ));
51          }
52      }
53      
54  }