List of usage examples for java.util Locale setDefault
public static synchronized void setDefault(Locale newLocale)
From source file:app.RunApp.java
/** * Constructor. It initializes the main features of the tool. */// ww w . ja v a 2s . c om public RunApp() { //For menus language at charts Locale.setDefault(Locale.UK); jTablePrincipal = new JTable(); jTableChiPhi = new JTable(); fixedTableChiPhi = new JTable(); fixedTableCoocurrences = new JTable(); fixedTableHeatmap = new JTable(); jTableCoocurrences = new JTable(); jTableHeatmap = new JTable(); jTableMulti = new JTable(); this.setTitle("Multi-Label Dataset Analyzer (MLDA)"); try { this.setIconImage(ImageIO.read(new File("src/images/64.png"))); } catch (IOException exc) { } this.setMinimumSize(new Dimension(780, 500)); this.setBounds(300, 0, 780, 500); initComponents(); initConfig(); datasetCurrentName = ""; multipleDatasetsConfig(); }
From source file:helma.main.Server.java
/** * initialize the server//from ww w.j a v a 2s .c om */ public void init() throws IOException { // set the log factory property String logFactory = sysProps.getProperty("loggerFactory", "helma.util.Logging"); helmaLogging = "helma.util.Logging".equals(logFactory); System.setProperty("org.apache.commons.logging.LogFactory", logFactory); // set the current working directory to the helma home dir. // note that this is not a real cwd, which is not supported // by java. It makes sure relative to absolute path name // conversion is done right, so for Helma code, this should work. System.setProperty("user.dir", hopHome.getPath()); // from now on it's safe to call getLogger() because hopHome is set up getLogger(); String startMessage = "Starting Helma " + version + " on Java " + System.getProperty("java.version"); logger.info(startMessage); // also print a msg to System.out System.out.println(startMessage); logger.info("Setting Helma Home to " + hopHome); // read db.properties file in helma home directory String dbPropfile = sysProps.getProperty("dbPropFile"); File file; if ((dbPropfile != null) && !"".equals(dbPropfile.trim())) { file = new File(dbPropfile); } else { file = new File(hopHome, "db.properties"); } dbProps = new ResourceProperties(); dbProps.setIgnoreCase(false); dbProps.addResource(new FileResource(file)); DbSource.setDefaultProps(dbProps); // read apps.properties file String appsPropfile = sysProps.getProperty("appsPropFile"); if ((appsPropfile != null) && !"".equals(appsPropfile.trim())) { file = new File(appsPropfile); } else { file = new File(hopHome, "apps.properties"); } appsProps = new ResourceProperties(); appsProps.setIgnoreCase(true); appsProps.addResource(new FileResource(file)); paranoid = "true".equalsIgnoreCase(sysProps.getProperty("paranoid")); String language = sysProps.getProperty("language"); String country = sysProps.getProperty("country"); String timezone = sysProps.getProperty("timezone"); if ((language != null) && (country != null)) { Locale.setDefault(new Locale(language, country)); } if (timezone != null) { TimeZone.setDefault(TimeZone.getTimeZone(timezone)); } // logger.debug("Locale = " + Locale.getDefault()); // logger.debug("TimeZone = " + // TimeZone.getDefault().getDisplayName(Locale.getDefault())); dbSources = new Hashtable(); // try to load the extensions extensions = new Vector(); if (sysProps.getProperty("extensions") != null) { initExtensions(); } jetty = JettyServer.init(this, config); }
From source file:org.jfree.data.time.WeekTest.java
/** * A test for a problem in constructing a new Week instance. */// w w w . j av a2 s . c o m @Test public void testConstructor() { Locale savedLocale = Locale.getDefault(); TimeZone savedZone = TimeZone.getDefault(); Locale.setDefault(new Locale("da", "DK")); TimeZone.setDefault(TimeZone.getTimeZone("Europe/Copenhagen")); GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault()); // first day of week is monday assertEquals(Calendar.MONDAY, cal.getFirstDayOfWeek()); cal.set(2007, Calendar.AUGUST, 26, 1, 0, 0); cal.set(Calendar.MILLISECOND, 0); Date t = cal.getTime(); Week w = new Week(t, TimeZone.getTimeZone("Europe/Copenhagen")); assertEquals(34, w.getWeek()); Locale.setDefault(Locale.US); TimeZone.setDefault(TimeZone.getTimeZone("US/Detroit")); cal = (GregorianCalendar) Calendar.getInstance(TimeZone.getDefault()); // first day of week is Sunday assertEquals(Calendar.SUNDAY, cal.getFirstDayOfWeek()); cal.set(2007, Calendar.AUGUST, 26, 1, 0, 0); cal.set(Calendar.MILLISECOND, 0); t = cal.getTime(); w = new Week(t, TimeZone.getTimeZone("Europe/Copenhagen")); assertEquals(35, w.getWeek()); w = new Week(t, TimeZone.getTimeZone("Europe/Copenhagen"), new Locale("da", "DK")); assertEquals(34, w.getWeek()); Locale.setDefault(savedLocale); TimeZone.setDefault(savedZone); }
From source file:org.pegadi.client.ApplicationLauncher.java
protected void setLocale(String locale) { if (locale.equals("no_NO")) { Locale.setDefault(new Locale("no", "NO")); } else if (locale.equals("no_NO_NY")) { Locale.setDefault(new Locale("no", "NO", "NY")); } else if (locale.equals("en")) { Locale.setDefault(new Locale("en", "GB")); } else if (locale.equals("le")) { Locale.setDefault(new Locale("le", "XX")); } else {/*from ww w . ja va 2 s .c om*/ throw new IllegalArgumentException("'" + locale + "' is not a supported locale"); } // TODO make resourcebundle read as utf-8 http://pegadi.underdusken.no/ticket/4 str = ResourceBundle.getBundle("org.pegadi.client.ClientStrings"); listerButton.setText(str.getString("lister_button")); listerButton.setToolTipText(str.getString("tip_lister_button")); listerButton.setMnemonic(str.getString("lister_button").charAt(0)); publicationButton.setText(str.getString("publication_button")); publicationButton.setToolTipText(str.getString("tip_publication_button")); sourcesButton.setText(str.getString("sources_button")); sourcesButton.setToolTipText(str.getString("tip_sources_button")); sourcesButton.setMnemonic(str.getString("sources_button").charAt(0)); tetrisButton.setText(str.getString("tetris_button")); tetrisButton.setToolTipText(str.getString("tip_tetris_button")); tetrisButton.setMnemonic(str.getString("tetris_button").charAt(0)); logoutButton.setText(str.getString("logout_button")); logoutButton.setToolTipText(str.getString("tip_logout_button")); quitButton.setText(str.getString("quit_button")); quitButton.setToolTipText(str.getString("tip_quit_button")); fileMenu.setMnemonic(str.getString("menu_program_mnem").charAt(0)); fileMenu.setText(str.getString("menu_program")); editMenu.setMnemonic(str.getString("menu_edit_mnem").charAt(0)); editMenu.setText(str.getString("menu_edit")); helpMenu.setMnemonic(str.getString("menu_help_mnem").charAt(0)); helpMenu.setText(str.getString("menu_help")); prefsMenuItem.setText(str.getString("menu_edit_pref")); prefsMenuItem.setMnemonic(str.getString("menu_edit_pref_mnem").charAt(0)); logoutMenuItem.setText(str.getString("menu_program_logout")); logoutMenuItem.setMnemonic(str.getString("menu_program_logout_mnem").charAt(0)); quitMenuItem.setMnemonic(str.getString("menu_program_quit_mnem").charAt(0)); quitMenuItem.setText(str.getString("menu_program_quit")); listerMenuItem.setText(str.getString("lister_button")); listerMenuItem.setMnemonic(str.getString("lister_button").charAt(0)); tetrisMenuItem.setText(str.getString("tetris_button")); tetrisMenuItem.setMnemonic(str.getString("tetris_button").charAt(0)); sourcesMenuItem.setText(str.getString("sources_button")); sourcesMenuItem.setMnemonic(str.getString("sources_button").charAt(0)); reportBugAction.putValue(AbstractAction.NAME, str.getString("menu_help_report")); if (LoginContext.server != null) { try { setLoggedinUserLabel(); } catch (Exception le) { log.error("Error getting real user name", le); } } }
From source file:net.sourceforge.pmd.lang.xml.XmlParserTest.java
/** * Verifies the parsing behavior of the XML parser with validation on. * //from w ww. j av a2s . c o m * @throws UnsupportedEncodingException * error */ @Test public void testParsingWithValidation() throws UnsupportedEncodingException { LanguageVersionHandler xmlVersionHandler = LanguageRegistry.getLanguage(XmlLanguageModule.NAME) .getDefaultVersion().getLanguageVersionHandler(); XmlParserOptions parserOptions = new XmlParserOptions(); parserOptions.setValidating(true); Parser parser = xmlVersionHandler.getParser(parserOptions); PrintStream oldErr = System.err; Locale oldLocale = Locale.getDefault(); try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); System.setErr(new PrintStream(bos)); Locale.setDefault(Locale.ENGLISH); Node document = parser.parse(null, new StringReader(XML_INVALID_WITH_DTD)); Assert.assertNotNull(document); String output = bos.toString("UTF-8"); Assert.assertTrue(output.contains("Element type \"invalidChild\" must be declared.")); Assert.assertTrue( output.contains("The content of element type \"rootElement\" must match \"(child)\".")); Assert.assertEquals(2, document.jjtGetNumChildren()); Assert.assertEquals("invalidChild", String.valueOf(document.jjtGetChild(1).jjtGetChild(1))); } finally { System.setErr(oldErr); Locale.setDefault(oldLocale); } }
From source file:org.apache.maven.plugins.pdf.PdfMojo.java
/** * Generate the PDF.// ww w . j a va2 s. co m * * @throws MojoExecutionException if any * @throws IOException if any * @since 1.1 */ private void generatePdf() throws MojoExecutionException, IOException { Locale.setDefault(getDefaultLocale()); for (final Locale locale : getAvailableLocales()) { final File workingDir = getLocaleDirectory(workingDirectory, locale); File siteDirectoryFile = getLocaleDirectory(getSiteDirectoryTmp(), locale); copyResources(locale); generateMavenReports(locale); DocumentRendererContext context = new DocumentRendererContext(); context.put("project", project); context.put("settings", settings); context.put("PathTool", new PathTool()); context.put("FileUtils", new FileUtils()); context.put("StringUtils", new StringUtils()); context.put("i18n", i18n); context.put("generateTOC", generateTOC); context.put("validate", validate); final DocumentModel model = aggregate ? getDocumentModel(locale) : null; try { // TODO use interface see DOXIASITETOOLS-30 ((AbstractDocumentRenderer) docRenderer).render(siteDirectoryFile, workingDir, model, context); } catch (DocumentRendererException e) { throw new MojoExecutionException("Error during document generation: " + e.getMessage(), e); } } }
From source file:com.awt.supark.MainActivity.java
public void setLanguage(String lang) { sharedprefs.edit().putString("lang", lang).commit(); if (!lang.equals("auto")) { Locale locale = new Locale(lang); Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale;//from w w w.j a va2 s. c om getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics()); } }
From source file:dev.datvt.cloudtracks.MainActivity.java
public void loadLocale() { String langPref = "Language"; SharedPreferences prefs = getSharedPreferences("CommonPrefs", Activity.MODE_PRIVATE); String language = prefs.getString(langPref, "en"); myLocale = new Locale(language); Locale.setDefault(myLocale); Configuration config = new Configuration(); config.locale = myLocale;/*ww w .j ava 2 s . c om*/ getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics()); }
From source file:de.azapps.mirakel.settings.SettingsActivity.java
@Override public void onConfigurationChanged(final Configuration newConfig) { Locale.setDefault(Helpers.getLocal(this)); super.onConfigurationChanged(newConfig); if (this.isTablet != MirakelCommonPreferences.isTablet()) { final Bundle saved = new Bundle(); onSaveInstanceState(saved);// w w w . j a v a 2s . co m onCreate(saved); invalidateHeaders(); onRestoreInstanceState(saved); if (!isTablet && getActionBar() != null) { getActionBar().setTitle(R.string.title_settings); } } }
From source file:pl.edu.icm.visnow.system.main.VisNow.java
public static void main(final String[] args) { /*/*from www. jav a 2s.co m*/ * try { for (javax.swing.UIManager.LookAndFeelInfo info : * javax.swing.UIManager.getInstalledLookAndFeels()) { if * ("Nimbus".equals(info.getName())) { * javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } * } catch (ClassNotFoundException ex) { * java.util.logging.LOGGER.getLogger(VisNow.class.getName()).log(java.util.logging.Level.SEVERE, * null, ex); } catch (InstantiationException ex) { * java.util.logging.LOGGER.getLogger(VisNow.class.getName()).log(java.util.logging.Level.SEVERE, * null, ex); } catch (IllegalAccessException ex) { * java.util.logging.LOGGER.getLogger(VisNow.class.getName()).log(java.util.logging.Level.SEVERE, * null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { * java.util.logging.LOGGER.getLogger(VisNow.class.getName()).log(java.util.logging.Level.SEVERE, * null, ex); } */ EventQueue.invokeLater(new Runnable() { @Override public void run() { for (int i = 0; i < args.length; i++) { if (args[i].equals("-debug")) { debug = true; } if (args[i].equals("-substancedebug")) { substancedebug = true; } if (args[i].equals("-easy")) { libraryLevel = SIMPLE_LIBRARY; VERSION = VERSION_BASE + "-Simple"; allowGUISwitch = false; } if (args[i].equals("-full")) { guiLevel = EXPERT_GUI; libraryLevel = FULL_LIBRARY; VERSION = VERSION_BASE + "-Pro"; } } Locale.setDefault(Locale.US); renderSplashFrame(0.1f, "Initializing logging..."); //TODO: test it see #initConfigDir // initConfigDir(); initLogging(); startupInfo(); renderSplashFrame(0.2f, "Initializing Java3D..."); initJava3D(); if (substancedebug) { try { Class substance = Class.forName("org.jvnet.substance.SubstanceLookAndFeel"); Class selectedSkinClass; if (guiLevel == SIMPLE_GUI) { selectedSkinClass = Class.forName("org.jvnet.substance.skin.BusinessBlackSteelSkin"); } else { @SuppressWarnings("unchecked") Map<String, Object> skinInfoMap = (Map<String, Object>) substance .getMethod("getAllSkins").invoke(null); List<String> skinClassNameArray = new ArrayList<String>(); for (Object object : skinInfoMap.values()) { String cn = (String) object.getClass().getMethod("getClassName").invoke(object); LOGGER.info("Adding substance skin class: " + cn); skinClassNameArray.add(cn); } int skinClassIdx = 0; if (guiLevel == SIMPLE_GUI) { skinClassIdx = 2; } else { skinClassIdx = new Random().nextInt(skinClassNameArray.size()); } LOGGER.info("Selected skin: " + skinClassNameArray.get(skinClassIdx)); selectedSkinClass = Class.forName(skinClassNameArray.get(skinClassIdx)); } // selectedSkinClass =Class.forName("org.jvnet.substance.skin.BusinessBlackSteelSkin"); javax.swing.UIManager .setLookAndFeel("org.jvnet.substance.skin.SubstanceBusinessLookAndFeel"); Class skinClass = Class.forName("org.jvnet.substance.api.SubstanceSkin"); @SuppressWarnings("unchecked") Method m = substance.getMethod("setSkin", skinClass); m.invoke(null, selectedSkinClass.newInstance()); JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); } catch (Exception ex) { LOGGER.error("Failed to set lf: " + ex.getMessage()); } } //resize borders from tabbedPane //TODO: needs refactoring - initPresentation, initL&F or sth like that try { UIManager.getDefaults().put("TabbedPane.contentBorderInsets", new Insets(4, 0, 0, 0)); } catch (Exception ex) { //this causes exception on MacOS X } try { visnow = new VisNow(); int argsCount = 0; for (int i = 0; i < args.length; i++) { if (!args[i].startsWith("-")) { argsCount++; } } String[] args2 = new String[argsCount]; int c = 0; for (int i = 0; i < args.length; i++) { if (!args[i].startsWith("-")) { args2[c++] = args[i]; } } visnow.init(args2); } catch (VNSystemException ex) { Displayer.display(1010101010, ex, null, "Initialization failed."); return; } visnow.initUserMessages(); } }); }