diff --git a/app/src/main/java/brickbreaker/App.java b/app/src/main/java/brickbreaker/App.java index f35e67e03621c30e569ce7c684ec229ecdd7ecd7..1a2f5fba29333626b3a1f95d2ad930bf241208c8 100644 --- a/app/src/main/java/brickbreaker/App.java +++ b/app/src/main/java/brickbreaker/App.java @@ -3,12 +3,15 @@ */ package brickbreaker; -public class App { - public String getGreeting() { - return "Hello World!"; - } +import javax.swing.JFrame; +public class App { public static void main(String[] args) { - System.out.println(new App().getGreeting()); + LoginFrame frame=new LoginFrame(); + frame.setTitle("Register || Brick Breaker"); + frame.setVisible(true); + frame.setBounds(10,10,370,600); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setResizable(false); } } diff --git a/app/src/main/java/brickbreaker/GamePanel.java b/app/src/main/java/brickbreaker/GamePanel.java new file mode 100644 index 0000000000000000000000000000000000000000..f1e6ec77b803d38d23f0bb554ec5f09598ecc0e1 --- /dev/null +++ b/app/src/main/java/brickbreaker/GamePanel.java @@ -0,0 +1,13 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package brickbreaker; + +/** + * + * @author Suman + */ +public class GamePanel { + +} diff --git a/app/src/main/java/brickbreaker/LoginFrame.java b/app/src/main/java/brickbreaker/LoginFrame.java new file mode 100644 index 0000000000000000000000000000000000000000..71252a9c06f5c1ae110338def5a92b555d421922 --- /dev/null +++ b/app/src/main/java/brickbreaker/LoginFrame.java @@ -0,0 +1,90 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package brickbreaker; + +/** + * + * @author Suman + */ +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class LoginFrame extends JFrame implements ActionListener { + + Container container=getContentPane(); + JLabel userLabel=new JLabel("USERNAME"); + JLabel passwordLabel=new JLabel("PASSWORD"); + JTextField userNameTextField=new JTextField(); + JPasswordField passwordField=new JPasswordField(); + JButton loginButton=new JButton("LOGIN"); + JButton registerButton=new JButton("REGISTER"); + + + LoginFrame() + { + //Calling methods inside constructor. + setLayoutManager(); + setLocationAndSize(); + addComponentsToContainer(); + addActionListeners(); + } + public void setLayoutManager() + { + container.setLayout(null); + } + public void setLocationAndSize() + { + //Setting location and Size of each components using setBounds() method. + userLabel.setBounds(50,150,100,30); + passwordLabel.setBounds(50,220,100,30); + userNameTextField.setBounds(150,150,150,30); + passwordField.setBounds(150,220,150,30); + loginButton.setBounds(50,300,100,30); + registerButton.setBounds(200,300,100,30); + + + } + public void addComponentsToContainer() + { + //Adding each components to the Container + container.add(userLabel); + container.add(passwordLabel); + container.add(userNameTextField); + container.add(passwordField); + container.add(loginButton); + container.add(registerButton); + } + + public void addActionListeners() { + loginButton.addActionListener(this); + registerButton.addActionListener(this); + } + + + @Override + public void actionPerformed(ActionEvent e) { + String actionCommand = e.getActionCommand(); + switch(actionCommand) { + case "LOGIN": + handleLogin(); + break; + + case "REGISTER": + handleRegister(); + } + } + + private void handleLogin() { + String password = new String(passwordField.getPassword()); + String userName = userNameTextField.getText(); + System.out.println("user Nmae: " + userName + " password: " + password); + } + + private void handleRegister() { + System.out.println("brickbreaker.LoginFrame.handleRegister()"); + } +}