Example usage for java.util Locale CHINA

List of usage examples for java.util Locale CHINA

Introduction

In this page you can find the example usage for java.util Locale CHINA.

Prototype

Locale CHINA

To view the source code for java.util Locale CHINA.

Click Source Link

Document

Useful constant for country.

Usage

From source file:com.qawaa.gui.EventWebScanGUI.java

/**
 * ?//from w  w  w.ja  v  a 2 s. c o  m
 * @param evt
 * @throws InterruptedException 
 */
private static void submitActionPerformed(ActionEvent evt) throws InterruptedException {
    WebSearchScanThread wssThread = WebSearchScanThread.Instance();
    if (RUNNING) {
        wssThread.threadStop();
        JOptionPane.showConfirmDialog(null, CONTEXT.getMessage("gobal.stop.dialog.msg", null, Locale.CHINA),
                CONTEXT.getMessage("gobal.stop.dialog.title", null, Locale.CHINA), JOptionPane.CLOSED_OPTION,
                JOptionPane.CLOSED_OPTION);
        return;
    }
    submit.setText(CONTEXT.getMessage("gobal.gui.button.init", null, Locale.CHINA));
    submit.setEnabled(false);
    LOG.info(CONTEXT.getMessage("gobal.db.connect", null, Locale.CHINA));
    Thread.sleep(1000L);
    WebScanControl c = WebScanControl.getInstance();
    try {
        if (!HibernateDataBaseCheck.check()) {
            LOG.error(CONTEXT.getMessage("gobal.db.connect.fail", null, Locale.CHINA));
            submit.setText(CONTEXT.getMessage("gobal.gui.button.run", null, Locale.CHINA));
            submit.setEnabled(true);
            return;
        }
    } catch (Exception e) {
        LOG.error(CONTEXT.getMessage("gobal.db.connect.fail", null, Locale.CHINA));
        submit.setText(CONTEXT.getMessage("gobal.gui.button.run", null, Locale.CHINA));
        submit.setEnabled(true);
        return;
    }
    LOG.info(CONTEXT.getMessage("gobal.db.connect.success", null, Locale.CHINA));
    Thread.sleep(500L);
    LOG.info(CONTEXT.getMessage("event.web.scan.event.check", null, Locale.CHINA));
    if (c.isExistEventList()) {
        LOG.error(CONTEXT.getMessage("event.web.scan.event.null", null, Locale.CHINA));
        submit.setText(CONTEXT.getMessage("gobal.gui.button.run", null, Locale.CHINA));
        submit.setEnabled(true);
        return;
    } else {
        LOG.info(CONTEXT.getMessage("event.web.scan.event.check.success", null, Locale.CHINA));
    }
    LOG.info(CONTEXT.getMessage("event.web.scan.start", null, Locale.CHINA));
    Thread.sleep(1000L);
    submit.setText(CONTEXT.getMessage("gobal.gui.button.stop", null, Locale.CHINA));
    submit.setEnabled(true);
    RUNNING = true;
    RunTimeListener runTimeListener = new RunTimeListener(runtime_value);
    runTimeListener.start();
    wssThread.start();
}

From source file:com.borax12.materialdaterangepicker.date.MonthView.java

protected void drawMonthDayLabels(Canvas canvas) {
    int y = getMonthHeaderSize() - (MONTH_DAY_LABEL_TEXT_SIZE / 2);
    int dayWidthHalf = (mWidth - mEdgePadding * 2) / (mNumDays * 2);

    for (int i = 0; i < mNumDays; i++) {
        int x = (2 * i + 1) * dayWidthHalf + mEdgePadding;

        int calendarDay = (i + mWeekStart) % mNumDays;
        mDayLabelCalendar.set(Calendar.DAY_OF_WEEK, calendarDay);
        Locale locale = Locale.getDefault();
        String localWeekDisplayName = mDayLabelCalendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT,
                locale);//w  ww . j  ava 2  s.c o  m
        String weekString = localWeekDisplayName.toUpperCase(locale).substring(0, 1);

        if (locale.equals(Locale.CHINA) || locale.equals(Locale.CHINESE)
                || locale.equals(Locale.SIMPLIFIED_CHINESE) || locale.equals(Locale.TRADITIONAL_CHINESE)) {
            int len = localWeekDisplayName.length();
            weekString = localWeekDisplayName.substring(len - 1, len);
        }

        if (locale.getLanguage().equals("he") || locale.getLanguage().equals("iw")) {
            if (mDayLabelCalendar.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) {
                int len = localWeekDisplayName.length();
                weekString = localWeekDisplayName.substring(len - 2, len - 1);
            } else {
                // I know this is duplication, but it makes the code easier to grok by
                // having all hebrew code in the same block
                weekString = localWeekDisplayName.toUpperCase(locale).substring(0, 1);
            }
        }
        canvas.drawText(weekString, x, y, mMonthDayLabelPaint);
    }
}

