Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create logo #274

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions logo
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class BloodDonationLogin {
public static void main(String[] args) {
// Create a frame
JFrame frame = new JFrame("Blood Donation Login");
frame.setSize(400, 250);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(null);

// Username label and text field
JLabel usernameLabel = new JLabel("Username:");
usernameLabel.setBounds(50, 50, 100, 30);
frame.add(usernameLabel);

JTextField usernameField = new JTextField();
usernameField.setBounds(150, 50, 200, 30);
frame.add(usernameField);

// Password label and password field
JLabel passwordLabel = new JLabel("Password:");
passwordLabel.setBounds(50, 100, 100, 30);
frame.add(passwordLabel);

JPasswordField passwordField = new JPasswordField();
passwordField.setBounds(150, 100, 200, 30);
frame.add(passwordField);

// Login button
JButton loginButton = new JButton("Login");
loginButton.setBounds(150, 150, 100, 30);
frame.add(loginButton);

// Action listener for login button
loginButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String username = usernameField.getText();
String password = new String(passwordField.getPassword());

// Simple validation logic (replace with real authentication logic)
if (username.equals("admin") && password.equals("password")) {
JOptionPane.showMessageDialog(frame, "Login successful! Welcome, " + username + "!");
} else {
JOptionPane.showMessageDialog(frame, "Invalid username or password.", "Login Error", JOptionPane.ERROR_MESSAGE);
}
}
});

// Make the frame visible
frame.setVisible(true);
}
}