Revision 12592 trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/openfile/OpenFileContainer.java
OpenFileContainer.java | ||
---|---|---|
27 | 27 |
import javax.swing.JTextField; |
28 | 28 |
|
29 | 29 |
import org.gvsig.gui.beans.openfile.listeners.OpenFileListener; |
30 |
import org.gvsig.i18n.Messages; |
|
31 |
|
|
30 |
import org.gvsig.gui.beans.messages.Messages; |
|
31 |
/** |
|
32 |
* |
|
33 |
* @version 13/07/2007 |
|
34 |
*/ |
|
32 | 35 |
public class OpenFileContainer extends JPanel { |
33 | 36 |
private static final long serialVersionUID = 5823371652872582451L; |
34 | 37 |
private int wComp = 500, hComp = 55; |
35 | 38 |
private int wButton = 165; |
36 | 39 |
private int wText = (int)Math.floor(0.63 * wComp); |
37 | 40 |
private int hButton = 22; |
38 |
|
|
41 |
|
|
39 | 42 |
private JButton jButton = null; |
40 | 43 |
private JTextField tOpen = null; |
41 | 44 |
private OpenFileListener listener = null; |
42 |
|
|
45 |
|
|
43 | 46 |
private boolean isButtonVisible = true; |
44 |
|
|
47 |
|
|
45 | 48 |
public OpenFileContainer() { |
46 | 49 |
super(); |
47 | 50 |
listener = new OpenFileListener(this); |
48 | 51 |
initialize(); |
49 | 52 |
listener.setButton(this.getJButton()); |
50 | 53 |
} |
51 |
|
|
54 |
|
|
52 | 55 |
/** |
53 | 56 |
* Constructor |
54 | 57 |
* @param WIDTH |
... | ... | |
65 | 68 |
this.hComp = HEIGHT; |
66 | 69 |
listener = new OpenFileListener(this); |
67 | 70 |
initialize(); |
68 |
listener.setButton(this.getJButton());
|
|
71 |
listener.setButton(this.getJButton()); |
|
69 | 72 |
} |
70 | 73 |
|
71 | 74 |
/** |
72 | 75 |
* This method initializes this |
73 |
*
|
|
76 |
* |
|
74 | 77 |
*/ |
75 | 78 |
private void initialize() { |
76 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
|
|
77 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
|
|
78 |
gridBagConstraints1.gridx = 1;
|
|
79 |
gridBagConstraints1.gridy = 0;
|
|
80 |
gridBagConstraints1.weightx = 10.0;
|
|
81 |
gridBagConstraints1.insets = new java.awt.Insets(0,2,0,0);
|
|
82 |
GridBagConstraints gridBagConstraints = new GridBagConstraints();
|
|
83 |
gridBagConstraints.insets = new java.awt.Insets(0,0,0,2);
|
|
84 |
gridBagConstraints.gridy = 0;
|
|
85 |
gridBagConstraints.gridx = 0;
|
|
86 |
gridBagConstraints.weightx = 1.0;
|
|
87 |
this.setLayout(new GridBagLayout());
|
|
88 |
this.setSize(new java.awt.Dimension(500,50));
|
|
89 |
this.setBorder(javax.swing.BorderFactory.createTitledBorder(null, Messages.getText("open_file"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
|
|
90 |
this.add(getJButton(), gridBagConstraints);
|
|
91 |
this.add(getTOpen(), gridBagConstraints1);
|
|
92 |
|
|
79 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
|
|
80 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
|
|
81 |
gridBagConstraints1.gridx = 1;
|
|
82 |
gridBagConstraints1.gridy = 0;
|
|
83 |
gridBagConstraints1.weightx = 10.0;
|
|
84 |
gridBagConstraints1.insets = new java.awt.Insets(0,2,0,0);
|
|
85 |
GridBagConstraints gridBagConstraints = new GridBagConstraints();
|
|
86 |
gridBagConstraints.insets = new java.awt.Insets(0,0,0,2);
|
|
87 |
gridBagConstraints.gridy = 0;
|
|
88 |
gridBagConstraints.gridx = 0;
|
|
89 |
gridBagConstraints.weightx = 1.0;
|
|
90 |
this.setLayout(new GridBagLayout());
|
|
91 |
this.setSize(new java.awt.Dimension(500,50));
|
|
92 |
this.setBorder(javax.swing.BorderFactory.createTitledBorder(null, Messages.getText("open_file"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
|
|
93 |
this.add(getJButton(), gridBagConstraints);
|
|
94 |
this.add(getTOpen(), gridBagConstraints1);
|
|
95 |
|
|
93 | 96 |
} |
94 | 97 |
|
95 | 98 |
/** |
96 |
* This method initializes jButton
|
|
97 |
*
|
|
98 |
* @return javax.swing.JButton
|
|
99 |
* This method initializes jButton |
|
100 |
* |
|
101 |
* @return javax.swing.JButton |
|
99 | 102 |
*/ |
100 | 103 |
private JButton getJButton() { |
101 | 104 |
if (jButton == null) { |
... | ... | |
111 | 114 |
} |
112 | 115 |
|
113 | 116 |
/** |
114 |
* This method initializes jTextField
|
|
115 |
*
|
|
116 |
* @return javax.swing.JTextField
|
|
117 |
* This method initializes jTextField |
|
118 |
* |
|
119 |
* @return javax.swing.JTextField |
|
117 | 120 |
*/ |
118 | 121 |
public JTextField getTOpen() { |
119 | 122 |
if (tOpen == null) { |
... | ... | |
126 | 129 |
} |
127 | 130 |
return tOpen; |
128 | 131 |
} |
129 |
|
|
132 |
|
|
130 | 133 |
/** |
131 | 134 |
* Pone el texto que le pasamos como texto del borde del panel. |
132 | 135 |
* @param text |
... | ... | |
136 | 139 |
this.borderText = text; |
137 | 140 |
} |
138 | 141 |
*/ |
139 |
|
|
140 |
|
|
142 |
|
|
143 |
|
|
141 | 144 |
public void setComponentSize(int w, int h){ |
142 | 145 |
wComp = w; |
143 | 146 |
hComp = 55; |
144 | 147 |
wText = (int)Math.floor(0.63 * wComp); |
145 |
|
|
148 |
|
|
146 | 149 |
this.setPreferredSize(new java.awt.Dimension(wComp, hComp)); |
147 | 150 |
if (isButtonVisible){ |
148 | 151 |
this.getTOpen().setPreferredSize(new java.awt.Dimension(wText, hButton)); |
... | ... | |
150 | 153 |
this.getTOpen().setPreferredSize(new java.awt.Dimension((int)Math.floor(wComp * 0.95), hButton)); |
151 | 154 |
} |
152 | 155 |
} |
153 |
|
|
154 | 156 |
|
157 |
|
|
155 | 158 |
/** |
156 | 159 |
* Devuelve el file cuya ruta corresponde con el campo de texto. |
157 | 160 |
* @return |
... | ... | |
167 | 170 |
} |
168 | 171 |
return fil; |
169 | 172 |
} |
170 |
|
|
173 |
|
|
171 | 174 |
} |
Also available in: Unified diff