LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-07-2004, 10:38 AM   #1
Travis86
Member
 
Registered: Dec 2002
Location: The land of GMT -6
Distribution: OS X, PS2 Linux, Ubuntu, IRIX 6.5
Posts: 399

Rep: Reputation: 31
Trouble with Java ActionMaps


I'm trying to make a multi-line JTextField using JTextArea an an action map with Java.

Here's the important part of the code:
Code:
    input.getInputMap().put(KeyStroke.getKeyStroke("ENTER"),"submit_data");

    InputMap im = input.getInputMap(JComponent.WHEN_FOCUSED);
    im.put(KeyStroke.getKeyStroke("ENTER"), "submit_data");
    
    ActionMap am = new JTextArea().getActionMap();
    am.put("submit_data",
        new AbstractAction("submit_data") {
            public void actionPerformed(ActionEvent evt) {
	      System.out.println("Someone hit enter");
            }
        }
    );
I can tell that something is working because "ENTER" no longer creates a new line. However, it never prints "Someone hit enter." What's wrong?

Also, please excuse my typo in the title. It appears that there is no way to fix it.

Last edited by Travis86; 01-07-2004 at 10:41 AM.
 
Old 01-08-2004, 03:20 AM   #2
nephilim
Member
 
Registered: Aug 2003
Location: Belgium
Distribution: Debian (server), Kubuntu (desktop)
Posts: 248

Rep: Reputation: 30
I'm assuming 'input' is a TextArea object, is that correct?

My guess is that you didn't assign the ActionMap to input, you should have

input.setActionMap(am);

somewhere.
 
Old 01-08-2004, 07:14 PM   #3
Travis86
Member
 
Registered: Dec 2002
Location: The land of GMT -6
Distribution: OS X, PS2 Linux, Ubuntu, IRIX 6.5
Posts: 399

Original Poster
Rep: Reputation: 31
That worked!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble installing Java The Stranger SUSE / openSUSE 17 06-18-2005 10:58 AM
Having trouble with Java KezzerDrix Mandriva 12 03-30-2005 09:06 AM
Trouble with Java a2b2c2d Linux - Software 2 10-04-2004 08:58 PM
Trouble w/java raysr Linux - Newbie 7 01-10-2004 02:24 PM
Trouble with Java Plugin Gerardoj Linux - Software 6 10-10-2003 08:16 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration