I18n for JOptionPane

I have a JOptionPane with OK/Cancel options.
I change the Default Locale when i need to change the app language.
It's alright when I change the default Locale the first time..the Ok and Cancel are shown in the appropriate language...(in the JOptionPane)
but when i'm changing the Locale the second time say back to English....it doesn't work....
I have done no Locale changes in the JOptionPane code....
using current;y JDK 1.4.1_02
Win/Mac
Any suggestions...!

I have observed that when launching an application from the command line using the -Duser.region= and -Duser.language= arguments, that any JOptionPane dialogs one's application might show shall always display their text using that language and locale no matter whether your program should call Locale.setDefault(), System.setProperty(), UIManager.setLookAndFeel(UIManager.getLookAndFeel()), or anything else you may try, at runtime. On the other hand, I have observed that if you launch your application WITHOUT having set those properties on the command line, then Locale.setDefault() and UIManager.setLookAndFeel(UIManager.getLookAndFeel()) will successfully cause JOptionPane to display all of its text using the "current" locale. This is true for the Windows, Motif and Metal look and feels on both Mac and Windows, under JDK 1.4 and 1.5. On Mac OS X however, the "Mac OS X" look and feel will "switch" (pun intended) to the current locale irrespective of whether or not the user.language and user.region system properties were set on the command line at launch time. This, I assume, is an instance of Macintosh "doing the right thing" for the end user despite what Java's designers may have had in mind...
To be frank, I would appreciate an authoritative answer from someone at Sun on this issue, as to whether or not the behavior I have described is intended -- and if so, why -- or whether it is a bug, or whether I have overlooked some salient fact in the Java documentation that I have no excuse for having overlooked.
Thank you for your time,
JL

