hi.. when i hit run all i get is the Clear button which fills the whole panel and nothing else comes up anyno where i went wrong
import java.awt.*;
import java.awt.event. *;
import javax.swing.*;
public class Login extends JFrame implements ActionListener
{
JPanel cardHolder;
private CardLayout card;
private JLabel label1, label2;
private JTextField username;
private JPasswordField password;
private JButton loginBtn, clearBtn, PurchaseTickets ;
public static void main(String args[])
{
Login app = new Login();
}
public Login() //constructor
{
super("Event Handling");
setTitle("Login ");
cardHolder = new JPanel();
card = new CardLayout();
Container c = getContentPane( );
cardHolder.setL ayout(card);
label1 = new JLabel("Usernam e:");
username = new JTextField(20);
label2 = new JLabel("Passwor d:");
password = new JPasswordField( 20);
loginBtn = new JButton("Login" );
loginBtn.addAct ionListener(thi s);
clearBtn = new JButton("Clear" );
clearBtn.addAct ionListener(thi s);
c.add(label1);
c.add(username) ;
c.add(label2);
c.add(password) ;
c.add(loginBtn) ;
c.add(clearBtn) ;
setSize(350, 170);
setVisible(true );
}
public void actionPerformed (ActionEvent e)
{
if (e.getSource() == loginBtn)
{
JOptionPane.sho wMessageDialog( null, "Welcome "+username.getT ext());
select sel = new select();
}
if (e.getSource() == clearBtn)
{
username.setTex t("");
password.setTex t("");
}
}
}
import java.awt.*;
import java.awt.event. *;
import javax.swing.*;
public class Login extends JFrame implements ActionListener
{
JPanel cardHolder;
private CardLayout card;
private JLabel label1, label2;
private JTextField username;
private JPasswordField password;
private JButton loginBtn, clearBtn, PurchaseTickets ;
public static void main(String args[])
{
Login app = new Login();
}
public Login() //constructor
{
super("Event Handling");
setTitle("Login ");
cardHolder = new JPanel();
card = new CardLayout();
Container c = getContentPane( );
cardHolder.setL ayout(card);
label1 = new JLabel("Usernam e:");
username = new JTextField(20);
label2 = new JLabel("Passwor d:");
password = new JPasswordField( 20);
loginBtn = new JButton("Login" );
loginBtn.addAct ionListener(thi s);
clearBtn = new JButton("Clear" );
clearBtn.addAct ionListener(thi s);
c.add(label1);
c.add(username) ;
c.add(label2);
c.add(password) ;
c.add(loginBtn) ;
c.add(clearBtn) ;
setSize(350, 170);
setVisible(true );
}
public void actionPerformed (ActionEvent e)
{
if (e.getSource() == loginBtn)
{
JOptionPane.sho wMessageDialog( null, "Welcome "+username.getT ext());
select sel = new select();
}
if (e.getSource() == clearBtn)
{
username.setTex t("");
password.setTex t("");
}
}
}
Comment