Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #5196

Passing KeyEvent upward

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
From Adam Beneschan <adam@irvine.com>
Newsgroups comp.lang.java.gui
Subject Passing KeyEvent upward
Date Sun, 22 Jul 2012 16:09:55 -0700 (PDT)
Organization http://groups.google.com
Lines 26
Message-ID <0f05834e-c654-4925-b78a-b8328b23ba0b@googlegroups.com> (permalink)
NNTP-Posting-Host 68.4.246.214
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-Trace posting.google.com 1342998595 5016 127.0.0.1 (22 Jul 2012 23:09:55 GMT)
X-Complaints-To groups-abuse@google.com
NNTP-Posting-Date Sun, 22 Jul 2012 23:09:55 +0000 (UTC)
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=68.4.246.214; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ
User-Agent G2/1.0
X-Received-Bytes 2186
Xref csiph.com comp.lang.java.gui:5196

Show key headers only | View raw


Hi,

I'm trying to learn how to program in Java and use some of the GUI features.  Here's something I'm trying to do but haven't succeeded at yet.

I have a text window (JTextPane) object, and I want to set things up so that when a certain something happens, a popup menu (JPopupMenu) will come up.  But I'd like it so that if the user presses a key, the key is handled just as if the menu hadn't come up--that is, the key-press event will be handled by the JTextPane (or is it the associated document?) as if the user had typed that key into the document.  I've already set up a MenuKeyListener for the popup menu that recognizes the KeyEvent and calls menu.setVisible(false) to get rid of the menu.  So far, so good.  But I don't know how to get the KeyEvent propagated to the text window.  I've tried getKeyListeners() on the JTextPane and then calling the keyTyped explicitly on each listener.  No good--the only listener it found was one I had added myself for debugging.  I also tried textPane.getInputContext().dispatchEvent(e) on the KeyEvent; that didn't do what I wanted either (seemed to have no effect).

Any thoughts?  I haven't found anything else to try.

Thanks,

                           -- Adam

Back to comp.lang.java.gui | Previous | NextNext in thread | Find similar


Thread

Passing KeyEvent upward Adam Beneschan <adam@irvine.com> - 2012-07-22 16:09 -0700
  Re: Passing KeyEvent upward markspace <-@.> - 2012-07-22 17:26 -0700
    Re: Passing KeyEvent upward markspace <-@.> - 2012-07-22 17:39 -0700
    Re: Passing KeyEvent upward Adam Beneschan <adam@irvine.com> - 2012-07-23 21:15 -0700
      Re: Passing KeyEvent upward markspace <-@.> - 2012-07-23 23:08 -0700
  Re: Passing KeyEvent upward "John B. Matthews" <nospam@nospam.invalid> - 2012-07-22 21:32 -0400
  Re: Passing KeyEvent upward Roedy Green <see_website@mindprod.com.invalid> - 2012-07-23 23:46 -0700
  Re: Passing KeyEvent upward Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2012-07-24 13:15 -0700
    Re: Passing KeyEvent upward Adam Beneschan <adam@irvine.com> - 2012-07-24 21:08 -0700
      Re: Passing KeyEvent upward markspace <-@.> - 2012-07-24 22:50 -0700
  Re: Passing KeyEvent upward Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2012-07-25 00:32 +0200

csiph-web