While Pressing Ctrl+v it is pasting twice

The following is my piece of code
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.awt.datatransfer.*;
public class CopyPasteExample extends JFrame implements KeyListener
     JTextArea textArea;
     String s;
     JMenuBar menuBar;
     JMenu Edit;
     JMenuItem cut,copy,paste;
     EditorActions editorActions;
     public CopyPasteExample()
     textArea = new JTextArea(200,300);
     editorActions = new EditorActions(this);
     add(textArea,BorderLayout.CENTER);
     menuBar = new JMenuBar();
     Edit = new JMenu("Edit");
     Edit.add(editorActions.cutAction);
     Edit.add(editorActions.copyAction);
     Edit.add(editorActions.pasteAction);
     menuBar.add(Edit);
     setJMenuBar(menuBar);
     setSize(400,400);
     setVisible(true);
     textArea.addKeyListener(this);
     public void keyPressed(KeyEvent e)
          if(e.getKeyCode() == KeyEvent.VK_C)
               s = textArea.getSelectedText();
     public void keyReleased(KeyEvent e)
          if(e.getKeyCode() == KeyEvent.VK_V)
               appendText(s);
     public void keyTyped(KeyEvent e)
     public void doCopy()
          s = textArea.getSelectedText();
     System.out.println("The Selected COPY STRING"+s);
     public void doCut()
     public void doPaste()
          appendText(s);
     public void appendText(String s)
System.out.println("The selq"+textArea.getSelectedText());
if(textArea.getSelectedText() != null)
          textArea.replaceSelection(s);
System.out.println("Entered IF");
else
System.out.println("Enteringi else");
textArea.insert(s, i);
public static void main(String args[])
          CopyPasteExample copy = new CopyPasteExample();
class EditorActions
public AbstractAction cutAction;
public AbstractAction copyAction;
public AbstractAction pasteAction;
     public EditorActions(CopyPasteExample example)
     final CopyPasteExample copy=example;
     setAction(copyAction = new AbstractAction()
          {public void actionPerformed(ActionEvent e)
               {copy.doCopy();}},
               "copy","VK_C","C");
     setAction(cutAction = new AbstractAction()
          {public void actionPerformed(ActionEvent e)
               {copy.doCut();}},
               "cut","VK_X","X");
     setAction(copyAction = new AbstractAction()
          {public void actionPerformed(ActionEvent e)
               {copy.doPaste();}},
               "copy","VK_V","P");
public static void setAction(Action action, String label,String mnemonic,
String acceleratorKey)
     if (acceleratorKey != null && acceleratorKey.length() > 0)
action.putValue(Action.ACCELERATOR_KEY,
KeyStroke.getKeyStroke(acceleratorKey));
if (label != null && label.length() > 0)
action.putValue(Action.NAME, label);
if (mnemonic != null && mnemonic.length() > 0)
KeyStroke key = KeyStroke.getKeyStroke(mnemonic);
if (key != null)
action.putValue(Action.MNEMONIC_KEY,
new Integer(key.getKeyCode()));
Please help me out in this issue

That's because you coded it all twice. You have one implementation via accelerators and another via key listeners. You only need one of those.

