In java, a beginner. I ask you to evaluate the correctness of writing the code and tell me how to make transitions with the opening of a new window when you click on the button (the old one closes) and back. Thanks to all of you early!

import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class Authorization{ public void createGui(){ JFrame frame = new JFrame("Поисковая система Личностей"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setVisible(true); frame.setSize(400,200); frame.setLocationRelativeTo(null); frame.setResizable(false); JPanel panel = new JPanel(); frame.add(panel); panel.setLayout(null); JTextField field = new JTextField("Введите логин"); field.setBounds(90,20,200,30); JPasswordField passwordField = new JPasswordField("Введите пароль"); passwordField.setBounds(90,60,200,30); passwordField.getPassword(); panel.add(field); panel.add(passwordField); JButton bRegistrate = new JButton("Регистрация"); bRegistrate.setBounds(90,100,120,30); JButton bVhod= new JButton("Вход"); bVhod.setBounds(220,100,70,30); panel.add(bRegistrate); panel.add(bVhod); bVhod.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (bVhod == e.getSource()){ BaseShow baseShow = new BaseShow(); baseShow.display(); } } }); bRegistrate.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (bRegistrate == e.getSource()){ BaseRegistraction baseRegistraction = new BaseRegistraction(); baseRegistraction.registr(); } } }); frame.validate(); frame.repaint(); } } import javax.swing.*; public class BaseRegistraction { public void registr(){ JFrame frameReg = new JFrame("Регистрация"); frameReg.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frameReg.setVisible(true); frameReg.setResizable(false); frameReg.setSize(500,500); frameReg.setLocationRelativeTo(null); } } 
  • The code should be in the question itself, and not on the Google disk. - 0xdb

0