1 7 8 package org.enhydra.jawe.config; 9 10 11 12 import java.awt.*; 13 14 import javax.swing.*; 15 16 import org.enhydra.jawe.*; 17 18 public class CfgUI extends BaseConfigPane{ 19 20 private JComboBox looknFeel; 21 private JCheckBox tooltipStatus, 22 gridStatus, 23 statusBarStatus, 24 nameWrappingStatus, 25 wrappingStyleWordStatus; 26 private JTextField txtGridSize, txtFontSize; 27 28 private String [] lnfNames = { 29 "Metal", 30 "Motif", 31 "Windows", 32 "Native" 33 }; 34 35 private String [] lnfClassNames = { 36 "javax.swing.plaf.metal.MetalLookAndFeel", 37 "com.sun.java.swing.plaf.motif.MotifLookAndFeel", 38 "com.sun.java.swing.plaf.windows.WindowsLookAndFeel", 39 "" 40 }; 41 42 public CfgUI(String name){ 43 super(name); 44 45 looknFeel =new JComboBox(lnfNames); 46 addComponent("Config.UI.LnF.Label",looknFeel); 47 48 tooltipStatus = new JCheckBox(); 49 addComponent("Config.UI.Tooltip.Label",tooltipStatus); 50 51 nameWrappingStatus = new JCheckBox(); 52 addComponent("Config.UI.NameWrapping.Label",nameWrappingStatus); 53 54 wrappingStyleWordStatus = new JCheckBox(); 55 addComponent("Config.UI.WrappingStyleWord.Label",wrappingStyleWordStatus); 56 57 gridStatus = new JCheckBox(); 58 addComponent("Config.UI.Grid.Label",gridStatus); 59 60 statusBarStatus = new JCheckBox(); 61 addComponent("Config.UI.StatusBar.Label",statusBarStatus); 62 63 txtGridSize = new JTextField(); 64 addComponent("Config.UI.GridSize.Label",txtGridSize ); 65 66 txtFontSize = new JTextField(); 67 addComponent("Config.UI.FontSize.Label",txtFontSize ); 68 69 readConf(); 70 } 71 72 public void readConf(){ 73 looknFeel.setSelectedItem(lfClassNameToName()); 74 tooltipStatus.setSelected(JaWEConfig.getInstance().getTooltipStatus()); 75 nameWrappingStatus.setSelected(JaWEConfig.getInstance().getNameWrappingStatus()); 76 wrappingStyleWordStatus.setSelected(JaWEConfig.getInstance().getWrappingStyleWordStatus()); 77 gridStatus.setSelected(JaWEConfig.getInstance().getGridStatus()); 78 statusBarStatus.setSelected(JaWEConfig.getInstance().getStatusBarStatus()); 79 80 txtGridSize.setText( 81 Integer.toString(JaWEConfig.getInstance().getGridSize())); 82 txtFontSize.setText( 83 Float.toString(JaWEConfig.getInstance().getFontSize())); 84 85 } 86 87 public void save(){ 88 JaWEConfig.getInstance().setLookAndFeelClassName(lfNameToClassName()); 89 JaWEConfig.getInstance().setTooltipStatus(tooltipStatus.isSelected()); 90 JaWEConfig.getInstance().setNameWrappingStatus(nameWrappingStatus.isSelected()); 91 JaWEConfig.getInstance().setWrappingStyleWordStatus(wrappingStyleWordStatus.isSelected()); 92 JaWEConfig.getInstance().setGridStatus(gridStatus.isSelected()); 93 JaWEConfig.getInstance().setStatusBarStatus(statusBarStatus.isSelected()); 94 JaWEConfig.getInstance().setGridSize( 95 Integer.parseInt(txtGridSize.getText())); 96 JaWEConfig.getInstance().setFontSize( 97 Float.parseFloat(txtFontSize.getText())); 100 } 101 102 private String lfClassNameToName(){ 103 String lnfClassName = JaWEConfig.getInstance().getLookAndFeelClassName(); 104 for (int i=0; i<4; i++) { 105 if (lnfClassNames[i].equals(lnfClassName)) { 106 return lnfNames[i]; 107 } 108 } 109 return lnfNames[3]; 110 } 111 112 private String lfNameToClassName(){ 113 String lnfName=looknFeel.getSelectedItem().toString(); 114 for (int i=0; i<4; i++) { 115 if (lnfNames[i].equals(lnfName)) { 116 return lnfClassNames[i]; 117 } 118 } 119 return lnfClassNames[3]; 120 } 121 122 public Component getComponent(){ 123 return this; 124 } 125 } 126 127 | Popular Tags |