Fixed structure of UI, Added some logic to Auth
This commit is contained in:
@@ -7,9 +7,18 @@ public class MyFrame extends JFrame {
|
||||
JPanel mainPanel = new JPanel(new CardLayout());
|
||||
|
||||
public void changePanel(String panel) {
|
||||
|
||||
CardLayout cardLayout = (CardLayout) mainPanel.getLayout();
|
||||
cardLayout.show(mainPanel, panel);
|
||||
}
|
||||
|
||||
public void init(JPanel mainPanel) {
|
||||
mainPanel.add(new AuthPanel(this::changePanel), "auth");
|
||||
mainPanel.add(new LoginPanel(this::changePanel), "login");
|
||||
mainPanel.add(new RegistryPanel(this::changePanel), "registry");
|
||||
mainPanel.add(new HomePanel(this::changePanel), "home");
|
||||
}
|
||||
|
||||
|
||||
public MyFrame() {
|
||||
super("Todo App");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
@@ -17,26 +26,7 @@ public class MyFrame extends JFrame {
|
||||
setLocation(50, 50);
|
||||
setLayout(new CardLayout());
|
||||
|
||||
JPanel startPanel = new JPanel();
|
||||
JButton loginButton = new JButton("Login");
|
||||
JButton registryButton = new JButton("Registry");
|
||||
|
||||
startPanel.add(loginButton);
|
||||
startPanel.add(registryButton);
|
||||
mainPanel.add(startPanel, "start");
|
||||
mainPanel.add(LoginPanel.getLoginPanel(), "login");
|
||||
mainPanel.add(RegistryPanel.getRegistryPanel(), "registry");
|
||||
|
||||
loginButton.addActionListener(e -> {
|
||||
CardLayout cl = (CardLayout)mainPanel.getLayout();
|
||||
cl.show(mainPanel, "login");
|
||||
});
|
||||
|
||||
registryButton.addActionListener(e -> {
|
||||
CardLayout cl = (CardLayout)mainPanel.getLayout();
|
||||
cl.show(mainPanel, "registry");
|
||||
});
|
||||
|
||||
init(mainPanel);
|
||||
add(mainPanel);
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user