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
|
import javax.swing.*;
import java.awt.*; // Pour locate Flow
import java.awt.event.*;
import javax.swing.event.*;
import java.io.*;
class Interface extends JFrame implements ActionListener, ItemListener, FocusListener
{
private String dfname;
private String mshname;
private JButton LoadMSH,Run; // Bouton
private ButtonGroup choix; // Groupe d'éléments
private JRadioButton radio1,radio2,radio3;
private JLabel lab1,lab2,lab3;
private JTextField entre1,entre2,entre3;
private JComboBox unitmsr1,unitmsr2,unitmsr3;
private String[] vitess={"km^3/jour","m^3/jour","km^3/h","m^3/h","km^3/min","m^3/min","km^3/s","m^3/s"};
private String[] cdiff={"km^2/jour","m^2/jour","km^2/h","m^2/h","km^2/min","m^2/min","km^2/s","m^2/s"};
public Interface(String FileName)
{
// Caractéristique de la fenetre
super();
super.setSize (700,500);
super.setTitle ("Interface");
super.setVisible(true);
// Nom du fichier à créer
dfname=FileName;
MonInter();
}
public void MonInter()
{
System.out.println("OK 1");
// Elements
Container contenu = getContentPane(); // Contenu
contenu.setLayout (new GridBagLayout()); // unitmsrjout du gestionnaire d'Element
ButtonGroup choix = new ButtonGroup(); // Groupe de Bouton
System.out.println("OK 2");
System.out.println("OK 3");
System.out.println("OK 4");
GridBagConstraints c= new GridBagConstraints();
c.fill = GridBagConstraints.NONE; //Horizontal
System.out.println("OK 5");
c.gridx=1; c.gridy=1; c.gridwidth=1; c.gridheight=1; c.weightx=1; c.weighty=1;
LoadMSH = new JButton ("Load Mesh");
contenu.add(LoadMSH,c);
System.out.println("OK 6");
c.gridx=2; c.gridy=1;
Run = new JButton ("Run Job");
contenu.add(Run,c);
System.out.println("OK 7");
radio1 = new JRadioButton ("Calcul direct", true);
radio2 = new JRadioButton ("Sens par DF", false);
radio3 = new JRadioButton ("DO", false);
choix.add(radio1);
choix.add(radio2);
choix.add(radio3);
System.out.println("OK 8");
c.gridx=1; c.gridy=2;
contenu.add(radio1,c);
c.gridx=2; c.gridy=2;
contenu.add(radio2,c);
c.gridx=3; c.gridy=2;
contenu.add(radio3,c);
System.out.println("OK 9");
lab1= new JLabel ("Flux 1");
lab2= new JLabel ("Flux 2");
lab3= new JLabel ("Valeur");
c.gridx=1; c.gridy=3;
contenu.add(lab1,c);
c.gridx=1; c.gridy=4;
contenu.add(lab2,c);
c.gridx=1; c.gridy=5;
contenu.add(lab3,c);
System.out.println("OK 10");
entre1= new JTextField ("0.1",7);
entre2= new JTextField ("0.1",7);
entre3= new JTextField ("0.1",7);
c.gridx=2; c.gridy=3;// c.insets = new Insets(0,15,0,10); (avec ou sans insets ca ne change rien) !!!//c.fill = GridBagConstraints.HORIZONTAL; //Horizontal
contenu.add(entre1,c);
c.gridx=2; c.gridy=4;
contenu.add(entre2,c);
c.gridx=2; c.gridy=5;
contenu.add(entre3,c);
unitmsr1 = new JComboBox(vitess);
unitmsr2 = new JComboBox(vitess);
unitmsr3 = new JComboBox(cdiff);
unitmsr1.setSelectedIndex (0);
unitmsr2.setSelectedIndex (0);
unitmsr3.setSelectedIndex (0);
unitmsr1.addActionListener (this);
unitmsr1.addItemListener (this);
unitmsr2.addActionListener (this);
unitmsr2.addItemListener (this);
unitmsr3.addActionListener (this);
unitmsr3.addItemListener (this);
c.gridx=3; c.gridy=3;
contenu.add(unitmsr1,c);
c.gridx=3; c.gridy=4;
contenu.add(unitmsr2,c);
c.gridx=3; c.gridy=5;
contenu.add(unitmsr3,c);
System.out.println("OK 11");
} |
Partager