From source file:com.feilong.core.bean.ConvertUtilTest.java

/**
 * Test to locale.//w w w .j  a  v a  2  s . co  m
 */
@Test
public void testToLocale() {
    assertEquals(null, toLocale(null));
    assertEquals(Locale.CHINA, toLocale("zh_CN"));
    assertEquals(Locale.CHINA, toLocale(Locale.CHINA));
}

From source file:com.customdatepicker.date.MonthView.java

/**
 * Return a 1 or 2 letter String for use as a weekday label
 *
 * @param day The day for which to generate a label
 * @return The weekday label//from w ww .j  a  va  2s.c  o  m
 */
private String getWeekDayLabel(Calendar day) {
    Locale locale = Locale.getDefault();

    // Localised short version of the string is not available on API < 18
    if (Build.VERSION.SDK_INT < 18) {
        String dayName = new SimpleDateFormat("E", locale).format(day.getTime());
        String dayLabel = dayName.toUpperCase(locale).substring(0, 1);

        // Chinese labels should be fetched right to left
        if (locale.equals(Locale.CHINA) || locale.equals(Locale.CHINESE)
                || locale.equals(Locale.SIMPLIFIED_CHINESE) || locale.equals(Locale.TRADITIONAL_CHINESE)) {
            int len = dayName.length();
            dayLabel = dayName.substring(len - 1, len);
        }

        // Most hebrew labels should select the second to last character
        if (locale.getLanguage().equals("he") || locale.getLanguage().equals("iw")) {
            if (mDayLabelCalendar.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) {
                int len = dayName.length();
                dayLabel = dayName.substring(len - 2, len - 1);
            } else {
                // I know this is duplication, but it makes the code easier to grok by
                // having all hebrew code in the same block
                dayLabel = dayName.toUpperCase(locale).substring(0, 1);
            }
        }

        // Catalan labels should be two digits in lowercase
        if (locale.getLanguage().equals("ca"))
            dayLabel = dayName.toLowerCase().substring(0, 2);

        // Correct single character label in Spanish is X
        if (locale.getLanguage().equals("es") && day.get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
            dayLabel = "X";

        return dayLabel;
    }
    // Getting the short label is a one liner on API >= 18
    if (weekDayLabelFormatter == null) {
        weekDayLabelFormatter = new SimpleDateFormat("EEEEE", locale);
    }
    return weekDayLabelFormatter.format(day.getTime());
}

From source file:com.borax12.materialdaterangepicker.single.date.MonthView.java

/**
 * Return a 1 or 2 letter String for use as a weekday label
 * @param day The day for which to generate a label
 * @return The weekday label/*from   ww  w  . j  a  v  a2  s. c  o m*/
 */
private String getWeekDayLabel(Calendar day) {
    Locale locale = Locale.getDefault();

    // Localised short version of the string is not available on API < 18
    if (Build.VERSION.SDK_INT < 18) {
        String dayName = new SimpleDateFormat("E", locale).format(day.getTime());
        String dayLabel = dayName.toUpperCase(locale).substring(0, 1);

        // Chinese labels should be fetched right to left
        if (locale.equals(Locale.CHINA) || locale.equals(Locale.CHINESE)
                || locale.equals(Locale.SIMPLIFIED_CHINESE) || locale.equals(Locale.TRADITIONAL_CHINESE)) {
            int len = dayName.length();
            dayLabel = dayName.substring(len - 1, len);
        }

        // Most hebrew labels should select the second to last character
        if (locale.getLanguage().equals("he") || locale.getLanguage().equals("iw")) {
            if (mDayLabelCalendar.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) {
                int len = dayName.length();
                dayLabel = dayName.substring(len - 2, len - 1);
            } else {
                // I know this is duplication, but it makes the code easier to grok by
                // having all hebrew code in the same block
                dayLabel = dayName.toUpperCase(locale).substring(0, 1);
            }
        }

        // Catalan labels should be two digits in lowercase
        if (locale.getLanguage().equals("ca"))
            dayLabel = dayName.toLowerCase().substring(0, 2);

        // Correct single character label in Spanish is X
        if (locale.getLanguage().equals("es") && day.get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
            dayLabel = "X";

        return dayLabel;
    }
    // Getting the short label is a one liner on API >= 18
    return new SimpleDateFormat("EEEEE", locale).format(day.getTime());
}

From source file:com.jarklee.materialdatetimepicker.date.MonthView.java

/**
 * Return a 1 or 2 letter String for use as a weekday label
 *
 * @param day The day for which to generate a label
 * @return The weekday label/*from   w  w w .  jav  a2  s  .  c om*/
 */
private String getWeekDayLabel(Calendar day) {
    Locale locale = getLocale();
    // Localised short version of the string is not available on API < 18
    if (Build.VERSION.SDK_INT < 18) {
        String dayName = new SimpleDateFormat("E", locale).format(day.getTime());
        String dayLabel = dayName.toUpperCase(locale).substring(0, 1);

        // Chinese labels should be fetched right to left
        if (locale.equals(Locale.CHINA) || locale.equals(Locale.CHINESE)
                || locale.equals(Locale.SIMPLIFIED_CHINESE) || locale.equals(Locale.TRADITIONAL_CHINESE)) {
            int len = dayName.length();
            dayLabel = dayName.substring(len - 1, len);
        }

        // Most hebrew labels should select the second to last character
        if (locale.getLanguage().equals("he") || locale.getLanguage().equals("iw")) {
            if (mDayLabelCalendar.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) {
                int len = dayName.length();
                dayLabel = dayName.substring(len - 2, len - 1);
            } else {
                // I know this is duplication, but it makes the code easier to grok by
                // having all hebrew code in the same block
                dayLabel = dayName.toUpperCase(locale).substring(0, 1);
            }
        }

        // Catalan labels should be two digits in lowercase
        if (locale.getLanguage().equals("ca"))
            dayLabel = dayName.toLowerCase().substring(0, 2);

        // Correct single character label in Spanish is X
        if (locale.getLanguage().equals("es") && day.get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
            dayLabel = "X";

        return dayLabel;
    }
    // Getting the short label is a one liner on API >= 18
    return new SimpleDateFormat("EEEEE", locale).format(day.getTime());
}

From source file:com.t3.client.TabletopTool.java

public static void main(String[] args) {
    if (MAC_OS_X) {
        // On OSX the menu bar at the top of the screen can be enabled at any time, but the
        // title (ie. name of the application) has to be set before the GUI is initialized (by
        // creating a frame, loading a splash screen, etc).  So we do it here.
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        System.setProperty("com.apple.mrj.application.apple.menu.about.name", "About TabletopTool...");
        System.setProperty("apple.awt.brushMetalLook", "true");
    }//  w  w w . j a v  a  2 s.  co m
    // Before anything else, create a place to store all the data
    try {
        AppUtil.getAppHome();
    } catch (Throwable t) {
        t.printStackTrace();

        // Create an empty frame so there's something to click on if the dialog goes in the background
        JFrame frame = new JFrame();
        SwingUtil.centerOnScreen(frame);
        frame.setVisible(true);

        String errorCreatingDir = "Error creating data directory";
        log.error(errorCreatingDir, t);
        JOptionPane.showMessageDialog(frame, t.getMessage(), errorCreatingDir, JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    }
    verifyJavaVersion();

    configureLogging();

    // System properties
    System.setProperty("swing.aatext", "true");
    // System.setProperty("sun.java2d.opengl", "true");

    final SplashScreen splash = new SplashScreen(SPLASH_IMAGE, getVersion());
    splash.showSplashScreen();

    // Protocol handlers
    // cp:// is registered by the RPTURLStreamHandlerFactory constructor (why?)
    RPTURLStreamHandlerFactory factory = new RPTURLStreamHandlerFactory();
    factory.registerProtocol("asset", new AssetURLStreamHandler());
    URL.setURLStreamHandlerFactory(factory);

    MacroEngine.initialize();
    configureJide(); //TODO find out how to not call this twice without destroying error windows

    final Toolkit tk = Toolkit.getDefaultToolkit();
    tk.getSystemEventQueue().push(new T3EventQueue());

    // LAF
    try {

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        configureJide();
        if (WINDOWS)
            LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE);
        else
            LookAndFeelFactory.installJideExtension();
        if (MAC_OS_X) {
            macOSXicon();
        }
        menuBar = new AppMenuBar();
    } catch (Exception e) {
        TabletopTool.showError("msg.error.lafSetup", e);
        System.exit(1);
    }

    /**
     * This is a tweak that makes the Chinese version work better.
     * <p>
     * Consider reviewing <a
     * href="http://en.wikipedia.org/wiki/CJK_characters"
     * >http://en.wikipedia.org/wiki/CJK_characters</a> before making
     * changes. And http://www.scarfboy.com/coding/unicode-tool is also a
     * really cool site.
     */
    if (Locale.CHINA.equals(Locale.getDefault())) {
        // The following font name appears to be "Sim Sun".  It can be downloaded
        // from here:  http://fr.cooltext.com/Fonts-Unicode-Chinese
        Font f = new Font("\u65B0\u5B8B\u4F53", Font.PLAIN, 12);
        FontUIResource fontRes = new FontUIResource(f);
        for (Enumeration<Object> keys = UIManager.getDefaults().keys(); keys.hasMoreElements();) {
            Object key = keys.nextElement();
            Object value = UIManager.get(key);
            if (value instanceof FontUIResource)
                UIManager.put(key, fontRes);
        }
    }

    // Draw frame contents on resize
    tk.setDynamicLayout(true);

    EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            initialize();
            EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    clientFrame.setVisible(true);
                    splash.hideSplashScreen();
                    EventQueue.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            postInitialize();
                        }
                    });
                }
            });
        }
    });
    // new Thread(new HeapSpy()).start();
}