Similar Messages

  • Tecra M5 - Press Ctrl-Alt-Delete splash screen appears while booting

    Wondered if anyone has come across this before...
    Tecra M5 boots up ok and arrives at the "Press Ctrl-Alt-Delete" splash screen... the "Help" button is permanently "selected" so as soon as I press CTRL and ALT the explanation (Help) screen comes up telling me what to do... and I can't get past that at all... I've tried attaching a USB keyboard with the same result. I need to somehow "clear" the Help button ....
    Any idea's gratefully received.

    Problem solved... use the Alt GR key instead... worked first time !!

  • Whenever i press backspace, the same thing that happens when i press 'ctrl + shift + I' happens

    Whenever i press backspace, it does the same the same thing as if i press 'ctrl + shift + i', and again the same thing as if i press 'toggle tools' from the web developer option under tools from the menu at the top of firefox. I'm not a developer, i don't need this console thingy, and wouldn't mind getting rid of it. I didn't install it on purpose, and i have no idea what made this start happening recently. It's getting INCREDIBLY annoying.

    The backspace key shouldn't be opening the Console.
    '''Try the Firefox SafeMode''' to see how it works there. <br />
    ''A troubleshooting mode, which disables most Add-ons.'' <br />
    [https://support.mozilla.org/en-US/kb/troubleshoot-firefox-issues-using-safe-mode#w_safe-mode-window_2 Troubleshoot Firefox issues using Firefox SafeMode]
    When in Safe Mode... <br />
    * The status of plug-ins is not affected.
    * Custom preferences are not affected.
    * All extensions are disabled.
    * The default theme is used, without a persona.
    * userChrome.css and userContent.css are ignored.
    * The default toolbar layout is used.
    * The JIT Javascript compiler is disabled.
    * Hardware acceleration is disabled.
    * You can open the Firefox 15.0+ SafeMode by holding the '''Shft''' key when you use the Firefox desktop or Start menu shortcut.
    * Or use the Help menu item, click on '''Restart with Add-ons Disabled...''' while Firefox is running.
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before using the Firefox shortcut (without the Shft key) to open it again.''
    '''''If it is good in the Firefox SafeMode''''', your problem is probably caused by an extension, and you need to figure out which one. <br />
    http://support.mozilla.com/en-US/kb/troubleshooting+extensions+and+themes <br />
    Or it might be caused by Hardware Acceleration.
    ''When you figure out what is causing that, please let us know. It might help other user's who have that problem.''

  • Failure id 90DX6C-56S​5S1-9XL03f​-60S403 - A disk read error occurred. Press Ctrl+Alt+D​el to restart.

    Model: HP G62 Notebook PC
    System ID: 1439
    Product ID: WR444EA¤UUW
    Warranty Start Date: 08/06/2010
    Processor Type: Intel(R) Pentium(R) CPU    P6000 @ 1.87 GHz
    Processor Speed: 1870 MHZ
    Memory Size: 4096 MB RAM
    BIOS Date: 06/28/2010
    BIOS Revision: F.0B
    Serial Number {Removed for privacy}
    Keyboard Controller Revision: 60.22
    OS: Windows 7 - don't remember if 64 or 32 tbh (it's my GFs laptop)
    Error:
    Suddenly today, about 9 hours ago, the laptop froze while surfing normally on the net.. After a reset - done as followed: holding power button till computer shuts down, and power on again - the computer wouldn't start windows again, and only gives the message:
    A disk read error occurred. Press Ctrl+Alt+Del to restart.
    And will repeat the message after booting up with HP logo, and not enter Windows, time and time again if you press C+A+D
    I've tried recovery system, but that didn't work, and I'ved tried CHKDSK and it found and said it repaired some errors but it still happens.
    I then ran the start-up-test and in the end I got Failure ID 90DX6C-56S5S1-9XL03f-60S403 on Hard Disk 1.
    I tried to Google it, and no results.
    No recent system updates or anything new installed in a few weeks.

    Hi,
    It would look like the Hard Drive is failing/failed, but try running the following test from the bios menu as it can provide a more meaningful error code.
    Shutdown the notebook.  Tap away at f10 as you start the notebook to enter the bios menu.  Under the Advanced or Diagnostic tab you should find the facility to run a test on the Hard Drive.  Post back with the details of any error messages.
    Regards,
    DP-K
    ****Click the White thumb to say thanks****
    ****Please mark Accept As Solution if it solves your problem****
    ****I don't work for HP****
    Microsoft MVP - Windows Experience

  • Can I change an object perspective like pressing ctrl in Photoshop?

    In Photoshop, you can transform a layer by pressing ctrl while you click in the border of the object. I would like to do it on Illustrator CS6, is there anything like this tool available?

    Read about the Free Transform tool in AI help.

  • 'FRM-41008 - Undefined function key. Press  Ctrl + F1... ' Urgent Pls help

    Hi All,
    We are facing below issue in Oracle 10g Forms.
    We are opening one screen with mutlirecord block and query the recod(First Session) and at the same time we are trying to query one more session(Second session) with same data.
    While querying second session we have blocked the user to proceed further by using select ..... for update of columns and user will get error message
    'Transaction is already locked by another user....'. and we have kept second screen opened.
    Afterwards we are going back to first screen in first session and trying to update the record (Change price column and navigate to next item by using tab key. We are not using anhy other key) System is not allowing to update the record and screen is freezed and cursor control will go to items randomnly and displays below error message.
    'FRM-41008 - Undefined function key. Press Ctrl + F1 for list of valid keys.
    Could somebody pls explaining why above error message 'FRM-41008 ...' is showing for locking record issue ? Any trigger is firing above error message ?
    Thanks in advance
    Biju

    Thanks for the reply but we don't have key others trigger ,we have only when-new-form-instance trigger in form level. That being the case, I recommend you run your Form through the Forms Debugger to see where the form is generating this error. If you are unable to use the Forms Debugger, then I suggest you try running your form with the Forms Runtime Diagnostics (FRD) to see if you can discover the cause of the error. Take a look at this thread for a description of FRD and how to set it up: Re: dbms_session exception without any error. Although, the topic of this thread is not the same as yours, my reply is related. :)
    Craig...

  • Accidentally pressed ctrl-F5. Its muted. What to do now?

    I accidentally pressed ctrl-F5 on my Macbook. And now its on mute. Tried everything. Does not sing. What should I do?

    What do you mean by "tried everything"? Could you be more specific?
    When you try to adjust the volume, what happens? Do you see any symbols on the screen?
    Try adjusting the volume while logged into another user account (create another account if necessary).
    ~Lyssa

  • I need an alert message if I press ctrl shift b

    Hi All,
    I Need an alert message if I Press "ctrl+shift+b"(to make the selected text bold). Is this possible?
    Regards,
    Chinna

    Create a keyboard shortcuts (ctrl + shift + b) for your script and try...
    Code must be like this:
    alert("Bold Shortcut....");
    app.selection[0].fontStyle = "Bold";
    P.S.: you have to set conditions for bold, bold italic, etc. 
    Vandy

  • Revolve 810 G1 Unlock Computer when in Tablet Mode. Press CTRL-ALT-DEL or Windows Security Button

    1.  I have an Revolve 810 G1
         Running Windows 7 Pro (64 Bit).
    When I change the screen to Tablet Mode
      (Folding tablet over keyboard and using as tablet).
    I lock my computer.
    2.  What to know how to unlock without having to Open back up and use the CTL-Alt-DEL keys.
    When Locked screen shows:  Press CTRL-ALT-DEL or use the Windows Security Button to unlock this computer.
    I would like to use the Windows Button on the bottom of the screen
       (One Used in Windows 8 to change between Desktop and Metro) to Unlock screen And bring up on screen keyboard to put in my password.
    This is probably how it should work, but it does not work.
    Even bringing up the onscreen keyboard via the blue power button On the screen to Ease Of Access does not work.
    The CLT-ALT-DEL on the on screen keyboard will not unlock the screen.
    P.S.
    Where is that Windows Security Button when you need it? 
    Thanks,
    Rog

    If you are using Windows 7 (not Windows 8), you should be able to touch the Ease of Access button at the lower left of the screen, then select Type without the keyboard (On-screen keyboard). When the on-screen keyboard pops-up, press CTRL, then ALT, then DEL. You should get a password prompt; the on-screen keyboard will stay visible unless and until you close it.
    Although I am an HP employee, I am speaking for myself and not for HP.
    Please click the little thumbs-up dealybopper to the lower right if my reply was helpful to you. Please mark Accept As Solution if it solves your problem. This will help others, too!

  • "Undefined Function Key. Press Ctrl+F1..." Porting app from 6i to 10G

    I am running into a problem porting my application from Oracle Forms 6i to 10G. When I am querying a record based on a field that is not the first on the screen, I get an "Undefined Function Key. Press Ctrl+F1 for list of valid keys." error. I do not get the error using the same function keys from the first field on the screen. I also do not get the error if I click into another field (besides the one I an querying) before hitting my execute query key.
    I did some research, and found a fix that seems to work. I can add a WHEN_MOUSE_CLICKED trigger to the form and put in the following:
    Go_Item(:System.Mouse_Item);
    That seems to fix the issue. My problem is that I have close to 400 forms to upgrade. I would like to avoid adding this manually to every single form. I have looked into libraries, but I can't seem to figure out how to replicate a WHEN_MOUSE_CLICKED trigger using procedures. I was wondering if there was a way to use the Forms upgrade utility to add this trigger to every form it converts. Does anyone know if that can be done?
    Thanks in advance for your help with this.

    I'm not sure this solves the problem. This would call the trigger, but the trigger does not currently exist. I would still have to manually create the trigger in all 400 (or so) forms. Is there a way to add it in a more global way?
    Thanks.

  • Firefox 9.0.1 keeps hanging once I access a website with video, when I write e-mails etc. If a press ctrl+alt+del, opens a window to confirm closing, and firefox works again. When I close that confirm window, firefox immediately hangs again.

    It stops working if I access websites with videos, and all sort of more complex flash. It I try to write an e-mail, it also stops. I can't do anything. PC keeps working, though. So I press ctrl+alt+del. It opens that window asking if you want to close all the tabs. I notice that firefox start to work again, behind that window. But, once I close the window, it stops again. Sometimes I can close the tab with the video before it hangs again, which can take a few ctr+alt+del's. It doesn't happen with other browsers! It started 1 week ago. Is it an extension? Or a virus (i use avast)? Thank you!

    Perform the suggestions mentioned in the following articles:
    * [https://support.mozilla.com/en-US/kb/Template:clearCookiesCache/ Clear Cookies & Cache]
    * [[Troubleshooting extensions and themes]]
    * [[Managing the Flash plugin]]
    Check and tell if its working.

  • While Pressing the button i want to skip first screen in standard screen.

    Hello All,
    I need to create a z Program and call a screen variant of a standard transaction in it.
    I am calling a screen variant of transaction PA70 to hide some of the fields of the screen.
    Also the first screen is supressed.
    My requirement is while pressing back button it should not come on the first screen.
    while if i am doing the same thing with Transaction PA20 it is not coming back to first screen.
    How can i supress this first screen while coming back?
    Regards.

    Hi,
    Use:
    "set al the field values on the initial screen of the transaction and then use
    CALL TRANSACTION '<t-code>' AND SKIP FIRST SCREEN.
    Now you will be navigated to second screen of the transaction, when you click, you will be navigated to your program selection screen.
    Hope this helps you.
    Regards,
    Tarun

  • How do I tell itunes (on a Windows XP PC) to start adding downloaded files to an external drive ? Starting itunes while pressing the shift key and then choosing works only for a MAC, I think. I only need this one final step. All is copied already

    How do I tell itunes on a Windows XP PC to start downloading new songs to my external drive ? The whole library has already been moved. I am just one final step away. Everything I`m downloading still lands on C: Relaunching itunes while pressing "shift" and then getting prompted to choose library might work for a Mac, it doesn't for Windows.

    In iTunes click on 'Edit', then 'Preferances', Click on the 'Advanced' button, change the entry in the 'iTunes media folder location' to point to your external drive.

  • If I want to open the same website in a second tab and press Ctrl+T and start typing the website title or URL, why does Firefox 4 insist on switching to the first tab? Is it possible to turn this off?

    I regularly need to open the same website in two tabs, to be able to view changes made between opening the first and second tabs. In Firefox 3.x I could press Ctrl+T and start typing the website title or URL, which would be auto-completed by Firefox. This enabled me to quickly open the same website in a second tab. Firefox 4 does not do this, instead it wants me to switch to the existing tab. This is not what I need.
    Of course it is possible to open the same website in a second tab via e.g. a bookmark, but this takes more time and effort. It would be great if I could select Firefox's behavior in this situation.

    To create a duplicate of an existing tab in Firefox 4, do one of the following:
    *middle-click the icon on the left end of the URL/Location/Address Bar
    *hold down the Ctrl key and drag the tab until a small arrow appears at the border between tabs, then release the mouse button, then release the Ctrl key.
    <br />
    <br />
    You have multiple Java Console extensions because Java did not clean up after itself when updating; Firefox button > Add-ons > Extensions OR, using the Menu Bar, Tools > Add-ons > Extensions:
    *Java Console 6.0.17, Java Console 6.0.19, Java Console 6.0.20, Java Console 6.0.21, Java Console 6.0.22, Java Console 6.0.23
    Using the instructions here:
    *http://kb.mozillazine.org/Firefox_:_FAQs_:_Install_Java#Multiple_Java_Console_extensions
    you can delete the following folders:
    *{CAFEEFAC-0016-0000-00'''''17'''''-ABCDEFFEDCBA}
    *{CAFEEFAC-0016-0000-00'''''19'''''-ABCDEFFEDCBA}
    *{CAFEEFAC-0016-0000-00'''''20'''''-ABCDEFFEDCBA}
    *{CAFEEFAC-0016-0000-00'''''21'''''-ABCDEFFEDCBA}
    *{CAFEEFAC-0016-0000-00'''''22'''''-ABCDEFFEDCBA}
    *{CAFEEFAC-0016-0000-00'''''23'''''-ABCDEFFEDCBA}
    You can leave {CAFEEFAC-0016-0000-00'''''24'''''-ABCDEFFEDCBA}
    <br />
    <br />
    '''You need to update the following:'''
    *Adobe Shockwave for Director Netscape plug-in, version 11.5
    *Adobe PDF Plug-In For Firefox and Netscape "9.3.3"
    *Shockwave Flash 10.2 r152
    #'''''Check your plugin versions''''' on either of the following links':
    #*http://www.mozilla.com/en-US/plugincheck/
    #*https://www-trunk.stage.mozilla.com/en-US/plugincheck/
    #*'''Note: plugin check page does not have information on all plugin versions'''
    #*There are plugin specific testing links available from this page:
    #**http://kb.mozillazine.org/Testing_plugins
    #'''Update Shockwave for Director'''
    #*NOTE: this is not the same as Shockwave Flash; this installs the Shockwave Player.
    #*Use Firefox to download and SAVE the installer to your hard drive from the link in the article below (Desktop is a good place so you can find it).
    #*When the download is complete, exit Firefox (File > Exit)
    #*locate and double-click in the installer you just downloaded, let the install complete.
    #*Restart Firefox and check your plugins again.
    #*'''<u>Download link and more information</u>''': http://support.mozilla.com/en-US/kb/Using+the+Shockwave+plugin+with+Firefox
    #'''Update Adobe Reader (PDF plugin):'''
    #*From within your existing Adobe Reader ('''<u>if you have it already installed</u>'''):
    #**Open the Adobe Reader program from your Programs list
    #**Click Help > Check for Updates
    #**Follow the prompts for updating
    #**If this method works for you, skip the "Download complete installer" section below and proceed to "After the installation" below
    #*Download complete installer ('''if you do <u>NOT</u> have Adobe Reader installed'''):
    #**SAVE the installer to your hard drive (save to your Desktop so that you can find it after the download). Exit/Close Firefox. Run the installer you just downloaded.
    #**Use either of the links below:
    #***https://support.mozilla.com/en-US/kb/Using+the+Adobe+Reader+plugin+with+Firefox ''(click on "Installing and updating Adobe Reader")''
    #***''<u>Also see Download link</u>''': http://get.adobe.com/reader/otherversions/
    #*After the installation, start Firefox and check your version again.
    #'''Update the [[Managing the Flash plugin|Flash]] plugin''' to the latest version.
    #*Download and SAVE to your Desktop so you can find the installer later
    #*If you do not have the current version, click on the "Player Download Center" link on the "'''Download and information'''" or "'''Download Manual installers'''" below
    #*After download is complete, exit Firefox
    #*Click on the installer you just downloaded and install
    #**Windows 7 and Vista: may need to right-click the installer and choose "Run as Administrator"
    #*Start Firefox and check your version again or test the installation by going back to the download link below
    #*'''Download and information''': http://www.adobe.com/software/flash/about/
    #**Use Firefox to go to the above site to update the Firefox plugin (will also install plugin for most other browsers; except IE)
    #**Use IE to go to the above site to update the IE ActiveX
    #*'''Download Manual installers'''.
    #**http://kb2.adobe.com/cps/191/tn_19166.html#main_ManualInstaller
    #**Note separate links for:
    #***Plugin for Firefox and most other browsers
    #***ActiveX for IE

  • Error message NTLDR is missing - press ctrl alt del to restart

    Hello,
    I am extremely embarrassed to admit the following and ridiculously angry with myself for doing something as totally stupid as I did, but it is done now..sigh..
    I have the NTLDR is missing - press ctrl alt del to restart nightmare error.
    This is how it happened. I need(ed) to reformat my hard drive, but first I was going to back up everything. I back up every so often, though, now I know not near as often as I should!. (last back up was 5/21/07 sigh.) Well, not thinking, instead of backing up, I put the restore cd in the drive and the screen came up saying: "loading ramdisk" then I got to the next screen which basically was asking if I wanted to restore out of the box or not. I chose the first step in the wizard which said out of the box. Then I clicked NEXT and realized I had not backed up my files!! So I cancelled out of the restore cd wizard.
    When I restarted the computer, I got the aforementioned nightmare error.
    I have been researching for many, many hours on how to fix it or at least be able to boot into windows. I've done the following:
    1. created a floppy boot disk with ntldr, ntdetect.com, and boot.ini on it to restore I have all but I don't know if the dates mean anything on the ones downloaded from another laptop
    this did not work I still came up with the same error or some other errors one pointing to hal\something. i am not sure if it is my boot.ini that is causing the problem or what. Oh, by the way, I went into the BIOS and made sure that the computer booted up to FDD first when trying the floppy option.
    [boot loader]
    timeout=30
    default=multi(0)disk(0)

    Hi
    Its a very stupid and tricky situation.
    The simplest solution would be the HDD formatting and new reinstallation of the OS.
    But it seems you want to rescue all the files available on the HDD.
    Hopefully its not too late
    Hmmm. I think youve got only one chance!!! You have to remove the internal HDD from the notebook and try to connect it to second PC via external USB controller!!!!
    Such part is not expensive and can be ordered from every notebook dealer.
    You should be able to get the access to the HDD removed from notebook....
    After this procedure the HDD should be formatted in NTFS and all partition should be erased!
    Then you should try to start the installation procedure from the Windows or Recovery CD.
    By the way; I have investigate a little bit in the Microsoft database and found these both documents:
    http://support.microsoft.com/kb/318728
    http://support.microsoft.com/kb/314057
    Maybe some hints described in these documents could be useful.
    Good luck

Maybe you are looking for

  • "Flatten" option for multi-camera  is gone in new version of CC

    It has been a couple months since I have used this feature, but it is gone now. Now when I right click on a multi-camera clip, the only option is "Enable" (or disable by uncheking it). The option to "Flatten"was a huge benefit, and it was sorely lack

  • Abstract message

    hi expect,    why should we are creating abstract message?in bpm why we are using abstract message?

  • Beginner can't undeploy auto-deployed web app

    Hi. (I am brand new to WLS 10. I am testing it for a possible upgrade from WLS 8.) I auto-deployed a web application Weblogic Server 10.0. Now I am trying to undeploy it, but I just can't seem to make it go away. I first tried the delete button in th

  • Is it possible to condense the calendar view so that I can see the whole day on one screen under IOS7?

    Upraded to IOS7.  Am now unable to view a complete day of calendar on a single screen without scrolling up and down.  It appears to be a step backwards for the app.  Is there a way to change views in Calendar?

  • Load page in jquery dialog

    hi my apex version is 4.0.2 i try to load a page in a jquery dialog box the dialog box opens with following javascript error apex.jquery.datepicker._defaults is null or not an object here is the code i use function openForm() var url = 'f?p=&APP_ID.: