I'm trying to write an applet that switches between cards using CardLayout, but the app is not showing anything at all and I can't figure out what's wrong. A little help would be much appreciated :)
import javax.swing.*;
import java.awt.*;
public class TEST extends JApplet{
@Override
public void init(){
}
@Override
public void start(){
JPanel cards = new JPanel(new CardLayout());
JPanel main = new JPanel();
main.setLayout(new GridLayout(3, 1, 2, 2));
JTextField jtfEmail = new JTextField("E-mail", 10);
main.add(jtfEmail);
JTextField jtfPassword = new JPasswordField("Password", 10);
main.add(jtfPassword);
JPanel buttons = new JPanel();
JButton jbtLogin = new JButton("Login");
buttons.add(jbtLogin);
JButton jbtRegister = new JButton("Register");
buttons.add(jbtRegister);
main.add(buttons);
cards.add(main, "Main");
CardLayout cardLayout = (CardLayout) cards.getLayout();
cardLayout.show(cards, "Main");
}
}
public void start(){
This is not the correct method to use to add components to an applet. This method might be called multiple times.