[jEdit-Syntax-devel] re actions under jdk1.4
Brought to you by:
marcel-boehme,
oliverhe
|
From: Colin B. <Col...@as...> - 2002-04-10 00:49:13
|
Hi Gabriel,
I had the same problem with my project. It worked fine under JDK1.3 but
shortcuts didn't work under 1.4. To fix it I had to change the visibility of
the processKeyEvent(KeyEvent) method in my frame class from protected to
public E.G.
public void processKeyEvent(KeyEvent evt) {
super.processKeyEvent(evt);
}
And I added the following file to my project. In application startup I call
the static init method _only_ if running under 1.4. If you make the call via
reflection then by leaving the Java14.java file out of the build you can
build your project under 1.3
/*
* Java14.java - Java 2 version 1.4 API calls
*
* Copyright (C) 2001, 2002 Slava Pestov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
import java.awt.Component;
import java.awt.DefaultKeyboardFocusManager;
import java.awt.KeyboardFocusManager;
import java.awt.Window;
import java.awt.event.KeyEvent;
import javax.swing.JInternalFrame;
import net.sourceforge.squirrel_sql.client.gui.BaseSheet;
/**
* This file must be compiled with a JDK 1.4 or higher javac. If you are
using
* an older Java version and wish to compile from source, you can safely
leave
* this file out.
*
* @author Slava Pestov
*/
public class Java14 {
public static void init() {
KeyboardFocusManager.setCurrentKeyboardFocusManager(new
DefaultKeyboardFocusManager() {
public boolean postProcessKeyEvent(KeyEvent evt) {
if(!evt.isConsumed()) {
Component comp =
(Component)evt.getSource();
for(;;) {
if(comp instanceof
BaseSheet) {
((BaseSheet)comp).processKeyEvent(evt);
return true;
} else if(comp == null ||
comp instanceof Window) {
break;
} else {
comp =
comp.getParent();
}
}
}
return super.postProcessKeyEvent(evt);
}
});
}
}
This code is basically the modifications that Slava Pestov made to fix a
similar problem with his jEdit text editor. BaseSheet is my JInternalFrame
subclass that contains the jEdit text area, replace it with your own.
Col
============================
From: Gabriel Hauber <gabjon@op...>
<http://images.sourceforge.net//images/msg.gif> actions under jdk1.4
2002-03-07 16:42
Hi,
Just wondering if I'm alone in experiencing this.
I'm using JDK1.4, and I'm embedding the JEditTextArea component within a
JFrame's content pane.
I've defined toolbar/menu actions within the JFrame for things like
save/cut/copy/paste/etc. However, when typing within the text area,
none of the associated keyboard shortcuts seem to work.
I believe it worked under JDK1.3, but can't easily check now as a main
part of my application is dependent on 1.4
Anyone have any ideas?
Thanks,
Gabriel
--
----------------------------------------------------------
Gabriel J. Hauber -- Freelance Software Engineer
eXtreme Programming/UML/Java/XML/JUnit/AmigaDE/VP/VPUnit
Brisbane, Australia
http://www.gabrielhauber.com
----------------------------------------------------------
|