import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JTextField;
import javax.swing.JSeparator;
import javax.swing.JPasswordField;
import javax.swing.JButton;
import Classi.Controller;
public class Login extends JFrame implements ActionListener {
private static final long serialVersionUID = 1L;
private JFrame frame;
private JTextField TextFild_InserisciEmail;
private JPasswordField Password;
protected Object frame1;
Controller ctrl;
public Login(final Controller ctrl) {
frame = new JFrame();
frame.getContentPane().setBackground(new Color(255, 165, 0));
frame.setResizable(false);
frame.setBounds(100, 100, 747, 504);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
setSize(new Dimension(747,504));
this.ctrl=ctrl;
JPanel panel = new JPanel();
panel.setBounds(0, 0, 581, 482);
frame.getContentPane().add(panel);
panel.setLayout(null);
JLabel lblNewLabel = new JLabel("");
lblNewLabel.setIcon(new ImageIcon(Login.class.getResource("/Accesso/iconaAccesso.jpg")));
lblNewLabel.setBounds(0, 0, 581, 482);
panel.add(lblNewLabel);
JLabel Label_Food = new JLabel("Food");
Label_Food.setForeground(new Color(255, 255, 255));
Label_Food.setFont(new Font("Kohinoor Devanagari", Font.BOLD, 35));
Label_Food.setBounds(621, 64, 92, 63);
frame.getContentPane().add(Label_Food);
JLabel Label_Email = new JLabel("E-mail");
Label_Email.setForeground(new Color(255, 255, 255));
Label_Email.setBounds(593, 162, 61, 16);
frame.getContentPane().add(Label_Email);
JLabel Label_Password = new JLabel("Password");
Label_Password.setForeground(new Color(255, 255, 255));
Label_Password.setBounds(593, 220, 61, 16);
frame.getContentPane().add(Label_Password);
JSeparator separator = new JSeparator();
separator.setForeground(new Color(0, 0, 0));
separator.setBounds(593, 196, 138, 12);
frame.getContentPane().add(separator);
TextFild_InserisciEmail = new JTextField();
TextFild_InserisciEmail.setVisible(false);
TextFild_InserisciEmail.setFont(new Font("Times New Roman", Font.ITALIC, 14));
TextFild_InserisciEmail.setDisabledTextColor(new Color(0, 0, 0));
TextFild_InserisciEmail.setForeground(new Color(0, 0, 0));
TextFild_InserisciEmail.setSelectionColor(new Color(192, 192, 192));
TextFild_InserisciEmail.setText("Inserisci E-mail");
TextFild_InserisciEmail.setBackground(new Color(255, 165, 0));
TextFild_InserisciEmail.setBorder(null);
TextFild_InserisciEmail.setBounds(593, 185, 148, 16);
frame.getContentPane().add(TextFild_InserisciEmail);
TextFild_InserisciEmail.setColumns(10);
Password = new JPasswordField();
Password.setText("123456789");
Password.setBackground(new Color(255, 165, 0));
Password.setBorder(null);
Password.setBounds(593, 239, 138, 16);
frame.getContentPane().add(Password);
JSeparator separator_1 = new JSeparator();
separator_1.setForeground(Color.BLACK);
separator_1.setBounds(593, 254, 138, 12);
frame.getContentPane().add(separator_1);
JButton Button_Accedi = new JButton("Accedi!");
Button_Accedi.setForeground(new Color(255, 165, 0));
Button_Accedi.setBounds(583, 291, 158, 29);
frame.getContentPane().add(Button_Accedi);
Button_Accedi.addActionListener(this);
JButton Button_HaiDimenticatoLa = new JButton("Hai dimenticato la password?");
Button_HaiDimenticatoLa.setFont(new Font("Kohinoor Gujarati", Font.PLAIN, 11));
Button_HaiDimenticatoLa.setBorder(null);
Button_HaiDimenticatoLa.setForeground(Color.WHITE);
Button_HaiDimenticatoLa.setBounds(583, 313, 158, 29);
frame.getContentPane().add(Button_HaiDimenticatoLa);
JSeparator separator_1_1 = new JSeparator();
separator_1_1.setForeground(new Color(255, 255, 255));
separator_1_1.setBounds(583, 330, 158, 12);
frame.getContentPane().add(separator_1_1);
JButton Button_Registrazione = new JButton("Registrati!");
Button_Registrazione.setForeground(new Color(255, 165, 0));
Button_Registrazione.setBounds(583, 354, 158, 29);
frame.getContentPane().add(Button_Registrazione);
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand().equals("Hai dimenticato la password?"))
{
ctrl.visualizzazionePwdDimenticata();
}
else if(e.getActionCommand().equals("Registrati!"))
{
ctrl.visualizzazioneRegistrazione();
}
}
}
import GuiFood.*;
public class Controller {
private Login login;
private Registrazione registrazione;
private Password_Dimenticata password_dimenticata;
public Controller() {
login = new Login(this);
login.setVisible(true);
login.setLocationRelativeTo(null);
}
public void visualizzazioneRegistrazione() {
registrazione = new Registrazione(this);
registrazione.setVisible(true);
registrazione.setLocationRelativeTo(login);
}
public void visualizzazionePwdDimenticata() {
password_dimenticata = new Password_Dimenticata(this);
password_dimenticata.setVisible(true);
password_dimenticata.setLocationRelativeTo(login);
}
public boolean controllaCaratteriNonAmmessi(String nome)
{
char[] tmp = nome.toCharArray();
for(char c: tmp)
{
if(c == '*' || c == '/' || c == '-' || c == ',')
{
return false;
}
}
return true;
}
public void VisualizzazioneErrore(String string) {
// TODO Auto-generated method stub
}
public void creaUtente(Utente utente) {
// TODO Auto-generated method stub
}
}
public class Driver {
public static void main(String[] args) {
Controller ctrl = new Controller();
}
}
Quando lo mando in esecuzione ottengo solo una schermata bianca sapete dirmi dove ho problemi?