Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Java Spelling Framework bugs



On 8/20/02 3:17 PM, "email@hidden" <email@hidden>
wrote:

> |My software has a whole lot of JTextAreas, each one gets its own
> |JTextComponentDriver. I tried calling startRealtimeChecking on each one (in
> |response to a menu event), and the following things happened:
> |
> |1> All the JTextAreas started showing a blinking caret, not just the focused
> |one.
> |
> |2> If I try to delete a misspelled word from the end of a sentence, I start
> |throwing BadLocationExceptions.
>
> One of the basic rules of debugging applies: any given bug is far more likely
> to be in your code than in the library. (Not "must be", but definitely "far
> more likely to be".) Can you create a *simple* program that demonstrates the

I have some code at the end of this reply that exhibits this behavior. I'll
file a bug on apple's bugreporter. It just seems odd that such simple stuff
would be so weird. I feel like I'm missing something fundamental here.


> |On a related note, are there any GPL or other free pure-java spell checker
> |tools?
>
> You might check over at the SourceForge site (www.sourceforge.net).

Thanks for the tip. It turns out that the Jazzy project has something
useable (although not with realtime spellchecking).

Begin code:

import java.awt.*;
import java.lang.reflect.Method;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import com.apple.mrj.*;

public class SpellTest extends JFrame
{

private JTextArea one,two;
private Object spellOne, spellTwo;
private boolean realTimeChecking = false;

public SpellTest() {
try {
one = new JTextArea(10,40);
two = new JTextArea(10,40);
Class driverClass =
java.lang.Class.forName("com.apple.spell.ui.JTextComponentDriver");
spellOne = driverClass.newInstance();
spellTwo = driverClass.newInstance();
JButton toggleButton = new JButton("Toggle Realtime");
toggleButton.addActionListener(new ActionListener() {
public void
actionPerformed(ActionEvent ae) {
toggleRealtimeSpellcheck();
}
});
JPanel jp = new JPanel();
one.setBorder(BorderFactory.createLineBorder(Color.black));
two.setBorder(BorderFactory.createLineBorder(Color.red));
jp.add(one);
jp.add(two);
jp.add(toggleButton);
setContentPane(jp);
pack();
setVisible(true);
toggleRealtimeSpellcheck();
} catch (Throwable t) {
t.printStackTrace();
}
}


public void
setRealtimeSpellcheck(boolean c) {
if (c) {
System.err.println("turning on!");
try {
Class driverClass =
java.lang.Class.forName("com.apple.spell.ui.JTextComponentDriver");
Method checkMethod =
driverClass.getMethod("startRealtimeChecking",new
Class[]{javax.swing.text.JTextComponent.class});
checkMethod.invoke(spellOne, new Object[]{one});
checkMethod.invoke(spellTwo, new Object[]{two});
} catch (Throwable t) {
t.printStackTrace();
}
} else {
System.err.println("turning off!");
try {
Class driverClass =
java.lang.Class.forName("com.apple.spell.ui.JTextComponentDriver");
Method checkMethod =
driverClass.getMethod("stopRealtimeChecking",null);
checkMethod.invoke(spellOne, null);
checkMethod.invoke(spellTwo, null);
} catch (Throwable t) {
t.printStackTrace();
}
}
realTimeChecking = c;
}

public void
toggleRealtimeSpellcheck() {
setRealtimeSpellcheck(realTimeChecking ^ true);
}


public static void main(String args[]) {
new SpellTest();
}

}
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Java Spelling Framework bugs (From: email@hidden)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.