Yes, I think it’s a focus issue. I have tested putting a JGoView in a java.awt.Frame in a Swing application and it is working correctly for me (see code below). If for some reason the JGoView doesn’t get the keyboard events, there’s nothing JGo can do.
package awtframe;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.nwoods.jgo.*;
public class Frame1 extends Frame {
JPanel contentPane;
BorderLayout borderLayout1 = new BorderLayout();
JGoView jGoView1 = new JGoView();
//Construct the frame
public Frame1() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
JGoBasicNode n = new JGoBasicNode("test");
n.setLocation(100, 100);
this.jGoView1.getDocument().add(n);
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
this.setLayout(borderLayout1);
this.add(jGoView1, BorderLayout.CENTER);
this.setSize(new Dimension(485, 376));
this.setTitle("Frame Title");
jGoView1.addKeyListener(new Frame1_jGoView1_keyAdapter(this));
}
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
void jGoView1_keyPressed(KeyEvent e) {
switch (e.getKeyCode()) {
case KeyEvent.VK_DELETE:
jGoView1.deleteSelection();
break;
}
}
}
class Frame1_jGoView1_keyAdapter extends java.awt.event.KeyAdapter {
Frame1 adaptee;
Frame1_jGoView1_keyAdapter(Frame1 adaptee) {
this.adaptee = adaptee;
}
public void keyPressed(KeyEvent e) {
adaptee.jGoView1_keyPressed(e);
}
}