1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
|
public class Fenetre extends JFrame implements ActionListener {
private JPanel pan = new JPanel();
private JPanel pan1 = new JPanel();
private JPanel pan2 = new JPanel();
private JPanel pan3 = new JPanel();
private JPanel pan4 = new JPanel();
private JPanel pan5 = new JPanel();
private JPanel pan6 = new JPanel();
private JPanel pan7 = new JPanel();
private JPanel pan8 = new JPanel();
private JPanel pan9 = new JPanel();
private JPanel pan10 = new JPanel();
private JPanel pan11 = new JPanel();
private JPanel pan12 = new JPanel();
private JPanel pan13 = new JPanel();
private JButton bouton; private JButton bouton2; private JButton bouton3; private JButton bouton4;
private JButton bouton5; private JButton bouton6; private JButton bouton7; private JButton bouton8;
private JButton bouton9; private JButton bouton10; JButton bouton11;
private JTextField jtx; private JTextField jtx2; private JTextField jtx3; private JTextField jtx4;
private JTextField jtx5; private JTextField jtx6; private JTextField jtx7; private JTextField jtx8;
private JTextField jtx9;
private JLabel label; private JLabel label2; private JLabel label3; private JLabel label4;
private JLabel label5; private JLabel label6; private JLabel label7; private JLabel label8;
private JLabel label9;
private JComboBox<String> combo;
private JComboBox<String> combo2;
private File document;
//Fenetre pop up
private JOptionPane jop1;
private JLabel lab;
public Fenetre() throws IOException{
//Fenetre principal
setTitle("Logiciel");
setSize(400, 600);
setResizable(true);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jop1 = new JOptionPane();
lab = new JLabel("Mass=");
pan.setLayout(new GridLayout(12,1));
bouton = new JButton("Folder Test");
bouton.addActionListener(new BoutonListener());
bouton2 = new JButton("Nome Dati");
bouton2.addActionListener(new Bouton2Listener());
bouton3 = new JButton("NomeSpeedMinMax");
bouton3.addActionListener(new Bouton3Listener());
label = new JLabel("Col Speed Min Max");
jtx = new JTextField("_");
jtx.setPreferredSize(new Dimension(30, 20));
jtx2 = new JTextField("_");
jtx2.setPreferredSize(new Dimension(30, 20));
bouton4 = new JButton("Ok");
bouton4.addActionListener(new Bouton4Listener());
label2 = new JLabel("SpeedFricoCol");
jtx3 = new JTextField("_");
jtx3.setPreferredSize(new Dimension(30, 20));
jtx4 = new JTextField("_");
jtx4.setPreferredSize(new Dimension(30, 20));
bouton5 = new JButton("Ok");
bouton5.addActionListener(new Bouton5Listener());
label3 = new JLabel("Sampling");
combo = new JComboBox<String>();
combo.addItem("1");
combo.addItem("2");
bouton6 = new JButton("Ok");
bouton6.addActionListener(new Bouton6Listener());
bouton7 = new JButton("Export Data");
bouton7.addActionListener(new Bouton7Listener());
label4 = new JLabel("Name Data");
jtx5 = new JTextField();
jtx5.setPreferredSize(new Dimension(30, 20));
label6= new JLabel("Number of Mass Level");
jtx6 = new JTextField();
jtx6.setPreferredSize(new Dimension(30, 20));
bouton10 = new JButton("Ok");
bouton10.addActionListener(new Bouton6Listener());
label7= new JLabel("Mass Level =");
jtx7 = new JTextField();
jtx7.setPreferredSize(new Dimension(30, 20));
bouton11 = new JButton("Ok");
bouton11.addActionListener(new Bouton6Listener());
label8= new JLabel("Number of Normal Force");
jtx8 = new JTextField();
jtx8.setPreferredSize(new Dimension(30, 20));
label9= new JLabel("Normal Force =");
jtx9 = new JTextField();
jtx9.setPreferredSize(new Dimension(30, 20));
label5 = new JLabel("Method");
bouton8 = new JButton("OneLaw");
bouton8.addActionListener(new Bouton8Listener());
bouton9 = new JButton("MoreLaw");
bouton9.addActionListener(new Bouton9Listener());
pan.add(pan1);
pan.add(pan2);
pan.add(pan3);
pan.add(pan4);
pan.add(pan5);
pan.add(pan6);
pan.add(pan7);
pan.add(pan8);
pan.add(pan9);
pan.add(pan10);
pan.add(pan11);
pan.add(pan12);
pan1.add(bouton);
pan2.add(bouton2);
pan3.add(bouton3);
pan4.add(label);
pan4.add(jtx);
pan4.add(jtx2);
pan4.add(bouton4);
pan5.add(label2);
pan5.add(jtx3);
pan5.add(jtx4);
pan5.add(bouton5);
pan6.add(label3);
pan6.add(combo);
pan6.add(bouton6);
pan7.add(bouton7);
pan8.add(label4);
pan8.add(jtx5);
pan9.add(label6);
pan9.add(jtx6);
pan9.add(bouton10);
pan10.add(label7);
pan10.add(jtx7);
pan11.add(label8);
pan11.add(jtx8);
pan13.add(label9);
pan13.add(jtx9);
pan12.add(label5);
pan12.add(bouton8);
pan12.add(bouton9);
setContentPane(pan);
setVisible(true);
/* pan2.setVisible(false);
pan3.setVisible(false);
pan4.setVisible(false);
pan5.setVisible(false);
pan6.setVisible(false);
pan7.setVisible(false);
pan8.setVisible(false);
pan9.setVisible(false); */
}
//Bouton Folder Test
class BoutonListener implements ActionListener{
public void actionPerformed(ActionEvent e) {
//Permet d'aller chercher un dossier dans une fenetre explorer
JFileChooser choix = new JFileChooser();
choix.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int retour = choix.showOpenDialog(bouton);
if(retour == JFileChooser.APPROVE_OPTION)
choix.getSelectedFile();
String t =choix.getSelectedFile().getAbsolutePath();
try {
folderTest(t);
} catch (IOException e1) {
e1.printStackTrace();
}
pan2.setVisible(true);
}
public void folderTest (String name) throws IOException{
File fichier = new File("C:\\Users\\Flo\\workspace\\TrainDy\\monfichier.txt");
document=fichier;
FileWriter ffw = new FileWriter(fichier);
ffw.write("FolderTest='" + name + "'");
ffw.close();
}
}
//Bouton Nome Dati
class Bouton2Listener implements ActionListener{
public void actionPerformed(ActionEvent e){
JFileChooser choix = new JFileChooser();
choix.setFileSelectionMode(JFileChooser.FILES_ONLY);
int retour = choix.showOpenDialog(bouton2);
if(retour == JFileChooser.APPROVE_OPTION)
choix.getSelectedFile();
String t =choix.getSelectedFile().getAbsolutePath();
try {
nomeDati(t,document);
} catch (IOException e1) {
e1.printStackTrace();
}
pan3.setVisible(true);
}
public void nomeDati (String name, File fichier) throws IOException{
BufferedWriter bufferedwriter = new BufferedWriter (new FileWriter (fichier, true));
String texte="Nome Dati='" + name + ",";
bufferedwriter.newLine();
bufferedwriter.write(texte);
bufferedwriter.close();
}
}
//Bouton Nome Speed MAx Min
class Bouton3Listener implements ActionListener{
public void actionPerformed(ActionEvent e){
JFileChooser choix = new JFileChooser();
choix.setFileSelectionMode(JFileChooser.FILES_ONLY);
int retour = choix.showOpenDialog(bouton2);
if(retour == JFileChooser.APPROVE_OPTION)
choix.getSelectedFile();
String t =choix.getSelectedFile().getAbsolutePath();
try {
NomeSpeedMinMax(t,document);
} catch (IOException e1) {
e1.printStackTrace();
}
pan4.setVisible(true);
}
public void NomeSpeedMinMax (String name, File fichier) throws IOException{
BufferedWriter bufferedwriter = new BufferedWriter (new FileWriter (fichier, true));
String texte="NomeSpeedMinMax= " + name + ",";
bufferedwriter.newLine();
bufferedwriter.write(texte);
bufferedwriter.close();
}
}
class Bouton4Listener implements ActionListener{
public void actionPerformed(ActionEvent e) {
String valeur = jtx.getText()+";"+jtx2.getText();
try {
ColSpeedMinMax (valeur, document) ;
} catch (IOException e1) {
e1.printStackTrace();
}
pan5.setVisible(true);
}
public void ColSpeedMinMax (String name, File fichier) throws IOException{
try(BufferedWriter bufferedwriter = Files.newBufferedWriter(fichier.toPath(), StandardOpenOption.APPEND)) {
String texte = "ColSpeedMinMax= " + name;
bufferedwriter.newLine();
bufferedwriter.write(texte);
}
}
}
class Bouton5Listener implements ActionListener{
public void actionPerformed(ActionEvent e) {
String valeur = jtx3.getText()+";"+jtx4.getText();
try {
SpeedFricoCol (valeur, document) ;
} catch (IOException e1) {
e1.printStackTrace();
}
pan6.setVisible(true);
}
public void SpeedFricoCol (String name, File fichier) throws IOException{
try(BufferedWriter bufferedwriter = Files.newBufferedWriter(fichier.toPath(), StandardOpenOption.APPEND)) {
String texte = "SpeedFricoCol : " + name;
bufferedwriter.newLine();
bufferedwriter.write(texte);
}
}
}
class Bouton6Listener implements ActionListener{
public void actionPerformed(ActionEvent e) {
String valeur = combo.getSelectedItem()+";";
try {
SamplingSpeedFromExperimentalData (valeur, document) ;
} catch (IOException e1) {
e1.printStackTrace();
}
pan7.setVisible(true);
}
public void SamplingSpeedFromExperimentalData (String name, File fichier) throws IOException{
try(BufferedWriter bufferedwriter = Files.newBufferedWriter(fichier.toPath(), StandardOpenOption.APPEND)) {
String texte = "SamplingSpeedFromExperimentalData=" + name;
bufferedwriter.newLine();
bufferedwriter.write(texte);
}
}
}
class Bouton7Listener implements ActionListener{
public void actionPerformed(ActionEvent e) {
JFileChooser choix = new JFileChooser();
choix.setFileSelectionMode(JFileChooser.FILES_ONLY);
int retour = choix.showOpenDialog(bouton2);
if(retour == JFileChooser.APPROVE_OPTION)
choix.getSelectedFile();
String t =choix.getSelectedFile().getAbsolutePath();
try {
ExportData(t,document);
} catch (IOException e1) {
e1.printStackTrace();
}
pan8.setVisible(true);
}
public void ExportData (String name, File fichier) throws IOException{
BufferedWriter bufferedwriter = new BufferedWriter (new FileWriter (fichier, true));
String texte="Export Data= " + name;
bufferedwriter.newLine();
bufferedwriter.write(texte);
bufferedwriter.close();
}
}
class Bouton8Listener implements ActionListener{
public void actionPerformed(ActionEvent e) {
Fenetre2 fen2 = new Fenetre2();
fen2.setVisible(true);
}
}
public void actionPerformed(ActionEvent e) {
}
}
class Bouton9Listener implements ActionListener{
public void actionPerformed(ActionEvent e) {
Fenetre3 fen3 = new Fenetre3();
fen3.setVisible(true);
}
class Bouton10Listener implements ActionListener{
public void actionPerformed(ActionEvent e) {
}
}
} |
Partager