KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > config > BaseConfigPane


1 /*
2  * Authors:
3  * Stefanovic Nenad chupo@iis.ns.ac.yu
4  * Bojanic Sasa sasaboy@neobee.net
5  *
6  */

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 JavaDoc name;
20    protected int y = 0;
21    protected GridBagLayout gridBag;
22
23    protected Map componentToPropertyFileEntry=new HashMap();
24
25    /**
26     * Constructor
27     */

28    public BaseConfigPane(String JavaDoc name){
29       this.name = name;
30       setLayout(gridBag =new GridBagLayout());
31       setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
32    }
33
34    public String JavaDoc getName(){
35       return name;
36    }
37
38    public Component getComponent(){
39       return this;
40    }
41
42    /**
43     * Adds a labeled component in the pane. All the components
44     * are placed on bottom of each other (vertically sorted).
45     * @param cfEntry The label to be displayed next to the component
46     * @param comp The component to be added
47     */

48    protected void addComponent(String JavaDoc 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.WEST;
60
cons.anchor = GridBagConstraints.EAST;
61       cons.fill = GridBagConstraints.HORIZONTAL;
62       //cons.fill = GridBagConstraints.NONE;
63

64       String JavaDoc 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       //cons.gridwidth = 1;
74

75       //cons.anchor = GridBagConstraints.EAST;
76
//cons.anchor = GridBagConstraints.WEST;
77

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 JavaDoc cfe=(String JavaDoc)me.getValue();
94          ((JLabel)c).setText(ResourceManager.getLanguageDependentString(cfe)+": ");
95       }
96    }
97
98 }
99
100
Popular Tags