1 7 8 package org.enhydra.jawe.config; 9 10 import javax.swing.*; 11 import java.awt.*; 12 import java.util.*; 13 14 import org.enhydra.jawe.*; 15 16 17 public class BaseConfigPane extends JPanel{ 18 19 private String name; 20 protected int y = 0; 21 protected GridBagLayout gridBag; 22 23 protected Map componentToPropertyFileEntry=new HashMap(); 24 25 28 public BaseConfigPane(String name){ 29 this.name = name; 30 setLayout(gridBag =new GridBagLayout()); 31 setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 32 } 33 34 public String getName(){ 35 return name; 36 } 37 38 public Component getComponent(){ 39 return this; 40 } 41 42 48 protected void addComponent(String cfEntry, Component comp){ 49 GridBagConstraints cons = new GridBagConstraints(); 50 51 cons.gridy = y++; 52 cons.gridx = 0; 53 54 cons.gridheight = 1; 55 cons.gridwidth = 1; 56 57 cons.weightx = 1.0f; 58 59 cons.anchor = GridBagConstraints.EAST; 61 cons.fill = GridBagConstraints.HORIZONTAL; 62 64 String label=ResourceManager.getLanguageDependentString(cfEntry)+": "; 65 JLabel l = new JLabel(label, SwingConstants.RIGHT); 66 componentToPropertyFileEntry.put(l,cfEntry); 67 68 gridBag.setConstraints(l, cons); 69 add(l); 70 71 cons.gridx = 1; 72 73 75 78 gridBag.setConstraints(comp, cons); 79 add(comp); 80 } 81 82 public void save(){ 83 } 84 85 public void readConf(){ 86 } 87 88 public void refreshLanguageDependentStrings () { 89 Iterator it=componentToPropertyFileEntry.entrySet().iterator(); 90 while (it.hasNext()) { 91 Map.Entry me=(Map.Entry)it.next(); 92 Component c=(Component)me.getKey(); 93 String cfe=(String )me.getValue(); 94 ((JLabel)c).setText(ResourceManager.getLanguageDependentString(cfe)+": "); 95 } 96 } 97 98 } 99 100 | Popular Tags |