Similar Messages

  • Problem in Internalization( I18N) for changing the Source langeuage

    Hi All,
    I have some problem in changing the source language in header:
    In S2X editor, I copyed the .xlf file pasted in same then modifyed accordingly(xxx_de.xlf) when i opend the xlf its asking the Activity when I created its throwing repository access faild like no deltaV resource avilable with directory(c:\......)
    and im not able to change the header and Resource text In S2X Editor, any one give me help on this.
    Thanks
    polaka

    Hi Nagesh,
    When we are doing I18N for that Application. Go to Navigator Tab
    Here Select Particular Projects--à src-àPackages-àsap-àvijay
    To internationalize the Web Dynpro application, copy the automatically generated *.xlf files and save them under a new name in the same directory.
    The new name must meet the following convention:
    u2022 .xlf
    For example, if you are creating *.xlf files for German,
    Use the language key de.
    Here Click on OK
    After that we can edit and translate these new *.xlf files in the S2X Editor.
    ApplyTemFirstView.wdview_de.xlf-àClick on Resource Text Tab
    Select Particular Text and Change the language to German-àClick on EDIT Button
    Here Enter German Lang-àClick on OK
    Now Go to Web Dynpro Explorer Tab
    Select Project-àRC Click on Rebuild Project
    Select Project-àRC Click on Reload
    Then Deploye the Application
    How to Check in Explorer. It is converting to German Language or not
    Open Internet Explorer
    Tool-àInternet Options -àClick on Languages Button-àClick on ADD Button
    Select German Language--àClick on OK
    Now We will Check in Portal
    Created Web Dynpro iView in Portal. That iView assign to the particular WorkSet-àAssign to Role
    Select that user Can Change Language
    Regards
    Vijay Kalluri

  • How to Handle Events for JOptionPane buttons?

    Hi All,
    I need a help...
    I am trying to develop a simple SWING application that consists of multiple elements (mainly text fields) and a Submit button. On pressing Submit button, it should validate all the fields and then do something else. But if some fields are left blank, then it should give a pop-up message and on clicking the OK button on the pop-up message, the focus should go to that text field which is left null.
    The problem is I am not able to understand how to Capture this OK button click-event of the pop-up message. I mean how to do something when the OK/Cancle button of the pop-up window is clicked.
    Please Help me.
    Thanks in Advance,
    Ujjal

    As already pointed out, JOptionPane has some static methods which show a dialog, and return an int, or a string. The whole point of this class is to remove the need for any event handling by the developer, that is, you simply call the showDialog method or whatever, and it returns a value telling you, for example, which button was pressed - no need for action listeners at all. The result of the showDialog method (or whichever you use) tells you which button was pressed. Check the javadocs for JOptionPane for details of several constants that indicate which button was pressed
    The class exists to make simple dialogs trivial to generate - you're overcomplicating things!

  • How to set font for  JOptionPane.showMessageDialog() ?

    Hi,
    I want to set font for JOptionPane.showMessageDialog(). I have tried with following but it did not worked.
    javax.swing.UIManager.put("JOptionPane.font", "Verdana"); Do any one have idea how to do this. Your suggestion would be helpfull to me.
    Thank you.

    Then you'll have to loop over the components in the JOptionPane and setFont for each JButton. My SwingUtils class (search the net using Darryl SwingUtils, I can't give you a link as it's blocked from my office) can make this easier.
    Sample code:import darrylbu.util.SwingUtils;
    import java.awt.Font;
    import javax.swing.*;
    import javax.swing.plaf.FontUIResource;
    public class OptionPaneFonts {
       public static void main(String[] args) {
          UIManager.put("OptionPane.messageFont", new FontUIResource(new Font(
                  "Verdana", Font.BOLD, 32)));
          SwingUtilities.invokeLater(new Runnable() {
             @Override
             public void run() {
                new OptionPaneFonts().makeUI();
       public void makeUI() {
          JOptionPane pane = new JOptionPane("So it's a date?",
                  JOptionPane.QUESTION_MESSAGE,
                  JOptionPane.YES_NO_CANCEL_OPTION,
                  UIManager.getIcon("OptionPane.questionIcon"),
                  new String[]{"Okey-dokey", "Not on your life!",
                     "Let me think about it"
                  }, null);
          for (JButton button : SwingUtils.getDescendantsOfType(JButton.class, pane)) {
             button.setFont(new Font("Tahoma", Font.ITALIC, 18));
          JDialog dialog = new JDialog((JWindow) null);
          dialog.setModal(true);
          dialog.add(pane);
          dialog.pack();
          dialog.setLocationRelativeTo(null);
          dialog.setVisible(true);
    }db
    Edited by: DarrylBurke -- shortened the code

  • Custom icon for JOptionPane.showInputDialog

    As a novice who's wading through Deitel's 'Java how to program', using java2 and j2sdk1.4.1 on JCreator Pro. I want to use my own icons on a small proggie i've written. I know that the format is:
    showInputDialog(Component parentComponent, Object message, String title, int messageType, Icon icon, Object[] selectionValues, Object initialSelectionValue)
    however this doesn't tell me how to write the code. how do i change the default '?' icon for my own icon?
    thanks for any help
    rgds
    adambi

    This should help you also
                ImageIcon ico = new ImageIcon("drag2.jpeg");
                Frame frame = new Frame();
                Object[] options = {"Yes, please",
                        "No, thanks",
                        "No eggs, no ham!"};
              JOptionPane.showInputDialog(frame,
              "What some eggs ?.",
              "My title",JOptionPane.ERROR_MESSAGE,ico,options,
        options[2]);also here is a good link for ya on dialogs
    http://java.sun.com/j2se/1.4/docs/api/
    GOOD LUCK

  • Giving JTextField for JOptionPane.showInputDialog

    Hi All,
    For the above method
    public static Object showInputDialog(Component parentComponent,
                                         Object message,
                                         String title,
                                         int messageType,
                                         Icon icon,
                                         Object[] selectionValues,
                                         Object initialSelectionValue)
                                  throws HeadlessExceptionBasically i am giving like this.
    .Object[] selectionvalues={"gif","png","jpg","bmp","ico"};
    JTextField jtf=new JTextField(15);How can i add the JtextField so that the text which i gave will take the extension of the object array variables given.
    Any help appreciated..
    Thanks in advance.
    regards,
    Viswanadh

    Argh, so now we are getting somewhere. ;o)
    JOptionPane are usually used as a quick, simple way of presenting a dialogbox to the user. I don't think it will be suitable for what you want to do.
    Have a look at this link: [http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html|http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html]
    I think you will need to create a simple dialog box class to do this because the JOptionPane will close when you press the OK button so the user won't see your JTextField with the new value in it.
    BTW, Here is a link for a tutorial that shows you how to customise the JOptionPane for more advanced topics:
    [http://java.sun.com/developer/JDCTechTips/2004/tt0122.html|http://java.sun.com/developer/JDCTechTips/2004/tt0122.html]

  • I18n for the next release of KDE

    I'd love to have KDE in spanish, so if you could....

    neri is indeed correct. unofficial is indeed a misnomer. all packages there are officially supported. unofficial is really just an additional repo whose intention is to represent those packages which do not appear on the install iso. the best way to view it:
    Official= all packages that can be installed from the iso
    Unofficial= all packages not found on the iso.
    the idea is to keep the iso on one disc but offer everything on that disc that allows a user to be as functional as possible while not compromising the speed of the install procedure, etc.
    i have long advocated more language support packages and that is is why i kept pressing for the addition of the i18n catagory. because it is in unofficial please do not infer from that that the development team does not support and encourage foreign language support.
    with respect to the upcoming catagory i just wish to say that i will include only the opackages you users weish to contribute. this will ensure better support for those packages while reducing maintenance of possibly unused language packages.
    i hope that clears some of your questions up roman.

  • Setting the default icons for JOptionPane

    i have my own LookAndFeel and i'm trying to set the icons of JOptionPane but it doesn't work, why?
    Icon errorIcon =  new ImageIcon( "images/EbooksIconMedium.png" );
    table.put( "OptionPane.errorIcon", errorIcon );
    table.put( "OptionPane.informationIcon", errorIcon );
    table.put( "OptionPane.questionIcon", errorIcon );
    table.put( "OptionPane.warningIcon", errorIcon );
    ....

    Hello Dmitry,
    There is no customizing for this - atleast to my knowledge.
    However, you should have to redo the settings again and again unless you are continuously re-sizing the main window.
    Cheers
    Aneesh

  • ActionListener for JOptionPane.showConfirmDialog

    Is it possible to handle JOptionPane.showConfirmDailog 's button click events through action listeners?
    I want to execute some code on the "Save" button click and want to do it like my JFileChooser window stays in the background until either of the Yes,No or Cancel buttons of the showConfirmDialog is pressed.In fact I'm able to get the state of the button pressed using,
    int i=JOptionPane.showConfirmDialog(null,"Confirm file overwrite?")but can't make the showConfirmDialog window stay in the background,,,
    Can anybody please help?
    Thanks in advance...

    There are forums specifically for GUI questions.
    I believe there is also a forum for international issues.

  • Key mapping for JOptionPane

    My problem is pretty simple. When presented with a YES_NO_CANCEL option, I want the escape key to trigger the CANCEL operation.
    I've tried numerous methods including creating my own JOptionPane, adding/removing KeyListeners, etc., but I can't seem to get around this default behavior. Any suggestions?
    Michael

    By default, the Esc key closes the dialog with a return value of JOptionPane.CLOSED_OPTION. Why can't you simply perform the same action as when the return value is JOptionPanel.CANCEL_OPTION ?
    db
    edit Or even reassign the return value, if you prefer to do that (I wouldn't)int retVal = JOptionPane.showOptionDialog(...);
    if (retVal == JOptionPane.CLOSED_OPTION) {
       retVal = JOptionPane.CANCEL_OPTION;
    }Edited by: Darryl.Burke

  • I18n for custom date format strings

    I want to internationalize dates shorter than DateFormat.SHORT, in the form "M/d". For example, when the Locale is US, January 16 should display as 1/16, but if the Locale is MX (Mexico), it should display as 16/1.
    It seems like a very simple problem date formatting problem, but it doesn't look like the DateFormat/SimpleDateFormat classes have any way of doing this. Am I missing something?
    --Steven                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    You need to apply your own customized date pattern to get the formats you want. I suggest you put the patterns in resource bundles...the default pattern in your default bundle, and the Mexican pattern in your bundle for Mexico. Then do something like this:
    <pre>
    <code>
    String newPattern = "M/d"; // retrieve from bundle instead
    Date today = new Date();
    DateFormat df = DateFormat.getInstance();
    SimpleDateFormat simpleFormat = (SimpleDateFormat)df;
    simpleFormat.applyPattern(newPattern);
    System.out.println(df.format(today);
    </code>
    </pre>

  • Internationalization (I18N)  for Japanese

    I am using JSP & MYSQL for my website. I have set all pages in UTF-8 ,
    But while get parameters from request it will return garbage data.
    This is working fine from netbeans.But not on web server.
    Please help

    I have used it but not getting correct string.
    when i post data to another file & from when i get string by request.getParameter("str") it gives me garbage data.

  • Bpel 10.1.3.5 miss russian i18n for admin

    I upgraded bpel from 10.1.3.4 to 10.1.3.5
    Now bpel admin (console) produce error in Apache:
    "GET /BPELAdmin/lib/i18n/.js?gvpn0m HTTP/1.1" 404 134
    I find that russian i18n js file miss in
    orabpel/console/lib/i18n:
    de.js es_ES.js fr_CA.js it.js ko.js readme.txt zh_TW.js
    en.js es.js fr.js ja.js pt_BR.js zh_CN.js
    Any suggestion?

    I have the same problem. My language is dutch, no nl.js either.
    The result of this missing file is that in BPELConsole in the instances-tab Flow, Audit and Source do not work.
    There is no default locale!
    So a workaround is change your language in your browser or make a little change in jsResourceBundle.jspf.
    This file can be found in j2ee\home\applications\orabpel\admin and j2ee\home\applications\orabpel\console.
    In this file the locale is read:
       String key = matchLocale(request.getLocale()).toString();In case of an unsupported locale matchLocale returns an empty String (which is wrong).
    Add this line:
      if ("".equals(key)) {key="en";}And the default is set to english again.
    By the way, did you log a SR?
    Groeten,
    HJH

  • I18n for Server-Based JavaHelp Helpsets?

    Hi Folk,
    Can anyone tell me how can we implement internationalization for Server-Based JavaHelp Helpsets?
    As an example, I have below code snippet for Index.jsp and I am invoking JavaHelp from this page.
    <jsp:useBean id="helpBroker" class="ServletHelpBroker" scope="session" />
    and
    <jh:validate helpBroker="<%= helpBroker %>" helpSetName="MyJavaHelp/alarms/Alarms.hs/>
    As per my understanding,
    In case, I have to support more than one language, then I must have so many .hs files for each lang. But the above( <jh:validate > ) tag accepts only fully qualified url.
    Please let me know how to solve this else if you have any alternative.
    Thanks in advance.
    Pachu

    We have sucessfully used javahelp with a custom network protocol handler
    to fetch the documentation from specific "packages" in the classpath.
    The same technique could be used with a database.
    Drop me a line if you're interested in more detail.
    Gordan Vosicki

  • I18N for web-application which contents can be updated

    Hi,
    I have read several articles and chapters regarding I18N, however I still consider myself new to this topic mostly because I have never developed anything that supported I18N.
    Basically I know how use the ResourceBundle to load strings from different properties files according to the locale of the user.
    However I now want to develop a website that contains different tutorials. The tutorials can be written in different languages. A website is usually deployed in a WAR file, and thus it is not something as easy as to put all the text of a tutorial inside a properties file. I was thinking of having to use some database backend.
    Anyway my question is; How to implement I18N in a web application which contents can be updated?
    Regards,
    Sim085

    I think they want the users to be able to enter in
    text via the UI and they want to know the best
    approach to supporting mutiple langauges. Exactly!! :)
    I found this whitepaper informative but I have not
    yet tried the approach described.
    http://www.inter-locale.com/IUC19.pdf
    GaryThanks Gary .. I will read that white paper.
    Regards,
    Sim085

Maybe you are looking for

  • Sap hr system table

    Please Let me know What is SAPHR System Table nuber ?

  • I paid for limbo and it won't run. Can I get a refund?

    Didn't realize limbo won't run on my 2008 macbook. It's still a speedy machine, I don't understand why it's not supported. Anyway, I've spent the money now, can I get a refund do you think? Thanks, Jesse

  • Aggregation in IR works incorrectly when breaks on computed cols are used

    I have a problem with aggregation in IR when breaks on computed cols are used. Please see exact steps to reproduce the problem in my next post bellow Martin Edited by: Martin Krepelka on Oct 22, 2008 11:18 AM

  • Characteristics(CT04) Issue.

    Dear SD Consultants,         I am having some standard Characteristics(CT04) in Development Server. But i am not having the same in Production Server. Can any one please guide me to transport the standard Characteristics from DEV to PRD. PLease help

  • Which software to use?

    Hi. Im going to do a video memorial for an uncle. I have searched the web lookig for a professional or semiprofessional software to do it but I cant find anything. Do you know of any free software that could help me with this? Thanks in advance