codice:
package schedule.uI;
public class ShowUserData extends javax.swing.JFrame {
private ArrayList<String> datiUtente2=new ArrayList<String>();
private String name="";
private String surname="";
private String email="";
private String telufficio="";
private int iduser;
private JLabel jLabel2;
private JLabel jLabel5;
private JButton jButton4;
private JButton jButton1;
private JButton jButton3;
private JButton jButton2;
private JTextField Telufficio_text;
private JLabel jLabel6;
private JTextField Email_text;
private JTextField Surname_text;
private JTextField Name_text;
private JLabel jLabel1;
/**
* Questa interfaccia visualizza il profilo di un utente iscritto alla piattaforma.
* è fatta con jigloo e ha due parametri, un arrayList di stringhe
* contenente i dati di un utente e il suo id
*/
public void run(ArrayList<String> datiUtente, int id_user) {
ShowUserData inst = new ShowUserData(datiUtente,id_user);
inst.setLocationRelativeTo(null);
inst.setVisible(true);
};
public ShowUserData(ArrayList<String> datiUtente, int id_user) {
super("Schedule - Visualizza Profilo");
/**
* qui trasporta i dati dell'array nelle 4 stringhe e l'id user. Poi manda in esecuzione
*l'interfaccia che visualizzerà i dati nelle TxtField apposite
*/
datiUtente2=datiUtente;
name= datiUtente2.get(0);
surname=datiUtente2.get(1);
email=datiUtente2.get(2);
telufficio=datiUtente2.get(3);
iduser=id_user;
initGUI();
}
private void initGUI() {
try {
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
getContentPane().setLayout(null);
this.setResizable(false);
{
jLabel1 = new JLabel();
getContentPane().add(jLabel1);
jLabel1.setText("Nome");
jLabel1.setBounds(26, 109, 87, 25);
jLabel1.setFont(new java.awt.Font("Segoe UI",2,14));
jLabel1.setBorder(BorderFactory.createTitledBorder(""));
}
{
jLabel2 = new JLabel();
getContentPane().add(jLabel2);
jLabel2.setText("Cognome");
jLabel2.setBounds(24, 170, 90, 25);
jLabel2.setFont(new java.awt.Font("Segoe UI",2,14));
jLabel2.setBorder(BorderFactory.createTitledBorder(""));
}
{
Name_text = new JTextField();
getContentPane().add(Name_text);
Name_text.setBounds(112, 109, 210, 25);
Name_text.setBorder(BorderFactory.createTitledBorder(""));
Name_text.setText(name);
Name_text.setEditable(false);
}
{
Surname_text = new JTextField();
getContentPane().add(Surname_text);
Surname_text.setBounds(113, 170, 210, 25);
Surname_text.setBorder(BorderFactory.createTitledBorder(""));
Surname_text.setText(surname);
Surname_text.setEditable(false);
}
{
jLabel5 = new JLabel();
getContentPane().add(jLabel5);
jLabel5.setText("E-mail");
jLabel5.setBounds(403, 109, 118, 25);
jLabel5.setFont(new java.awt.Font("Segoe UI",2,14));
jLabel5.setBorder(BorderFactory.createTitledBorder(""));
}
{
Email_text = new JTextField();
getContentPane().add(Email_text);
Email_text.setBounds(520, 109, 210, 25);
Email_text.setBorder(BorderFactory.createTitledBorder(""));
Email_text.setText(email);
Email_text.setEditable(false);
}
{
jLabel6 = new JLabel();
getContentPane().add(jLabel6);
jLabel6.setText("Telefono Ufficio");
jLabel6.setBounds(403, 171, 118, 25);
jLabel6.setFont(new java.awt.Font("Segoe UI",2,14));
jLabel6.setBorder(BorderFactory.createTitledBorder(""));
}
{
Telufficio_text = new JTextField();
getContentPane().add(Telufficio_text);
Telufficio_text.setBounds(520, 171, 210, 25);
Telufficio_text.setBorder(BorderFactory.createTitledBorder(""));
Telufficio_text.setText(telufficio);
Telufficio_text.setEditable(false);
}
{
jButton1 = new JButton();
getContentPane().add(jButton1);
jButton1.setText("Modifica");
jButton1.setBounds(26, 27, 90, 59);
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
}
{
jButton2 = new JButton();
getContentPane().add(jButton2);
jButton2.setText("Salva");
jButton2.setBounds(133, 27, 86, 59);
jButton2.setEnabled(false);
}
{
jButton3 = new JButton();
getContentPane().add(jButton3);
jButton3.setText("Annulla");
jButton3.setBounds(240, 28, 82, 58);
jButton3.setEnabled(false);
jButton3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
}
{
jButton4 = new JButton();
getContentPane().add(jButton4);
jButton4.setText("Torna al menu");
jButton4.setBounds(31, 422, 222, 122);
jButton4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
}
addWindowListener(
new WindowAdapter(){
public void windowClosing(WindowEvent event) {
System.exit(0);
}
}
);
pack();
setSize(800, 600);
} catch (Exception e) {
e.printStackTrace();
}
}
private void jButton1ActionPerformed(ActionEvent evt) {
Name_text.setEditable(true);
Surname_text.setEditable(true);
Telufficio_text.setEditable(true);
Email_text.setEditable(true);
jButton3.setEnabled(true);
jButton2.setEnabled(true);
}
private void jButton3ActionPerformed(ActionEvent evt) {
Name_text.setEditable(false);
Surname_text.setEditable(false);
Telufficio_text.setEditable(false);
Email_text.setEditable(false);
jButton3.setEnabled(false);
jButton2.setEnabled(false);
//TODO add your code for jButton3.actionPerformed
}
private void jButton4ActionPerformed(ActionEvent evt) {
this.dispose();
new UserMenu().setVisible(true);
//TODO add your code for jButton4.actionPerformed
}
}