Visualizzazione dei risultati da 1 a 6 su 6

Visualizzazione discussione

  1. #1
    Utente di HTML.it
    Registrato dal
    Feb 2009
    residenza
    Roma
    Messaggi
    81

    If then else dove e come metterlo?

    Salve, sto creando un Login in Java, ma non riesco, ad inserire l'IF , che se la username e la password sono esatti, mi restiuisce ciao giampiero, altrimenti chi sei?
    questo e il codice:
    codice:
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JButton;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    import java.awt.*;
    import java.awt.event.*;
    
    
    public class login {
        public static void main (String[] args){
            JFrame frame = new JFrame("Login");
            frame.setSize(400,300);
            JPanel panel = new JPanel();
            panel.setSize(200,200);
            JLabel label = new JLabel("LOGIN");
            panel.setLayout(new GridLayout(6,2));
            JLabel label1 = new JLabel("Username");
            JTextField text = new JTextField("Username");
            JLabel label2 = new JLabel("Password");
            JTextField text1 = new JTextField("Password");
            JButton button = new JButton("Login");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.add(panel);
            panel.add(label);
            panel.add(label1);
            panel.add(text);
            panel.add(label2);
            panel.add(text1);
            panel.add(button);
            frame.setVisible(true);
            button.addActionListener(new Action());
            
        }
            }
            class Action implements ActionListener{
            public void actionPerformed (ActionEvent e){
                JFrame frame1 = new JFrame();
                frame1.setVisible(true);
                frame1.setSize(200,200);
            JLabel label = new JLabel("ciao Giampiero");
                JPanel panel = new JPanel();
                frame1.add(panel);
                panel.add(label);
                frame1.setVisible(true);
        
            }
        }
    Ultima modifica di LeleFT; 19-01-2016 a 13:43 Motivo: Sistemati i tag CODE

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.