Java Reference
In-Depth Information
107. public void setNation(Nation nation){
108. countryChooser.setSelectedItem(nation);
109. }
110.
111. private class WindowCloseManager extends WindowAdapter{
112. public void windowClosing(WindowEvent evt){
113. exitApplication();
114. }
115. }
116.
117. private void exitApplication(){
118. System.exit(0);
119. }
120. }
The class DataCreator produces a set of InternationalizedText objects to use in this example.
Example A.169 DataCreator.java
1. import java.util.Properties;
2. import java.io.IOException;
3. import java.io.FileOutputStream;
4. public class DataCreator{
5. private static final String GUI_TITLE = "title";
6. private static final String EXIT_CAPTION = "exit";
7. private static final String COUNTRY_LABEL = "country";
8. private static final String CURRENCY_LABEL = "currency";
9. private static final String PHONE_LABEL = "phone";
10.
11. public static void serialize(String fileName){
12. saveFrData();
13. saveUsData();
14. saveNlData();
15. }
16.
17. private static void saveFrData(){
18. try{
19. Properties textSettings = new Properties();
20. textSettings.setProperty(GUI_TITLE, "Demonstration du Pattern Facade");
21. textSettings.setProperty(EXIT_CAPTION, "Sortir");
22. textSettings.setProperty(COUNTRY_LABEL, "Pays");
23. textSettings.setProperty(CURRENCY_LABEL, "Monnaie");
24. textSettings.setProperty(PHONE_LABEL, "Numero de Telephone");
25. textSettings.store(new FileOutputStream("french.properties"), "French Settings");
26. }
27. catch (IOException exc){
28. System.err.println("Error storing settings to output");
29. exc.printStackTrace();
30. }
31. }
32. private static void saveUsData(){
33. try{
34. Properties textSettings = new Properties();
35. textSettings.setProperty(GUI_TITLE, "Facade Pattern Demonstration");
36. textSettings.setProperty(EXIT_CAPTION, "Exit");
37. textSettings.setProperty(COUNTRY_LABEL, "Country");
38. textSettings.setProperty(CURRENCY_LABEL, "Currency");
39. textSettings.setProperty(PHONE_LABEL, "Phone Number");
40. textSettings.store(new FileOutputStream("us.properties"), "US Settings");
41. }
42. catch (IOException exc){
43. System.err.println("Error storing settings to output");
44. exc.printStackTrace();
45. }
46. }
47. private static void saveNlData(){
48. try{
49. Properties textSettings = new Properties();
50. textSettings.setProperty(GUI_TITLE, "Facade Pattern voorbeeld");
51. textSettings.setProperty(EXIT_CAPTION, "Exit");
52. textSettings.setProperty(COUNTRY_LABEL, "Land");
53. textSettings.setProperty(CURRENCY_LABEL, "Munt eenheid");
54. textSettings.setProperty(PHONE_LABEL, "Telefoonnummer");
55. textSettings.store(new FileOutputStream("dutch.properties"), "Dutch Settings");
56. }
57. catch (IOException exc){
58. System.err.println("Error storing settings to output");
59. exc.printStackTrace();
Search WWH ::




Custom Search