Skip to content

Commit eba9bfc

Browse files
committed
cut copy paste using inbuilt functionality
1 parent ed1d059 commit eba9bfc

6 files changed

Lines changed: 10 additions & 8 deletions

File tree

bin/main/TextEditor$7.class

-78 Bytes
Binary file not shown.

bin/main/TextEditor$8.class

-329 Bytes
Binary file not shown.

bin/main/TextEditor$9.class

-158 Bytes
Binary file not shown.

bin/main/TextEditor.class

0 Bytes
Binary file not shown.

nullnull

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
class hello{
22
public static void main{
33
System.out.println("Hello World");
4-
Hello how
4+
hello java
5+
how are you
56
}
67
}

src/main/TextEditor.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ public void actionPerformed(ActionEvent e) {
312312
mntmCopy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK));
313313
mntmCopy.addActionListener(new ActionListener() {
314314
public void actionPerformed(ActionEvent e) {
315-
316-
str = textArea.getSelectedText();
315+
textArea.copy();
316+
//str = textArea.getSelectedText();
317317
}
318318
});
319319
mntmCopy.setIcon(new ImageIcon("C:\\Users\\rahul\\Downloads\\copy.jpg"));
@@ -323,11 +323,12 @@ public void actionPerformed(ActionEvent e) {
323323
mntmCut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));
324324
mntmCut.addActionListener(new ActionListener() {
325325
public void actionPerformed(ActionEvent e) {
326-
326+
textArea.cut();
327+
/*
327328
str = textArea.getSelectedText();
328329
n = textArea.getText().indexOf(str);
329330
textArea.replaceRange("", n, str.length());
330-
331+
*/
331332
}
332333
});
333334
mntmCut.setIcon(new ImageIcon("C:\\Users\\rahul\\Downloads\\cut(1).jpg"));
@@ -337,9 +338,9 @@ public void actionPerformed(ActionEvent e) {
337338
mntmPaste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK));
338339
mntmPaste.addActionListener(new ActionListener() {
339340
public void actionPerformed(ActionEvent e) {
340-
341-
position = textArea.getCaretPosition();
342-
textArea.insert(str, position);
341+
textArea.paste();
342+
//position = textArea.getCaretPosition();
343+
//textArea.insert(str, position);
343344
}
344345
});
345346
mntmPaste.setIcon(new ImageIcon("C:\\Users\\rahul\\Downloads\\paste.jpg"));

0 commit comments

Comments
 (0)