1 package org.columba.core.gui.util; 19 20 import javax.swing.JComponent ; 21 import javax.swing.JTextField ; 22 23 import org.columba.core.gui.base.UndoDocument; 24 25 30 31 public class CTextField extends JTextField { 32 35 public CTextField() { 36 super(); 37 38 setDocument(new UndoDocument()); 39 } 40 41 44 public CTextField(String arg0) { 45 this(); 46 47 setText(arg0); 48 } 49 50 51 public JComponent getComponent() { 52 return this; 53 } 54 55 public boolean isCopyActionEnabled() { 56 if (getSelectedText() == null) { 57 return false; 58 } 59 60 if (getSelectedText().length() > 0) { 61 return true; 62 } 63 64 return false; 65 } 66 67 public boolean isCutActionEnabled() { 68 if (getSelectedText() == null) { 69 return false; 70 } 71 72 if (getSelectedText().length() > 0) { 73 return true; 74 } 75 76 return false; 77 } 78 79 public boolean isDeleteActionEnabled() { 80 if (getSelectedText() == null) { 81 return false; 82 } 83 84 if (getSelectedText().length() > 0) { 85 return true; 86 } 87 88 return false; 89 } 90 91 public boolean isPasteActionEnabled() { 92 return true; 93 } 94 95 public boolean isRedoActionEnabled() { 96 return true; 98 } 99 100 public boolean isSelectAllActionEnabled() { 101 return true; 102 } 103 104 public boolean isUndoActionEnabled() { 105 return true; 107 } 108 109 public void delete() { 110 replaceSelection(""); 111 } 112 113 public void redo() { 114 ((UndoDocument) getDocument()).redo(); 115 } 116 117 public void undo() { 118 ((UndoDocument) getDocument()).undo(); 119 } 120 } 121 | Popular Tags |