From source file:net.rptools.maptool.client.MapTool.java

public static void main(String[] args) {
    if (MAC_OS_X) {
        // On OSX the menu bar at the top of the screen can be enabled at any time, but the
        // title (ie. name of the application) has to be set before the GUI is initialized (by
        // creating a frame, loading a splash screen, etc).  So we do it here.
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        System.setProperty("com.apple.mrj.application.apple.menu.about.name", "About MapTool...");
        System.setProperty("apple.awt.brushMetalLook", "true");
    }/* ww  w .  j  a v  a2 s.c om*/
    // Before anything else, create a place to store all the data
    try {
        AppUtil.getAppHome();
    } catch (Throwable t) {
        t.printStackTrace();

        // Create an empty frame so there's something to click on if the dialog goes in the background
        JFrame frame = new JFrame();
        SwingUtil.centerOnScreen(frame);
        frame.setVisible(true);

        String errorCreatingDir = "Error creating data directory";
        log.error(errorCreatingDir, t);
        JOptionPane.showMessageDialog(frame, t.getMessage(), errorCreatingDir, JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    }
    verifyJavaVersion();

    configureLogging();

    // System properties
    System.setProperty("swing.aatext", "true");
    // System.setProperty("sun.java2d.opengl", "true");

    final SplashScreen splash = new SplashScreen(SPLASH_IMAGE, getVersion());
    splash.showSplashScreen();

    // Protocol handlers
    // cp:// is registered by the RPTURLStreamHandlerFactory constructor (why?)
    RPTURLStreamHandlerFactory factory = new RPTURLStreamHandlerFactory();
    factory.registerProtocol("asset", new AssetURLStreamHandler());
    URL.setURLStreamHandlerFactory(factory);

    final Toolkit tk = Toolkit.getDefaultToolkit();
    tk.getSystemEventQueue().push(new MapToolEventQueue());

    // LAF
    try {
        // If we are running under Mac OS X then save native menu bar look & feel components
        // Note the order of creation for the AppMenuBar, this specific chronology
        // allows the system to set up system defaults before we go and modify things.
        // That is, please don't move these lines around unless you test the result on windows and mac
        String lafname;
        if (MAC_OS_X) {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            menuBar = new AppMenuBar();
            lafname = "net.rptools.maptool.client.TinyLookAndFeelMac";
            UIManager.setLookAndFeel(lafname);
            macOSXicon();
        }
        // If running on Windows based OS, CJK font is broken when using TinyLAF.
        //         else if (WINDOWS) {
        //            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        //            menuBar = new AppMenuBar();
        //         }
        else {
            lafname = "de.muntjak.tinylookandfeel.TinyLookAndFeel";
            UIManager.setLookAndFeel(lafname);
            menuBar = new AppMenuBar();
        }
        // After the TinyLAF library is initialized, look to see if there is a Default.theme
        // in our AppHome directory and load it if there is.  Unfortunately, changing the
        // search path for the default theme requires subclassing TinyLAF and because
        // we have both the original and a Mac version that gets cumbersome.  (Really
        // the Mac version should use the default and then install the keystroke differences
        // but what we have works and I'm loathe to go playing with it at 1.3b87 -- yes, 87!)
        File f = AppUtil.getAppHome("config");
        if (f.exists()) {
            File f2 = new File(f, "Default.theme");
            if (f2.exists()) {
                if (Theme.loadTheme(f2)) {
                    // re-install the Tiny Look and Feel
                    UIManager.setLookAndFeel(lafname);

                    // Update the ComponentUIs for all Components. This
                    // needs to be invoked for all windows.
                    //SwingUtilities.updateComponentTreeUI(rootComponent);
                }
            }
        }

        com.jidesoft.utils.Lm.verifyLicense("Trevor Croft", "rptools", "5MfIVe:WXJBDrToeLWPhMv3kI2s3VFo");
        LookAndFeelFactory.addUIDefaultsCustomizer(new LookAndFeelFactory.UIDefaultsCustomizer() {
            public void customize(UIDefaults defaults) {
                // Remove red border around menus
                defaults.put("PopupMenu.foreground", Color.lightGray);
            }
        });
        LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE);

        /****************************************************************************
         * For TinyLAF 1.3.04 this is how the color was changed for a
         * button.
         */
        // Theme.buttonPressedColor[Theme.style] = new ColorReference(Color.gray);

        /****************************************************************************
         * And this is how it's done in TinyLAF 1.4.0 (no idea about the
         * intervening versions).
         */
        Theme.buttonPressedColor = new SBReference(Color.GRAY, 0, -6, SBReference.SUB3_COLOR);

        configureJide();
    } catch (Exception e) {
        MapTool.showError("msg.error.lafSetup", e);
        System.exit(1);
    }

    /**
     * This is a tweak that makes the Chinese version work better.
     * <p>
     * Consider reviewing <a
     * href="http://en.wikipedia.org/wiki/CJK_characters"
     * >http://en.wikipedia.org/wiki/CJK_characters</a> before making
     * changes. And http://www.scarfboy.com/coding/unicode-tool is also a
     * really cool site.
     */
    if (Locale.CHINA.equals(Locale.getDefault())) {
        // The following font name appears to be "Sim Sun".  It can be downloaded
        // from here:  http://fr.cooltext.com/Fonts-Unicode-Chinese
        Font f = new Font("\u65B0\u5B8B\u4F53", Font.PLAIN, 12);
        FontUIResource fontRes = new FontUIResource(f);
        for (Enumeration<Object> keys = UIManager.getDefaults().keys(); keys.hasMoreElements();) {
            Object key = keys.nextElement();
            Object value = UIManager.get(key);
            if (value instanceof FontUIResource)
                UIManager.put(key, fontRes);
        }
    }

    // Draw frame contents on resize
    tk.setDynamicLayout(true);

    EventQueue.invokeLater(new Runnable() {
        public void run() {
            initialize();
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    clientFrame.setVisible(true);
                    splash.hideSplashScreen();
                    EventQueue.invokeLater(new Runnable() {
                        public void run() {
                            postInitialize();
                        }
                    });
                }
            });
        }
    });
    // new Thread(new HeapSpy()).start();
}