import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class UsernameFrame extends JFrame { private static final int WIDTH = 300, HEIGHT = 100; JTextField textField; JButton btn; public UsernameFrame(){ super(); this.setLayout(new BorderLayout()); JLabel label = new JLabel("Pick a Name"); add(label , BorderLayout.PAGE_START); textField = new JTextField(); add(textField , BorderLayout.CENTER); btn = new JButton("Na be intellij"); add(btn , BorderLayout.PAGE_END); setSize(WIDTH , HEIGHT); setVisible(true); Logic logic = new Logic(); btn.addActionListener(logic); textField.addActionListener(logic); this.setDefaultCloseOperation(EXIT_ON_CLOSE); } }