Hi folks,
On a similar vein to the above poster, I am also having a problem with encodings. The below program demonstrates what I'd like to see:
Code:
import java.awt.Image;
import java.io.IOException;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import org.springframework.core.io.ClassPathResource;
import org.springframework.richclient.application.support.DefaultApplicationServices;
import org.springframework.richclient.factory.ComponentFactory;
import org.springframework.richclient.image.AwtImageResource;
import org.springframework.richclient.image.DefaultIconSource;
import org.springframework.richclient.image.ImageSource;
import org.springframework.richclient.test.SpringRichTestCase;
public class TestFonts extends SpringRichTestCase {
private static final byte[] bytes = new byte[] { (byte)0x2F, (byte)0x2F, (byte)0xBB, (byte)0xEF, (byte)0xBC, (byte)0xBA, (byte)0xB8, (byte)0xCA };
public static void main(String[] args) throws Exception {
String content = new String(bytes, "EUC-KR");
JTextArea ta = new JTextArea();
ta.setText(content);
JFrame frame = new JFrame("Test");
frame.getContentPane().add(ta);
frame.setBounds(300, 300, 200, 100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
protected void registerAdditionalServices(
DefaultApplicationServices defaultapplicationservices) {
try {
ImageSource imageSource = new ImageSource() {
AwtImageResource brokenImageIndicatorResource = new AwtImageResource(
new ClassPathResource("images/alert/error_obj.gif"));
Image brokenImageIndicator = brokenImageIndicatorResource
.getImage();
public Image getImage(String key) {
return brokenImageIndicator;
}
public AwtImageResource getImageResource(String key) {
return brokenImageIndicatorResource;
}
};
defaultapplicationservices.setImageSource(imageSource);
defaultapplicationservices.setIconSource(new DefaultIconSource(
imageSource));
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
public void testFonts() throws Exception {
DefaultApplicationServices das = getApplicationServices();
ComponentFactory cf = (ComponentFactory) das.getService(ComponentFactory.class);
JTextArea ta = cf.createTextArea(5, 5);
String content = new String(bytes, "EUC-KR");
ta.setText(content);
JFrame frame = new JFrame("Spring Test");
frame.getContentPane().add(ta);
frame.setBounds(300, 300, 200, 100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
Thread.sleep(10000);
}
}
This shows (on MY machine, anyway), the expected 4 Korean characters, both running as an app, as well as using JUnit.
However, when I try to show them within a Form constructed within my app, I get the blocks. I have no idea how to debug this, and identify what in my configuration is causing this. Could it be a default font issue, perhaps?
Rogan