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