Help me Invoke the Enter Button Action when Node is Editable State

I want to invoke an Action on press of the Enter Button when the Node is in Editable Mode.
Currently in the below code, The message "Ï am here" gets printed on selecting a node and cliking the 'Enter' Key.
I want the same message action to be invoked when we press F2 on a Node, when the Node is editable itself when a user clicks Enter Button
.import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.KeyStroke;
import javax.swing.tree.DefaultMutableTreeNode;
class NodeTree extends JTree {
     public void addActions() {
          ActionMap aMap = this.getActionMap();
          aMap.put("rename", new NodeTreeAction(this, "rename"));
          this.setActionMap(aMap);
          InputMap map = this.getInputMap(JComponent.WHEN_FOCUSED);
          map.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "rename");
          this.setInputMap(JComponent.WHEN_FOCUSED, map);
public class JTreeSample {
     public static void main(String[] args) {
          NodeTree tree = new NodeTree();
          JFrame frame = new JFrame("Manual Nodes Sample");
          DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
          DefaultMutableTreeNode mercury = new DefaultMutableTreeNode("Elem1");
          root.add(mercury);
          DefaultMutableTreeNode venus = new DefaultMutableTreeNode("Elem2");
          root.add(venus);
          DefaultMutableTreeNode mars = new DefaultMutableTreeNode("Elem3");
          root.add(mars);
          tree.setEditable(true);
          tree.addActions();
          JScrollPane scrollPane = new JScrollPane(tree);
          frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
          frame.setSize(300, 150);
          frame.setVisible(true);
class NodeTreeAction extends AbstractAction {
     private NodeTree tree;
     private String cmd;
     public NodeTreeAction(NodeTree tree, String cmd) {
          super(cmd);
          this.cmd = cmd;
          this.tree = tree;
     public void actionPerformed(ActionEvent e) {
          if (cmd.equals("rename")) {
               System.out.println("Ï am here");
}

I modified the NodeTree Class with the following
class NodeTree extends JTree {
     public void addActions() {
          ActionMap aMap = this.getActionMap();
          aMap.put("rename", new NodeTreeAction(this, "rename"));
          this.setActionMap(aMap);
          InputMap map = this.getInputMap(JComponent.WHEN_FOCUSED);
          map.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "rename");
          this.setInputMap(JComponent.WHEN_FOCUSED, map);
     @Override
     public void startEditingAtPath(TreePath path) {
       if(!isEditing() || stopEditing()) {
         Action.actionPerformed(new ActionEvent(this,
           ActionEvent.ACTION_PERFORMED, Action.getActionCommand()));
}I am getting an Error on Line
Action.actionPerformed(new ActionEvent(this,
*     ActionEvent.ACTION_PERFORMED, Action.getActionCommand()));*
saying, cannot make a static reference to the non-static method actionPerformed(ActionEvent) from ActionListener
Could you please help. I am totally new to this.
Hemanth

Similar Messages

  • Where is the ENTER Button on the P1606dn when I am trying to manually feed envelopes?

    I had trouble trying to print envelopes using Microsoft Word running under Windows 7, I got an HP message saying to load the paper (envelope) then hit the ENTER button.
    Hitting the enter button on my keyboard did not get the intended results. Looking at all documentation on the P1606dn printer did not find a button labeled as an ENTER button there.
    I finally discovered the proper button is the "GO" button depicted by a sheet of paper with a folded-down upper right-hand corner and an arrow pointing downward on the top of the printer.
    It would be nice is HP were to change the drivers to where the message would be consistent with the documentation of the printer.

    Thank you for your message and feedback.
    You are right. the intention is to educate customer to hit the "GO" button.
    I am an employee of HP but I only speak for myself and not for the company.

  • How to invoke the shutdown event tracker when running restart-computer

    In Windows command shell, it is possible to run shutdown /d to specify a reason code and /c to enter a comment into the shutdown event tracker to log why a shutdown was being performed.
    I'm not seeing an equivalent parameter for the restart-computer cmdlet in PowerShell.  Is it possible to invoke the shutdown event tracker when running restart-computer?

    help restart-computer 
    says no.  There's nothing wrong with using native commands, in a number of cases they are better than what PS provides.
    I hope this post has helped!

  • Function of the PLAY button versus the ENTER button

    Hello gang,
    I had a quick DVD / DVDSP related question that I've been trying to get a definitive answer for, and I've had great luck and some very helpful responses over in the Final Cut forum so I figured I'd give it a shot.
    Anyways, I'm editing some video and authoring a DVD for a group who intend to make an instructional DVD. It's divided into about five chapters and each one begins with some sort of voiceover and text/graphics. In the opening segment of the DVD, there is a voiceover that explains the way to navigate through the DVD and select chapters, etc. etc. The voiceover has already been written and recorded, but I have some concerns about the power they have designated for the "Play" button. Here is an excerpt:
    "We use the PLAY button in a couple of ways: to select and play an item that is currently highlighted in a list of items on the screen..."
    and also:
    "Almost all DVD remotes have a set of buttons that are arranged like a set of arrows (or triangles) pointing to the top, bottom, right and left of the remote control. These keys are used to move the selection pointer on menus presented on the screen. When an item is selected, it is highlighted to distinguish it from the other items in the list that are not selected. Once you have moved the selection point to the item you want, push the PLAY button to actually select and begin playback on that item."
    Now here is my concern– I was under the impression that the "Enter" button was typically used to select menu items, etc. I decided to test this on some commercial DVDs I had lying around, and it seems that the Play button does in fact work to select items. I had always assumed it was assigned just one specific role, for example playing the main title on a DVD.
    I looked it up in the DVDSP manual and this is all I found:
    "A button is selected when the viewer navigates to
    it. Only one button at a time can be in the selected state. The selected button becomes
    activated when the viewer presses the remote control’s Enter button. Depending on the
    button type, highlights or layers are used to indicate each button’s state."
    I couldn't find anything regarding the function of the Play button. I suppose my question is this: do these instructions sound okay? Are they universal? Can the Play button be used to select menu items on EVERY DVD player? I am only really stressing about this because this DVD is being targeted towards senior citizens, many of whom have extremely limited knowledge of DVD technology. I'd like to come up with the most universal, simple, and solid instructions for navigation through the DVD.
    Okay, thank you in advance. I appreciate any comments or advice you might be able to offer.
    PowerBook G4   Mac OS X (10.4.7)  

    Ah yes, Jake, but which UOP? Surely, you've seen me address this issue of there not being a Play UOP before?
    The project can be set up for Play to be Enter on a very high percentage of players, but it would be good with Christopher’s project to get the announcer to add "and Enter".
    The way it works is make sure that the "Still Off" user Op in DVD Studio Pro's Advanced Playback Controls is unchecked. DVD SP started making this default UOP denial in recent versions, which will mess up the Play remote key on a lot of players, including the Apple DVD player.
    And it would be good to take notes here Jake, since you do some Scenarist authoring. This Play remote key could bite you big time, if you're not careful (I've rescued two good authors who had trouble with what I'm about to describe; luckily, we caught it before it was submitted for replication).
    Still Off, which is what a lot of DVD player manufacturers map their play remote key if they don't directly map it to "Enter", when the DVD player is in infinite pause mode, i.e., the state a cell/program is in when displaying a still menu, causes the menu PGC to execute it's post command area (leave the PGCs still phase).
    A check of DVD SP's abstraction layer will show that navigation out of the post command area of all DVD SP's menu PGCs is determined by the current value of SPRM 8, the last selected/activated button. All of DVD SP's menu domain buttons are "LinkTail PGC" commands, so the effect of Operating Play is identical to activating a button with Enter, in the case of Still Off being the trigger.
    This can be verified by setting a button command in AfterEdit to jump somewhere directly which is different location than it was set in DVD SP. With the Still Off user op enabled, hit Play on the selected button and find that the original command in DVD SP will execute. But hit enter on the same button, and navigation will go to your test location. This is how it works on many players (you can check it out right in the Apple player).
    So it's good for spec based authors to use LinkTail PGC, which most do, on their menu button commands for still menus (in single PGCs), just in case users use Play instead of Enter in those players; or navigation can get pretty wacky! Or, if you don’t use LinkTail for the menus’ button commands, then it would be good to at least provide for code in the PGCs post command area to receive navigation in this case. But LinkTail has lots of other advantages, which is why it's used so much.
    With motion menus, Most players map the play remote key to "Enter", well, except the Apple DVD player. It turns the Play remote key to a Pause key during motion, so Christopher’s viewers would definitely be out of luck there.
    All that said, the play remote key should not be depended on as the primary for bullet-proof navigation, as you said.
    Take care,
    Trai

  • Suppress the enter-query mode when no-data-found after execute a query.

    HI,
    Greetings of the day, Can any one suggest me that how to Suppress the enter-query mode when no-data-found after execute a query on the form by a button.
    whenever i execute query on form and result is no data found then form :system.mode is still in enter-query mode.
    i want that if result is no data found then form comes back it initial state.
    i will thank full of him who will help me..
    Thanks in Advance..

    Put this in your Key-ExeQry trigger:Execute_Query;
    If Get_block_property(:System.current_block,query_hits)=0 then
      Exit_form; --this cancels the Enter-Query mode; Does not exit the form.
    End if;You may want to trap and prevent the "FRM-40353: Query cancelled" message, and change the "FRM-40301: Query caused no records to be retrieved. Re-Enter" message. To do that, you need an On-Message form-level trigger:Declare
      Msg_Code Number        := MESSAGE_CODE;
      MSG      Varchar2(150) := SUBSTR('   '||MESSAGE_TYPE||'-'
                             ||TO_CHAR(Msg_Code)||': '||MESSAGE_TEXT,1,150);
    BEGIN
      If Msg_Code=40301 then
           -- 40301: Query caused no records to be retrieved. Re-Enter
        Message('  NO RECORDS FOUND',No_acknowledge);
      Elsif Msg_Code=40353 then -- Query cancelled.
        null;
      Else
        MESSAGE(MSG,NO_ACKNOWLEDGE);
      End if;
    End;

  • Can't load any websites. I do not get any "error messages", the "enter" button has no effect in the address bar. Works fine in the FF search box and in IE.

    Entering a URL in the address bar and hitting enter does nothing. Neither the "enter" button or "address bar arrow", for going to the website, function. Website does not load and no error messages appear. "Enter" button works fine in the FF search box and in IE, so it's not my keyboard.
    Tried most of the recommended fixes under the "Error loading websites" article with the exception of "DNS refetching", as typing "about:config" in the location bar does no good as the "enter button" won't function. I've removed and re-added FF back into the windows firewall, removed ZoneAlarm from my system, edited proxy settings, deleted and reinstalled FF several times. NOTHING WORKS!!! I'm a die hard FF fan and this is KILLING me. Please HELP!!!

    You have a lot of information in packed in the "More system details..." (in the right-hand column), where it looks like you found a solution. If not take a look at "Problematic Extensions" the AVG Free installation of their "'''AVG Free Search'''" can cause such problems. Directions to fix that are specific and involve reinstalling AVG Free without the Link Scanner component.
    * http://kb.mozillazine.org/Problematic_extensions

  • Pages not loading after pressing the enter button

    when i write some adress into the navigation panel and press enter nothing happens. Pages doesn`t start to load even from the history. Only thing that works are bookmarks, they load on, and I can browse the internet from the sites. By the way, the enter button works in other programs well. Thanks for ideas

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode

  • I'm having problem with text boxes.  Whenever i hit the enter button to start a new line or paragraph, the cursor doesn't drop down to the next line.  Instead i get this little red + sign in the box.

    I'm having problem with text boxes.  Whenever i hit the enter button to start a new line or paragraph, the cursor doesn't drop down to the next line.  Instead i get this little red + sign in the box.

    You are absolutely right.  Thought Enter meant Enter.  I was wrong.  Thank you for the help.
    Rod Rogers, Broker
    Accredited Land Consultant (ALC)
    Metcalf Land Company, Inc.
    Office: 864-585-0444
    Mobile: 864-316-0297
    Fax: 864-583-6000
    <http://www.metcalfland.com> www.metcalfland.com

  • I was trying to open finder with the pinwheel spinning when I accidently hit the off button. When restarting a small image of the finder icon blinked on

    I was trying to open finder while the pinwheel was spinning & I accidentally hit the off button.  When I tried to restart I get a gray screen & after about a minute in the middle of the screen appears a half inch by half inch image of the finder icon that blinks on & off with a question mark. Thats all it does, no other functions work just the icon blinking on & off with the question mark.  Please help, I really hope I didn't destroy my mac.
    Julian

    A flashing question mark appears when you start your Mac
    Question (?) Mark, Blinking Folder, or Gray Screen at Startup
    These are related but not identical issues. Their causes are outlined in Intel-based Mac- Startup sequence and error codes, symbols. Solutions may be found in:
    A flashing question mark appears when you start your Mac
    Mac OS X- Gray screen appears during startup
    In most cases the problems may be caused by one or more of these:
    Problem with the computer's PRAM - See Resetting your Mac's PRAM and NVRAM.
    Boot drive's directory has been corrupted - Repair with Disk Utility.
    Critical system files are damaged or deleted - Reinstall OS X.
    The disk drive is physically non-functional - Replace the hard drive.
    Note that the information I have provided is what Apple recommends, If other users suggest different solutions than found here, then be sure what they recommend does not impact on your warranty, if any, or ability to get continuing Apple service.
    Please don't start removing drives or changing cables unless you know what you are doing and have exhausted other non-invasive alternatives outlined here. If you perform any work yourself that is unapproved by Apple, then you will void any warranty you may have and lose all further Apple Support.
    Repair the Hard Drive and Permissions
    Boot from your Snow Leopard Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities menu. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    The main difference if you are using Lion or Mountain Lion is that you must first boot from the Recovery HD. Simply boot from the Recovery HD to perform the above.
    Reinstall Snow Leopard Without Erasing The drive
    1. Repair the Hard Drive and Permissions
    Boot from your Snow Leopard Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities menu. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    2. Reinstall Snow Leopard
    If the drive is OK then quit DU and return to the installer.  Proceed with reinstalling OS X.  Note that the Snow Leopard installer will not erase your drive or disturb your files.  After installing a fresh copy of OS X the installer will move your Home folder, third-party applications, support items, and network preferences into the newly installed system.
    Download and install Mac OS X 10.6.8 Update Combo v1.1.
    Reinstalling Lion/Mountain Lion Without Erasing The Drive
    Boot to the Recovery HD: Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD and click on the downward pointing arrow button.
    Repair the Hard Drive and Permissions: Upon startup select Disk Utility from the main menu. Repair the Hard Drive and Permissions as follows.
    When the recovery menu appears select Disk Utility. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the main menu.
    Reinstall Lion/Mountain Lion: Select Reinstall Lion/Mountain Lion and click on the Continue button.
    Note: You will need an active Internet connection. I suggest using Ethernet if possible because it is three times faster than wireless.

  • Why doesn't the enter key respond when saving a web page?

    go to save a web page, complete and when i press the enter key it doesn't work. i have to move the mouse pointer to the save button and click it that way but it slower this way. why won't it let me just push the enter button on my keyboard to save?
    any way to fix this?

    The '''<u>S</u>ave''' button has focus in the Save As window for me, and hitting either Enter or S will work.
    But if I change the File <u>n</u>ame or select a different file Type I have to use the mouse to save it; the focus is away from the Save button.
    If it doesn't work that way for you, see how it works when using the '''Firefox SafeMode'''.
    https://support.mozilla.org/en-US/kb/troubleshoot-firefox-issues-using-safe-mode

  • I want to turn my macbook air off. the shut down button already appeared but the mouse/cursor just hang and won't work. even after pressing the enter button to shut my mac off won't work. what will i do?

    i want to turn my macbook air off. the shut down button already appeared but the mouse/cursor just hang and won't work. even after pressing the enter button to shut my mac off won't work. what will i do?

    This is not a reply. I just want to elaborate on this problem.
    My computer freezes occasionally when it is used after being sleep for a while. The spinning ball appears and everything is totally disabled. Nothing on the keyboard works.
    The mouse moves, but does not work.
    The only solution is to turn the power off and on (losing all data in open applications.)
    I kept the System monitor running on the side to find out which program was running when the computer froze. The Monitor as well as all other applications froze, but the data showed:
    Firefox 18.4%
    Activity Monitor 0.9%
    Firefox Plugin 0.2%
    This is all the information I have. By the way, I am using iMac with OS 10.6.

  • How to get the Application perform actions when exits?

    How to get the Application perform actions when user clicks on the "X" icon in the top right hand corner?
    OR
    If i placed an Exit Button.... when actions that i need to use to allow my application to perform a certain action when it exits?
    Thanks

    frame.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        // do your stuff here
    });The WindowListener and WindowEvent can be found in java.awt.event package
    //David

  • HT4847 Why is the "done" button inactive when I try to downgrade my iCloud storage plan to 5GB free? Doesn't work from iOS device or macBook system preferences. I didn't sign up for a $40 plan.

    Why is the "done" button inactive when I try to downgrade my iCloud storage plan to 5GB free? Doesn't work from iOS device or macBook system preferences. I didn't sign up for a $40 plan.

    I found the solution .,,,
    1) click on your current plan and press done your payment details will appear .
    2) the first section is your plan and there is a botton "change" click on it
    3) it will take you back to the upgrade options
    4) press on the downgrade options
    5) choose the 5 GB and the done botton will be enabled
    6) click on it  you'll back to the step number 2 , here read carefully you'll see that your changes will take effect after the current plan expired with the date.

  • TS2972 Why is the "Import" button grey when I'm trying to transfer music from one computer to another?

    Why is the "Import" button grey when I'm trying to transfer music from one computer to another using Home Sharing?

    Hi lexipuppy,
    I dont know if you have your music on your other computer was on itunes, but if it was, make sure that you signed into your itunes account on your other computer. If you are signed in then your music should show up in your library.

  • Does the Video Button Action really work?

    According to teh Adobe site, the Video button action should be functional:
    I have not been able to get it to function so far. I am truing to get the button to play a video from a Navigation point. Am I doing something wrong (likely) or is the Adobe site incorrect.

    Thanks Bob. That would be a great feature to add. I'm using DPS to create some interactive video applications and that would give me lots of new abilities.

Maybe you are looking for