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
| public class CommutateurGUI {
JFrame fenetre;
JButton button1;
JTextArea input;
JTextArea screen;
JTextField nom;
Assembleur a;
public CommutateurGUI(File file_input, Assembleur a) {
fenetre = new JFrame("Commutateur");
button1 = new JButton("Assembler");
button1.addActionListener(new ActionButton1(this));
input = new JTextArea();
screen = new JTextArea();
assembleur = a;
Scanner scan;
try {
scan = new Scanner(file_input);
while (scan.hasNextLine()) {
while (scan.hasNextInt()) {
Integer key = scan.nextInt();
input.append(key.toString() + "");
}
input.append("\n");
}
} catch (FileNotFoundException e) {
System.out.println("File "
+ file_input.getAbsolutePath()
+ " could not be found on filesystem");
}
Container contenu = fenetre.getContentPane();
contenu.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.weightx = 1;
gbc.gridx = 0;
gbc.gridy = 1;
gbc.insets = new Insets(10, 15, 10, 15);
contenu.add(button1, gbc);
GridBagConstraints gbcscreen = new GridBagConstraints();
gbcscreen.gridy = 0;
gbcscreen.weighty = 1;
gbcscreen.gridx = 3;
gbcscreen.anchor = GridBagConstraints.LINE_END;
gbcscreen.insets = new Insets(10, 15, 10, 150);
contenu.add(screen, gbcscreen);
GridBagConstraints gbcinput = new GridBagConstraints();
gbcinput.gridy = 0;
gbcinput.weighty = 1;
gbcinput.gridx = 0;
gbcinput.anchor = GridBagConstraints.LINE_START;
gbcinput.insets = new Insets(10, 150, 10, 15);
contenu.add(input, gbcinput);
fenetre.pack();
fenetre.setVisible(true);
}
public static void main(File args, Assembleur a) {
new CommutateurGUI(args,a);
}
}
class ActionButton1 implements ActionListener {
private CommutateurGUI vue;
public ActionButton1(CommutateurGUI c) {
vue = c;
}
public void actionPerformed(ActionEvent button1) {
vue.screen.append("Paquet assemble : ");
file_input.assembler();
//Et la suite... c'est pas le propos ici ^^
}
} |
Partager