Is there a way to make scandinavic letters behave correctly in AWT
components with Steve Byrne's Linux JDK 1.1.6-glibc? I have noticed that
in a TextArea, whenever a call to TextArea.append() is done with a String
containing scandinavic letters, it causes the append method to simply
quit, leaving the String chopped. The last character of the String that
gets appended is the one before the scandinavic evil letter. Not even the
newline at the end of my String gets anywhere.
Stranger still, if the code happens to be in the constructor of my Frame
subclass, which creates a TextArea and places it within itself, the entire
constructor function quietly quits! I was quite puzzled why my for loop
that iterates a list of 100 items to print quitted at the fifth line.
Inputting scandinavic letters doesn't work, either. There is no reaction
when pressing such a key.
However it happily reads them from files and they get printed just nicely
with System.out.println(), so I'm pretty sure it's the AWT part where the
problem is.
Then I found out that there is another JDK 1.1.6 port for Glibc linux, by
Sergey Nikitin. I got the rpm file from redhat contrib, and it seems to
work just fine and gracefully as far as scandinavic letters are concerned,
so I am using it happily now. But this left me wondering, if there's a bug
in Byrne's JDK port, my system configuration, or something else? And if
it's a bug in the JDK port, is it known? Fiddling with the LANG, LC_CTYPE
etc. variables at least didn't seem to affect anything at all.
Here's my system:
Red Hat 5.0
Glibc 2.0.7-13 from their upgrade rpm
jdk1.1.6-v1-glibc
XFree86-VGA16-3.3.2-1
XFree86-libs-3.3.2-1
XFree86-75dpi-fonts-3.3.2-1
XFree86-SVGA-3.3.2-1
XFree86-XF86Setup-3.3.2-3
XFree86-100dpi-fonts-3.3.2-1
XFree86-3.3.2-1
XFree86-devel-3.3.2-1
Linux 2.1.105
Tried with and without TYA 0.6 and 0.7. (It's excellent, never caused
me a single problem and increases the speed of my application 7-fold!)
I'll happily to send the whole source code to my program where I'm
experiencing the problem (500+ lines) to anyone who asks, but I didn't
feel like putting it out for everyone yet because I'm touchy about
revealing to the world how bad my coding skills are. But here's a much
simplified piece of code that should do it:
ScanTest.java:
import java.net.*;
import java.io.*;
public class ScandTest {
public static void main(String[] args) {
TestWindow window=new TestWindow();
window.setSize(320,150);
window.show();
window.addMessage("This character -->x<-- ought to be a
scandinavic letter.\n");
// of course the x in the middle of there is really a scandinavic letter,
// but I didn't put it in this e-mail message because someone's mail
// system is going to die a horrible death or something if I do, I'm sure
}
}
TestWindow.java:
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class TestWindow extends Frame {
TextArea textarea;
TestWindow() {
super("test");
addWindowListener(new TestWindowListener());
setLayout(new BorderLayout());
textarea=new TextArea("",80,25);
textarea.setEditable(false);
Font fontti=new Font("Helvetica",Font.PLAIN,10);
// tried System and Times, too
textarea.setFont(fontti);
add(textarea);
}
void addMessage(String message) {
textarea.append(message);
textarea.setCaretPosition(textarea.getText().length());
}
class TestWindowListener extends WindowAdapter {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
}
}
I hope I didn't forget to mention anything important.