1 Reply Latest reply on May 21, 2010 4:07 PM by 843807

    I have boxes instead of Farsi characters as the text of MenuItem label...

      As i started programming by jdk6, i had no problem in text components neither in awt nor in swing.
      But for labels or titles of AWT components, yes :
      I couldn't have Farsi characters displayable on AWTs just as simple as Swing by typing them into the source code.
      lets check this SSCCE :
      import javax.swing.*;
      import java.awt.*;
      import java.io.*;
      import java.util.Properties;
      public class EmptyFarsiCharsOnAWT extends JFrame{
          public EmptyFarsiCharsOnAWT() {
          public static void main(String[] args) throws AWTException, IOException {
              JFrame jFrame = new EmptyFarsiCharsOnAWT();
              MenuItem show ;
              // approach 1 = HardCoding :
              show = new MenuItem("\u0646\u0645\u0627\u06cc\u0634 \u0645\u062a\u0627");
              // approach 2 = using simple utf-8 saved text file :
                  BufferedReader in = new BufferedReader(new FileReader("farsiLabels.txt"));
                  String showLabel = in.readLine();
                  show = new MenuItem(showLabel);
               // approach 3 = using properties file :
              FileReader in = new FileReader("farsiLabels.properties");
              Properties farsiLabels = new Properties();
              show = new MenuItem(farsiLabels.getProperty("tray.show"));
              PopupMenu popUp = new PopupMenu();
                  // creating Tray object
                  Image iconIamge = Toolkit.getDefaultToolkit().getImage("greenIcon.png");
                  TrayIcon trayIcon = new TrayIcon(iconIamge, null, popUp);
                  SystemTray tray = SystemTray.getSystemTray();
      Yes, i know each of three approaches in source code does right when you may test it from IDE , but if you make a JAR contains just this class (and its resources) by means of NetBeans > project > clean&build ,you won't see the expected characters and will just get EMPTY/BLANK SQUARES !
      Unfortunately, opposed to other situations i encountered before, here there is no way to avoid using awt and make use of Swing in this case.
      And this was just an SSCCE i made to show the problem and my recent (also first ) application suffers from this subject.

      Unfortunately it seems i can not attach anything to my post!
      the content of text file is just this one line:
      نمایش متا
      The contents of Properties file is this :
       #Sun May 02 09:45:10 IRDT 2010   
      tray.show=نمایش متا
      for instance.
      the icon image i don't think will differ to the issue.

      i am using latest version of Netbeans IDE.

      Thank you very much in advance.