0% found this document useful (0 votes)
39 views

Serialversionuid Contentpane Endereco Endereco Liberado Btnmandar

This document contains the code for a Java class called MigrationGui. MigrationGui creates a graphical user interface (GUI) that allows a user to enter an address into a text field and click a button. When the button is clicked, it retrieves the address from the text field, sets a variable to indicate it is ready, and updates a label with information from an agent object. The GUI is created and displayed in the main method.

Uploaded by

Álvaro Peres
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Serialversionuid Contentpane Endereco Endereco Liberado Btnmandar

This document contains the code for a Java class called MigrationGui. MigrationGui creates a graphical user interface (GUI) that allows a user to enter an address into a text field and click a button. When the button is clicked, it retrieves the address from the text field, sets a variable to indicate it is ready, and updates a label with information from an agent object. The GUI is created and displayed in the main method.

Uploaded by

Álvaro Peres
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

MigrationGui.

java

1 package Migration;
2 import java.awt.EventQueue;
3 import javax.swing.JFrame;
4 import javax.swing.JPanel;
5 import javax.swing.border.EmptyBorder;
6 import jade.core.Agent;
7 import java.awt.Color;
8 import javax.swing.JLabel;
9 import javax.swing.JTextField;
10 import javax.swing.JButton;
11 import java.awt.event.ActionListener;
12 import java.awt.event.ActionEvent;
13 import java.awt.event.WindowAdapter;
14 import java.awt.event.WindowEvent;
15 public class MigrationGui extends JFrame {
16 private static final long serialVersionUID = 1L;
17 private JPanel contentPane;
18 public JTextField Endereco;
19 public String endereco;
20 public int liberado=0;
21 public JButton btnMandar;
22 /**
23 * Launch the application.
24 */
25 public static void main(String[] args) {
26 EventQueue.invokeLater(new Runnable() {
27 public void run() {
28 try {
29 MigrationGui frame = new MigrationGui(null);
30 frame.setVisible(true);
31 } catch (Exception e) {
32 e.printStackTrace();
33 System.out.println("Fechou");
34 }
35 }
36 });
37 }
38 public MigrationGui(Agent agent) {
39
40 addWindowListener(new WindowAdapter() {
41 @Override
42 public void windowClosed(WindowEvent arg0) {
43 agent.doDelete();
44 }
45 });
46 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
47
48 setTitle(agent.getLocalName());
49 setBounds(100, 100, 209, 148);
50 contentPane = new JPanel();
51 contentPane.setBackground(Color.WHITE);
52 contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
53 setContentPane(contentPane);
54 contentPane.setLayout(null);
55
56 JLabel lblEndereo = new JLabel("Endere\u00E7o");
57 lblEndereo.setBounds(10, 11, 65, 14);
58 contentPane.add(lblEndereo);
59
60 Endereco = new JTextField();
61 Endereco.setBounds(97, 8, 86, 20);
62 contentPane.add(Endereco);

Page 1
MigrationGui.java

63 Endereco.setColumns(10);
64
65 JLabel lblOrigem = new JLabel("Origem");
66 lblOrigem.setBounds(10, 72, 46, 14);
67 contentPane.add(lblOrigem);
68
69 JLabel lblNewLabel = new JLabel("");
70 lblNewLabel.setBounds(66, 72, 117, 26);
71 contentPane.add(lblNewLabel);
72
73 btnMandar = new JButton("Mandar");
74 btnMandar.addActionListener(new ActionListener() {
75 public void actionPerformed(ActionEvent arg0) {
76 endereco = Endereco.getText();
77 liberado = 1;
78 lblNewLabel.setText(agent.getHap());
79 }
80 });
81 btnMandar.setBounds(94, 39, 89, 23);
82 contentPane.add(btnMandar);
83 }
84 }

Page 2

You might also like