15 | 16 | ||
---|---|---|---|
2 | 2 | ||
3 | import java.awt.Color; | 3 | import java.awt.Color; |
4 | import java.awt.Dimension; | 4 | import java.awt.Dimension; |
5 | import java.awt.GridBagConstraints; | ||
6 | import java.awt.GridBagLayout; | ||
5 | import java.awt.GridLayout; | 7 | import java.awt.GridLayout; |
6 | import java.awt.Insets; | 8 | import java.awt.Insets; |
7 | import java.awt.event.ActionEvent; | 9 | import java.awt.event.ActionEvent; |
... | ... | ||
221 | { | 223 | { |
222 | // Init panel | 224 | // Init panel |
223 | this.statsPanel = new JPanel(); | 225 | this.statsPanel = new JPanel(); |
224 | //this.statsPanel.setLayout( new BoxLayout( this.statsPanel, BoxLayout.Y_AXIS ) ); | 226 | this.statsPanel.setLayout( new GridBagLayout() ); |
225 | 227 | GridBagConstraints c = new GridBagConstraints(); | |
226 | | 228 | |
229 | c.fill = GridBagConstraints.BOTH; | ||
230 | c.weightx = 1.0; | ||
231 | | ||
227 | // Init title | 232 | // Init title |
228 | TitledBorder title = BorderFactory.createTitledBorder( BorderFactory.createLineBorder( Color.black ), "Statistics") ; | 233 | TitledBorder title = BorderFactory.createTitledBorder( BorderFactory.createLineBorder( Color.black ), "Statistics") ; |
229 | title.setTitleJustification(TitledBorder.CENTER); | 234 | title.setTitleJustification(TitledBorder.CENTER); |
230 | this.statsPanel.setBorder(title); | 235 | this.statsPanel.setBorder(title); |
231 | 236 | ||
232 | this.pathLbl = new JLabel("Saisissez le chemin vers le fichier .csv: "); | 237 | this.pathLbl = new JLabel("Path to *.csv file: "); |
233 | this.pathTxt = new JTextField(20); | 238 | this.pathTxt = new JTextField(20); |
234 | this.browseButton = new JButton("Browse..."); | 239 | this.browseButton = new JButton("Browse..."); |
235 | this.browseButton.addActionListener( this ); | 240 | this.browseButton.addActionListener( this ); |
... | ... | ||
239 | this.generateStatsButton.addActionListener( this ); | 244 | this.generateStatsButton.addActionListener( this ); |
240 | this.generateStatsButton.setActionCommand( "stats" ); | 245 | this.generateStatsButton.setActionCommand( "stats" ); |
241 | 246 | ||
242 | this.decalageLbl = new JLabel("Saisissez le décalage souhaité:"); | 247 | this.decalageLbl = new JLabel("Shift input:"); |
243 | this.decalageTxt = new JTextField(2); | 248 | this.decalageTxt = new JTextField(2); |
244 | this.decalageTxt.setText("0"); | 249 | this.decalageTxt.setText("0"); |
245 | | 250 | |
246 | this.statsPanel.add(this.pathLbl); | 251 | JPanel fieldsHolderFile = new JPanel(); |
247 | this.statsPanel.add( this.pathTxt ); | 252 | fieldsHolderFile.setLayout( new GridLayout(2,0) ); |
253 | fieldsHolderFile.add(this.pathLbl); | ||
254 | fieldsHolderFile.add( this.pathTxt ); | ||
255 | | ||
256 | ((GridBagLayout)this.statsPanel.getLayout()).setConstraints(fieldsHolderFile, c); | ||
257 | this.statsPanel.add( fieldsHolderFile ); | ||
258 | |||
259 | // New row | ||
260 | c.gridwidth = GridBagConstraints.REMAINDER; | ||
261 | | ||
262 | ((GridBagLayout)this.statsPanel.getLayout()).setConstraints(this.browseButton, c); | ||
248 | this.statsPanel.add( this.browseButton ); | 263 | this.statsPanel.add( this.browseButton ); |
249 | this.statsPanel.add( this.decalageLbl ); | 264 | |
250 | this.statsPanel.add( this.decalageTxt ); | 265 | // Relative constraints and vertical padding |
266 | c.insets = new Insets(10,0,0,0); | ||
267 | c.gridwidth = GridBagConstraints.RELATIVE; | ||
268 | | ||
269 | JPanel fieldsHolderStat = new JPanel(); | ||
270 | fieldsHolderStat.setLayout( new GridLayout(2,0) ); | ||
271 | fieldsHolderStat.add(this.decalageLbl); | ||
272 | fieldsHolderStat.add( this.decalageTxt ); | ||
273 | | ||
274 | ((GridBagLayout)this.statsPanel.getLayout()).setConstraints(fieldsHolderStat, c); | ||
275 | this.statsPanel.add( fieldsHolderStat ); | ||
276 | ((GridBagLayout)this.statsPanel.getLayout()).setConstraints(this.generateStatsButton, c); | ||
251 | this.statsPanel.add( this.generateStatsButton ); | 277 | this.statsPanel.add( this.generateStatsButton ); |
252 | 278 | ||
253 | this.mainPanel.add( this.statsPanel ); | 279 | this.mainPanel.add( this.statsPanel ); |