Do the mnemonics work? And the key presses? This is my Exception. The joys
of writing once and testing everywhere... I'm running on WINNT v4.0 build
1381-service pack 4, JVM 1.3.0-C.
Exception occurred during event dispatching:
java.lang.NullPointerException: null pData
at sun.awt.windows.WInputMethod.handleNativeIMEEvent(Native Method)
at sun.awt.windows.WInputMethod.dispatchEvent(WInputMethod.java:275)
at sun.awt.im.InputContext.dispatchEvent(InputContext.java:202)
at
sun.awt.im.InputMethodContext.dispatchEvent(InputMethodContext.java:1
77)
at java.awt.Component.dispatchEventImpl(Component.java:2529)
at java.awt.Container.dispatchEventImpl(Container.java:1213)
at java.awt.Component.dispatchEvent(Component.java:2499)
at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451
)
at
java.awt.LightweightDispatcher.trackMouseEnterExit(Container.java:231
8)
at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:2189)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
at java.awt.Container.dispatchEventImpl(Container.java:1200)
at java.awt.Window.dispatchEventImpl(Window.java:912)
at java.awt.Component.dispatchEvent(Component.java:2499)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
at
java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:10
3)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)
-----Original Message-----
From: Colin Vipurs [mailto:[EMAIL PROTECTED]]
Sent: 23 February 2001 09:11
To: Neil Thorne
Cc: '[EMAIL PROTECTED]'
Subject: Re: Problems with JPopupMenu
What Exception is getting thrown? This works fine for me on a Mandrake 7
Linux box running Java 1.3
> Hi there. I'm trying to get this simple test program working, which pops
up
> a menu, when you press the windows key (if you don't have the windows key,
> then change the keyReleased check to a different keycode say, VK_A) in the
> textfield. The problem is I get an Exception thrown, and key navigation
does
> not work at all. Is this just buggy swing? Any workarounds?
> thanks very much for your help.
>
> /*
> * ToyFrame.java
> *
> * Created on 22 February 2001, 23:07
> */
>
> package test.core.components.gui.document;
>
> import java.awt.*;
> import javax.swing.*;
>
> /**
> *
> * @author Administrator
> * @version
> */
> public class ToyFrame extends javax.swing.JFrame {
>
> /** Creates new form ToyFrame */
> public ToyFrame() {
> initComponents ();
> pack ();
> }
>
> /** This method is called from within the constructor to
> * initialize the form.
> * WARNING: Do NOT modify this code. The content of this method is
> * always regenerated by the FormEditor.
> */
> private void initComponents ()
> {
> jPopupMenu1 = new javax.swing.JPopupMenu ();
> jMenuItem1 = new javax.swing.JMenuItem ();
> jMenuItem2 = new javax.swing.JMenuItem ();
> jMenuBar1 = new javax.swing.JMenuBar ();
> jMenu1 = new javax.swing.JMenu ();
> jMenuItem3 = new javax.swing.JMenuItem ();
> jMenuItem4 = new javax.swing.JMenuItem ();
> jMenu2 = new javax.swing.JMenu ();
> jMenuItem5 = new javax.swing.JMenuItem ();
> jTextField1 = new javax.swing.JTextField ();
>
> jMenuItem1.setMnemonic ('1');
> jMenuItem1.setText ("Item 1");
>
> jPopupMenu1.add (jMenuItem1);
> jMenuItem2.setMnemonic ('2');
> jMenuItem2.setText ("Item 2");
>
> jPopupMenu1.add (jMenuItem2);
>
> jMenu1.setMnemonic ('F');
> jMenu1.setText ("File");
>
> jMenuItem3.setMnemonic ('O');
> jMenuItem3.setText ("Open");
>
> jMenu1.add (jMenuItem3);
> jMenuItem4.setMnemonic ('C');
> jMenuItem4.setText ("Close");
>
> jMenu1.add (jMenuItem4);
> jMenuBar1.add (jMenu1);
> jMenu2.setMnemonic ('E');
> jMenu2.setText ("Edit");
>
> jMenuItem5.setMnemonic ('C');
> jMenuItem5.setText ("Cut");
>
> jMenu2.add (jMenuItem5);
> jMenuBar1.add (jMenu2);
> addWindowListener (new java.awt.event.WindowAdapter ()
> {
> public void windowClosing (java.awt.event.WindowEvent evt)
> {
> exitForm (evt);
> }
> }
> );
>
> jTextField1.setText ("jTextField1");
> jTextField1.addKeyListener (new java.awt.event.KeyAdapter ()
> {
> public void keyReleased (java.awt.event.KeyEvent evt)
> {
> jTextField1KeyReleased (evt);
> }
> }
> );
>
>
> getContentPane ().add (jTextField1, java.awt.BorderLayout.CENTER);
>
> setJMenuBar (jMenuBar1);
>
> }
>
> private void jTextField1KeyReleased (java.awt.event.KeyEvent evt) {
> if ( evt.getKeyCode() == 0 )
> {
> Component comp = (Component)evt.getSource();
> jPopupMenu1.show(comp, comp.getX() + comp.getHeight() / 2,
comp.getY()
> + comp.getHeight() / 2);
> jPopupMenu1.setRequestFocusEnabled(true);
> jPopupMenu1.requestFocus();
>
> }
> }
>
> /** Exit the Application */
> private void exitForm(java.awt.event.WindowEvent evt) {
> System.exit (0);
> }
>
> /**
> * @param args the command line arguments
> */
> public static void main (String args[]) {
> new ToyFrame ().show ();
> }
>
>
> // Variables declaration - do not modify
> private javax.swing.JPopupMenu jPopupMenu1;
> private javax.swing.JMenuItem jMenuItem1;
> private javax.swing.JMenuItem jMenuItem2;
> private javax.swing.JMenuBar jMenuBar1;
> private javax.swing.JMenu jMenu1;
> private javax.swing.JMenuItem jMenuItem3;
> private javax.swing.JMenuItem jMenuItem4;
> private javax.swing.JMenu jMenu2;
> private javax.swing.JMenuItem jMenuItem5;
> private javax.swing.JTextField jTextField1;
> // End of variables declaration
>
> }
>
>
>
>
> Neil Thorne
> Java Developer
> Kinetech Europe
> 0207 200 7856
>
>
>
>
> **********************************************************************
> This email is intended only for the addressee. This email
> and any files transmitted with it may contain confidential
> or privileged information. If you are not the named
> addressee or the person responsible for delivering the
> message to the named addressee, please contact
> [EMAIL PROTECTED]
>
> This email has been scanned by MAILsweeper.
> **********************************************************************
> _______________________________________________
> Advanced-swing mailing list
> [EMAIL PROTECTED]
> http://eos.dk/mailman/listinfo/advanced-swing
>
----
Colin Vipurs
R&D, 'PA' Listings, Howden
(01430) 455 582
'Do you wanna go faster baby?'
**********************************************************************
This email is intended only for the addressee. This email
and any files transmitted with it may contain confidential
or privileged information. If you are not the named
addressee or the person responsible for delivering the
message to the named addressee, please contact
[EMAIL PROTECTED]
This email has been scanned by MAILsweeper.
**********************************************************************
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing