AWT PopupMenu not showing Chinese Characters

Hi all.
I have a mostly Swing application that must display English and Chinese characters. Changing the Swing components has been easy, however I am having problems changing an AWT PopupMenu that i use in combination with the new TrayIcon features of Java 6. TrayIcon requires an awt PopupMenu, so i cannot use a Swing JPopupMenu even if i wanted to.
The problem is that instead of the correct words i am getting just empty squares, which seem to indicate a problem. I have tried setting the font to "SimSun" but this made no difference.
I also tried this hack to use a JPopupMenu with Trayicon
http://weblogs.java.net/blog/ixmal/archive/2006/05/using_jpopupmen.html
This correctly showed the Chinese characters but it threw up lots of 'class cast' exceptions.
My ideal solution would be to fix the problems with PopupMenu as apposed to fixing the class cast exception errors with the JPopMenu hack.
Would anyone know why i cannot display Chinese characters in a AWT PopupMenu? have i missed something?
Thanks
Steven

hi!
check this out
package com.ani;
import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Label;
import java.awt.Panel;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JLabel;
public class showHindi extends Panel
     public showHindi()
          setLayout(new BorderLayout());
          String unicodeText = "\u0928\u092e\u0938\u094D\u0924\u0947";
          Font fn = new Font("Arial Unicode MS", Font.PLAIN, 32);
          Label lblText = new Label(unicodeText) {
               @Override
               public void paint(Graphics g)
                    //super.paint(g);
                    g.clearRect(0, 0, getWidth(), getHeight());
                    String str = getText();
                    g.drawChars(str.toCharArray(), 0, str.length(), 0, 30);
                    //System.out.println(getText());
          lblText.setFont(fn);
          JLabel lblText1 = new JLabel(unicodeText);
          lblText1.setFont(fn);
          add(lblText, BorderLayout.NORTH);
          add(lblText1, BorderLayout.SOUTH);
     public static void main(String[] args)
          Frame frm = new Frame("Test Hindi");
          frm.add(new showHindi());
          frm.setSize(600, 400);
          frm.addWindowListener(new WindowAdapter() {
               @Override
               public void windowClosing(WindowEvent e)
                    System.exit(0);
          frm.setVisible(true);
}this is working in my machine. i have used JLabel and Label both to just show you the difference. there is a flickering bug because of rendering, i hope you can manage that.
regards
Aniruddha

Similar Messages

  • Itunes can not show chinese characters.

    My Itunes can not show chinese characters, they are all blocks, while I can re-type in the chinese name of the song in Itunes, then it works.
    The same as Japanese, some time it can show Jap, while sometime can not. How can I solve this problem. My computer is Mac system

    Do you have such problem only with Chinese characters?

  • Not all chinese characters display correctly with non-embedded text

    Hi all,
      I've updated to the last beta 2 of Flash Player 10.1 (10,1,51,66) and compiled this simple Flex application to illustrate the fact that not all chinese characters can be displayed correctly with non-embedded text (device font).
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/halo"
                   minWidth="1024" minHeight="768"
                   creationComplete="resourceManager.localeChain = ['zh_CN'];"
                   layout="{new VerticalLayout()}">           
        <fx:Script>
            <![CDATA[
                import spark.layouts.VerticalLayout;
            ]]>
        </fx:Script>
        <s:Label text="伜-伞伟传伡伢伣伤伥伦伧伨伩伪伫伬伭-伝">
        </s:Label>
        <mx:Label text="伜-伞伟传伡伢伣伤伥伦伧伨伩伪伫伬伭-伝"/>       
    </s:Application>
      Notice that characters from the Unicode range 0x4F1E .. 0x4А2D are not displayed within <s:Label> component that uses Flash Text Engine (FTE) by default to display the text, but at the same time those characters display just fine within older <mx:Label> component that relies on flash.text.TextField instance to render the text.

        OK, did not know that "Arial Unicode MS" font is only distributed with Microsoft Office, was looking into relying on this font in case if "simsun.ttc" font is not available at the user's system, by using the following:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   minWidth="1024" minHeight="768"
                   creationComplete="resourceManager.localeChain = ['zh_CN']"
                   layout="{new VerticalLayout()}">               
        <fx:Style>
            @namespace s "library://ns.adobe.com/flex/spark";
            @namespace mx "library://ns.adobe.com/flex/halo";
            s|Label {
                fontFamily: "Arial Unicode MS, SimSun, Arial";            
        </fx:Style>   
        <fx:Script>
            <![CDATA[
                import spark.layouts.VerticalLayout;
            ]]>
        </fx:Script>
        <s:Label id="sparkLabel" text="伜-伞伟传伡伢伣伤伥伦伧伨伩伪伫伬伭-伝"/>   
    </s:Application>  
    Tough decision ahead, but accordingly to  the survey at codestyle.org (2000 participants from 2007 year and onwards), Arial Unicode MS is present at 62.53%% system surveyed.
    ps
       My current install of Windows XP already includes the install of Microsoft Office 2007 and I've also enabled/disabled the support of East Asian languages, thus the content of  my "fonts" folder differs now significantly from "clean" Windows XP install version.
    Nevertheless I found the page with comprehensive lists of standard fonts installed with different releases of Windows that looks viable here:  http://www.kayskreations.net/fonts/fonttb.html

  • When calling report in forms, only html format can show chinese characters

    To all experts,
    When I run report by calling run_report_object() in forms, only html format can show chinese characters. If I choose pdf format, garbage characters were shown instead of chinese characters. My settings on server are as follows:
    NLS_LANG=TRADITIONAL CHINESE_HONG KONG.UTF8
    FORMS60_REPFORMAT=PDF
    Do you know why? I hope to print report in PDF format as PDF turned out to be more regular in format. Is there any additional settings required?
    May experts here broaden my mind?
    Richard

    Assuming that you are using version 6i, try using Oracle9i Reports it has support for multi-byte in PDF.
    By the way, Reports questions will get better response if you send them on the reports forum.

  • When calling report from forms, only html format report can show chinese characters

    To all experts,
    When I run report by calling run_report_object() in forms, only html format can show chinese characters. If I choose pdf format, garbage characters were shown instead of chinese characters. My settings on server are as follows:
    NLS_LANG=TRADITIONAL CHINESE_HONG KONG.UTF8
    FORMS60_REPFORMAT=PDF
    Do you know why? I hope to print report in PDF format as PDF turned out to be more regular in format. Is there any additional settings required?
    May experts here broaden my mind?
    Richard

    You have two different ways of generating Japanese PDF files from Reoprts. One is font aliasing and the other is font subsetting.
    <font aliasing>
    You will need to have the following entries in uiprint.txt (example).
    [ PDF ]
    .....JA16SJIS = "KozMinPro-Regular-Acro"
    "MS UI Gothic".....JA16SJIS = "KozMinPro-Regular-Acro"
    You may need to download and install Japanese Font Pack from Adobe's web site (if your Acrobat is non-Japanese version).
    <font subsetting>
    You will need to add C:\WINNT\Fonts (or wherever your TTF/TTC fonts are installed) to your REPORTS_PATH.
    You will also need to have the following entries in uiprint.txt (example).
    [ PDF:Subset ]
    "Andale Duospace WT J" = "Aduoj.ttf"
    "Albany WT J"="AlbanWTJ.ttf"
    "MS UI Gothic" = "msgothic.ttc"

  • UWL Nocifaction can not show chinese code

    Hi experts:
         My project is using UWL nocifaction to show SAP mail and read it.Now i am using SomProviderConnector .The email can display in work item, but when click "Show Detail" button ,the content can not display chinese character,  All the  chinese characters display "?".
        Can you tell me How can i resolve it?
                                    Thank you!
                                                                                yours.

    Hi,
    Check this [Link1|Re: Work item title translation in German; & [Link2|Re: How to Translate the Text;.
    Regards,
    Surjith

  • Safari doesn't show Chinese characters in a specific site?

    Hi all,
    I've just found a weird thing that Safari doesn't show Chinese character in this site.
    http://blog.bcxstudio.net/
    It works in Firefox (Mac and win), Chrome (mac and win), IE 6-9, Safari for Mac, but not Safari on Windows.
    However, when I browse other websites like Yahoo hong kong and Apple HK. There is no problem.
    http://hk.news.yahoo.com
    http://www.apple.com/hk
    My best guess is that the site may uses some fonts (CSS3 @font-face?) that safari did not support.
    Anyone knows what happened?
    I am on Windows 7, Safari for Windows 5.0.2 (7533.18.5)
    Thank you!

    That's a bit odd ... I'm getting the opposite effect at the moment on my XP SP3. I'm not seeing the text in IE 8 (I don't think I've got the International character sets installed for my XP Pro), but they show fine in my Safari 5.0.2.
    Are you still seeing the effect at your end at the moment, b?

  • ExternalInterface not returning chinese characters

    I've got a Flex application embedded in a PDF.  Also in that PDF is a field (hidden text field) called Data containing XML that happens to contain chinese characters.  The encoding for the XML data is UTF-16. To retrieve the data, I make a JS call (getData) using ExternalInterface.  The JS is simple:
    function getData()
      var data = this.getField('Data').value;
      return data;
    I also inserted before the return an alert to display the data.  The chinese characters were present and displaying as expected:
    In my flex application I make the following call:
    var resultXML:XML = XML(ExternalInterface.call("getData"));
    However, the resulting XML appears to not be read as UTF-16, and the characters displayed look like:
    Is there something special I have to do to get the chinese characters correctly passed through from the ExternalInterface call?

        OK, did not know that "Arial Unicode MS" font is only distributed with Microsoft Office, was looking into relying on this font in case if "simsun.ttc" font is not available at the user's system, by using the following:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   minWidth="1024" minHeight="768"
                   creationComplete="resourceManager.localeChain = ['zh_CN']"
                   layout="{new VerticalLayout()}">               
        <fx:Style>
            @namespace s "library://ns.adobe.com/flex/spark";
            @namespace mx "library://ns.adobe.com/flex/halo";
            s|Label {
                fontFamily: "Arial Unicode MS, SimSun, Arial";            
        </fx:Style>   
        <fx:Script>
            <![CDATA[
                import spark.layouts.VerticalLayout;
            ]]>
        </fx:Script>
        <s:Label id="sparkLabel" text="伜-伞伟传伡伢伣伤伥伦伧伨伩伪伫伬伭-伝"/>   
    </s:Application>  
    Tough decision ahead, but accordingly to  the survey at codestyle.org (2000 participants from 2007 year and onwards), Arial Unicode MS is present at 62.53%% system surveyed.
    ps
       My current install of Windows XP already includes the install of Microsoft Office 2007 and I've also enabled/disabled the support of East Asian languages, thus the content of  my "fonts" folder differs now significantly from "clean" Windows XP install version.
    Nevertheless I found the page with comprehensive lists of standard fonts installed with different releases of Windows that looks viable here:  http://www.kayskreations.net/fonts/fonttb.html

  • cfdocument not showing Chinese character

    We have a system that uses a mixture of English and
    Simplified Chinese on almost every page. After properly installing
    the Simplified Chinese fonts (gb2312) on all of the users
    PC’s via the Regional and Language setting, the pages display
    both languages properly.
    We have just started using the <cfdocument> to create
    PDF documents. We were eager to convert to <cfdocument> in
    order to be able to use CSS and to be able to display the Chinese
    characters in the PDF document as they are displayed in the HTML.
    We tried it first on a CF MX 7 test bed. Once we created the
    cffont.properties.cn in the cf_root/Lib directory, it worked like a
    champ.
    In order get this feature into production, we moved the .cfm
    files and the cffont.properties files from out CF 7 test bed to our
    CF8 development system. No matter what we do, all we see in the PDF
    file where the Chinese characters should be are “?”.
    We can’t find any information on anything else that we
    need to do to make the Chinese characters appear besides creating
    the cffont.properties files in the cf_root/Lib directory as we did
    in CF 7. Using the CF Administrator’s Font Manager, I can see
    that the required Simplified Chinese fonts (NSimSun, SimSun &
    Simhei) are installed on the server. The bare bones code seems
    simple enough:
    <cfdocument format=“pdf”
    fontembed=”selective”>
    Page text…
    </cfdocument.
    If you have done this, or know what we need to do to port
    form CF7 to CF8, I would appreciate your sharing.
    Thank you in advance for your help.
    Len

    I see what you are saying about utf-8. I put in a
    cfprocessingdirective tag in order to use utf-8 encoding, but it
    makes no apparent difference. I also tried using other canonical
    values (MS936, x-mswin-936, etc.) for Simplified Chinese that I
    found in a Java spec on the Sun website – still not
    difference. Well that’s not strictly true: when I used Cp935,
    it turned everything to Chinese characters.
    After working with the utr-8 and doing some other analysis we
    discovered the questions marks in the code were not being cause by
    unprintable characters, but they we actually in the data. OOOOPs.
    This is a whole new ballgame. At first we though that the
    servers running CF8 must be missing some font that was needed on
    the server side. We brought over all of the fonts that seemed to be
    associated with Simplified Chinese, but that didn’t make any
    difference. I one final act of desperation, we changed the format
    on the cfdocument from PDF to SWF. All of the Chinese characters
    appeared in the SWF output file. All of the Chinese characters also
    appear in the HTML output that is generated at the same time that
    the PDF/SWF files are created. I call the code that creates the
    actual report twice from within a shell: once inside the cfdoument
    with a file name to create a separate file, and once that is not
    within it to create a HTML presentaion.
    The same code, when run on a CF7 server, produces a PDF
    output with all of the Chinese characters. One last thing, we are
    using CF8 on two different servers: one running W2KS and the other
    with W2003S.
    The only thing I can conclude from all of this is that there
    is either something wrong with the CF8 setup on both servers, or
    there is something wrong with CF8 itself.
    I'm also in the middle of a severe Verity problem that I'm
    working on with Adobe. The K2Server.exe process will crash (process
    grows from about 15k to over 700,000k) after doing some number of
    Verity collection creations or in the indexing. I've sent them code
    that will create this problem time after time. They are still
    scratching their collective heads over this one. I see it as a
    classic case of memory leakage. They haven't agreed with me yet.
    Having said all that, it seems entirely possible that there is some
    undiscovered problem with cfdocument and PDF file creation using
    CF8 as well.
    Len

  • Pls help.JSP: I could not store Chinese characters into files.

    Hi experts,
    I have this problem of cant store chinese characters into files(eg. .txt and .properties). I am adding
    these chinese text through a JSP website form....After i key in chinese characters in the textboxes
    in the website and sumbit the results, my chinese characters turned into ASCII or rather garbage in
    the files.
    Is there any way i can get the exact chinese characters i entered in the webite into the files?
    Need urgent assistance here.
    Thanks
    <%@ page contentType="text/html; charset=big5" %>
    <html>
    <head>
    <title>Confirmation</title>
    <meta http-equiv="Content-Type" content="text/html; charset=big5">
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    </head>
    <%@ page language="java"%>
    <%@ page import="java.io.*"%>
    <%@ page import="java.lang.Integer.*"%>
    <%@ page import="java.sql.*"%>
    <%@ page import="java.sql.ResultSet.*"%>
    <%@ page import="javax.servlet.*"%>
    <%@ page import="javax.servlet.http.*"%>
    <%@ page import="java.text.*"%>
    <%@ page import="java.util.*"%>
    <%@ page import="java.net.URL"%>
    <%
    //getting attributes from previous page form
    //At this point, chinese characters r retrieved
    //Ascii/garbage displayed for text when retrieved from previous page.
    String gameName=request.getParameter("name");
    String encode=request.getParameter("encode");
    String gameType=request.getParameter("type");
    String info=request.getParameter("description");
    int check=0;
    int nextGameID;
    String temp="";
    String langCode="";
    //establish connection
    Connection con = null;
    try {
    Class.forName("org.postgresql.Driver");
    con = DriverManager.getConnection("jdbc:postgresql://172.20.134.110:5432/smsINTFET" , "postgres",
    "postgres");
    catch(ClassNotFoundException e) {
    out.println("Could not load the driver: "+e.getMessage());
    catch(SQLException e) {
    out.println("SQLException caught in relax db: "+ e.getMessage());
    Statement stmt = null;
    ResultSet rs = null;
    ResultSet ps = null;
    String strSQL = "";
    String strSQL2 = "";
    String tempCat = "";
    strSQL="SELECT gamename FROM cp_games order by gameid;";
    try {
    stmt = con.createStatement();
    rs = stmt.executeQuery(strSQL);
    stmt.close();
    catch(SQLException e) {
    out.println("SQLException caught: "+ e.getMessage());
    while(rs.next())
    check=0;
    temp=rs.getString("gamename");
    if(temp.equalsIgnoreCase(gameName))
    // there is similar record in database
    check=1;
    break;
    else
    check=0;
    if(check==0)
    %>
    <body background="button/bkgd.jpg" bgproperties="fixed">
    <p><b><font size="30pts" face="Monotype Corsiva">Confirmation</font></b></p>
    <HR style="WIDTH: 500px; COLOR: blue; HEIGHT: 3px">
    The following information has been added.
    <table width="75%" border="0" cellspacing="0" cellpadding="2">
    <%
    String strCat="";
    strCat="INSERT INTO cp_games(gamename,description,encode) values('"+gameName+"','"+info+"','"+encode+"');";
    stmt = con.createStatement();
    stmt.executeUpdate(strCat);
    System.out.println("Successful inserted category");
    stmt.close();
    //setting language
    if(encode.equals("ascii"))
    langCode = "US";
    if(encode.equals("ms950"))
    langCode = "TW";
    if(encode.equals("ms936"))
    langCode = "CN";
    strSQL2="SELECT gameid FROM cp_games where gamename = '"+gameName+"';";
    try {
    stmt = con.createStatement();
    ps = stmt.executeQuery(strSQL2);
    stmt.close();
    catch(SQLException e) {
    out.println("SQLException caught: "+ e.getMessage());
    ps.next();
    nextGameID=ps.getInt("gameid");
    out.println("<B>The game number : </B>" + nextGameID);
    %>
    <tr>
    <td><B>Game added: </B><%=gameName%>
    </td>
    </tr>
    </table>
    <%
    String newFile="G:\\home\\smsGamesINTV2\\colorGame\\propertiesFiles\\FET\\CP_Game"+nextGameID+"_"+encode+"_"+langCode+".properties";
    try
    {               //begin file
    PrintWriter outFile=null;
    //create a new file and write the initial settings to file
    outFile=new PrintWriter(new FileOutputStream(newFile,true));
    outFile.println("game_intro="+nextGameID+")"+gameName+" - "+info);
    outFile.println("");
    outFile.println("game_title="+gameName);
    outFile.println("");
    outFile.println("game_type="+gameType);
    outFile.println("");
    outFile.println("qns_no=0");
    outFile.println("");
    outFile.println("ana_no=0");
    outFile.close();
    }//end file
    catch(IOException e)
    out.println("File Create Error");
    else // no match found
    out.println("Game,"+temp+ " already added");
    %>
    </body>
    </html>

    try to add this code under this line:
    <%@ page contentType="text/html; charset=big5" %>
    <% response.setContentType("text/html; charset=big5"); %>
    I have faced the problem like yours and it works fine for me. Try and see.

  • Showing Chinese characters being fetched from database.

    Hi,
    I have an application (using JSP and Servlets) that needs to show the data fetched from an nVarchar field from an Oracle database. When the data being read includes chinese characters, they are shown as "?". The encoding shown on the client browser is "ISO-8859-1", which clearly needs to be UTF-8.
    Can anybody guide me as to the settings required on the server to change the encoding and ensure that the pages are sent out properly.
    Regards,
    Manish.

    First, check to make sure that the strings sent to the browser are correctly encoded. Do so by manually switching the browser's encoding to the correct value. If you see the correct string, then set the charset to UTF-8. Some thing like this:
    Content-Type: text/html; charset=utf-8

  • Showing Chinese Characters in Pre Music Player?

    Does anyone know how to show music files with Chinese names in a palm pre? Cuz, I tried to drag music files into my pre and the first time it shows the Chinese characters but then when I drag more files, it stops showing the Chinese characters. Instead it shows some weird letters.

    我用pdkstrut没有出现这样的问题。
    国内没有多少人用这个,可否交流一下。
    msn:[email protected]
    qq:29956298

  • How to show chinese characters in Itunes.

    I downloaded Itunes for windows XP on my work desktop but it doesn't show the chinese characters instead it shows boxes. I have Itunes on my Powerbook and I didn't have to do anything special and the chinese characters are shown.

    I downloaded Itunes for windows XP on my work desktop
    but it doesn't show the chinese characters instead it
    shows boxes. I have Itunes on my Powerbook and I
    didn't have to do anything special and the chinese
    characters are shown.
    In WinXP, you do need to do something special to enable Chinese support. See this page:
    http://www.microsoft.com/globaldev/handson/user/xpintlsupp.mspx

  • Why the adobe reader can not show Chinese word

    Hi All,
    i am using WinXP SP2, CFMX7 version 7.0.1, MySQL and the
    latest version of report builder.
    i wish to do a report which can show chinese word and english
    word as well. However, the report can only show english and the
    report will replace '?' in every chinese character. Why and how to
    solve it?
    The CF can insert chinese charater into DB.

    [email protected] wrote:
    > Dear Paulh,
    >
    > no font can display chinese.
    > Where should i trun on identity-H? i dint see.
    preferences or simply press the F8 key.
    > when i enter chinese character into my DB, the cf able
    to catch and display on
    > the screen. BTW, if u insert chinese character within
    <cfoutput>#??#</output>
    > , an error msg will display. If u insert like this
    <cfoutput>??</output>, it
    > will display as '??'
    not following you.

  • Chinese Data Fields not displaying Chinese Characters

    Hi There,
    Wonder if someone can help. We are currently running reports in Crystal 8.5 but are in the process of upgrading our business systems to latest version and this includes converting all our Crystal 8.5 reports to Crystal Reports XI R2 SP4.
    During the process we are experiencing some difficulties in displaying Chinese characters, which have previously worked fine in version 8.5. The system we are running Crystal from has Oracle client 11 installed and the OS system locale is set to Chinese PRC. Our application is displaying Chinese characters properly and if we have any text fields on the report, these are also displaying properly when changing Font to Arial Unicode MS. The only thing that doesn't display properly is the field data which after checking has the correct Chinese data stored in the database. For some reason Crystal 11.5 doesn't seem to be transferring the data correctly which points to some sort of encoding problem.
    Is there something I am missing here or is there something else I need to install for this to work?
    Any hep would be appreciated.

    What is your Oracle database's language set? Is it set to UTF-8 or non UTF-8 (such as American_America.WE8ISO8859P1" )?
    There is a similar issue tracked under ID ADAPT00528561 (Crystal cannot display non-UTF-8 Chinese characters from an Oracle database ) and has been fixed and you should set the following registry key to make it effective:
    Set the following registry key "UseOSLocaleForConversion" to "Yes" under:
    HKEY_LOCAL_MACHINE\Software\Business Objects\Suite 11.5\Crystal Reports\Database\Oracle

Maybe you are looking for