Skip to content
Open
Show file tree
Hide file tree
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
Binary file added 407382bb-1b60-4a4e-918a-ddee03f336ac (2).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 407382bb-1b60-4a4e-918a-ddee03f336ac (3).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 407382bb-1b60-4a4e-918a-ddee03f336ac (4).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ChobDar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAsCh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAsR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added End.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Pa.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Tan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Win.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions part-1/E1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;

public class E1 extends JFrame implements ActionListener {
int a=25;
int b=25;
int sumClicks=0;
JButton button;
JLabel label;
JLabel imageLabel;
ImageIcon imageMe;
Random rand = new Random();
E1(){
setTitle("Ahmad");
setResizable(false);
setSize(500,500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
label=new JLabel("Clicks : 0");
label.setFont(new Font("Arial",Font.PLAIN,30));
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setVerticalAlignment(SwingConstants.CENTER);
button=new JButton("Click bro");
ImageIcon imageBig= new ImageIcon("Screenshot 2025-05-07 203054.png");
imageMe= new ImageIcon("407382bb-1b60-4a4e-918a-ddee03f336ac (2).png");
Image setImage = imageMe.getImage().getScaledInstance(a, b, Image.SCALE_SMOOTH);
ImageIcon setIcon = new ImageIcon(setImage);
imageLabel=new JLabel(setIcon);
setIconImage(imageBig.getImage());
button.addActionListener(this);
setLayout(new BorderLayout());
add(button,BorderLayout.SOUTH);
add(imageLabel,BorderLayout.CENTER);
add(label,BorderLayout.NORTH);
}

@Override
public void actionPerformed(ActionEvent e) {
a+=25;
b+=25;
sumClicks++;
label.setText("Click: "+ sumClicks);
label.setForeground(new Color(rand.nextInt(255),rand.nextInt(255),rand.nextInt(250)));
if(sumClicks%20==0||sumClicks%20==19){
if(sumClicks%20==0){
ImageIcon imageNextKiss=new ImageIcon("407382bb-1b60-4a4e-918a-ddee03f336ac (3).png");
Image newNextK = imageNextKiss.getImage().getScaledInstance(500, 500, Image.SCALE_SMOOTH);
ImageIcon setNextK = new ImageIcon(newNextK);
imageLabel.setIcon(setNextK);
a=25;
b=25;
}else{
ImageIcon imageKiss=new ImageIcon("407382bb-1b60-4a4e-918a-ddee03f336ac (4).png");
Image newKiss = imageKiss.getImage().getScaledInstance(500, 500, Image.SCALE_SMOOTH);
ImageIcon setKiss= new ImageIcon(newKiss);
imageLabel.setIcon(setKiss);
}
}else {
Image newSet = imageMe.getImage().getScaledInstance(a, b, Image.SCALE_SMOOTH);
ImageIcon setImage = new ImageIcon(newSet);
imageLabel.setIcon(setImage);
}
}
public static void main(String [] ags){
new E1().setVisible(true);



}

}
96 changes: 96 additions & 0 deletions part-2/E2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;

public class E2 extends JFrame implements ActionListener {
Random rand = new Random();
private String[] AlfBa={"mahdi","Soios","Nahar"};
String BordAlfba;
String DBordAlfba;
int chose;
int Win=0;
StringBuilder YourAlFba;
private JTextField Text;
private JLabel label;
private JLabel labelAlfBA;
private JLabel Dar = new JLabel(new ImageIcon("ChobDar.png"));
private JButton button;
E2(){
BordAlfba=AlfBa[rand.nextInt(3)];
YourAlFba=new StringBuilder();
chose=BordAlfba.length();
DBordAlfba=BordAlfba;
for(int i=0 ; i<BordAlfba.length();i++){
YourAlFba.append("-");
}
labelAlfBA=new JLabel(YourAlFba.toString());
setTitle("HaDs AlfBa");
label=new JLabel("Welcome");
button=new JButton("Enter AlfBa");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setResizable(false);
setSize(450,450);
Text=new JTextField(15);
button.addActionListener(this);
setLayout(new BorderLayout());
labelAlfBA.setBounds(225,325,100,30);
add(labelAlfBA);
add(label,BorderLayout.NORTH);
add(Text,BorderLayout.SOUTH);
add(button,BorderLayout.NORTH);
add(Dar,BorderLayout.CENTER);
}

public static void main(String[] ags){
new E2().setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
String name=Text.getText().trim();
if(BordAlfba.indexOf(name.charAt(0))!=-1){
Win++;
if(Win==5){
chose=99;
Dar.setIcon(new ImageIcon("Win.png"));
}
YourAlFba.setCharAt(DBordAlfba.indexOf(name.charAt(0)),name.charAt(0));
BordAlfba= BordAlfba.substring(0,BordAlfba.indexOf(name.charAt(0))) + BordAlfba.substring(BordAlfba.indexOf(name.charAt(0))+1);
} else {
switch (chose){
case 99:
Dar.setIcon(new ImageIcon("Win.png"));
break;
case 5:
Dar.setIcon(new ImageIcon("Sar.png"));
chose--;
break;
case 4:
Dar.setIcon(new ImageIcon("Tan.png"));
chose--;
break;
case 3:
Dar.setIcon(new ImageIcon("Pa.png"));
chose--;
break;
case 2:
Dar.setIcon(new ImageIcon("DAsR.png"));
chose--;
break;
case 1:
Dar.setIcon(new ImageIcon("DAsCh.png"));
chose--;
break;
default:
Dar.setIcon(new ImageIcon("End.png"));
break;
}

}
labelAlfBA.setText(YourAlFba.toString());


}
}
65 changes: 65 additions & 0 deletions part-3/E3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;

public class E3 extends JFrame implements ActionListener {
private JPanel mainPanel; // The panel whose background will change
private JButton redButton; // Button to select red theme
private JButton greenButton; // Button to select green theme
private JButton blueButton; // Button to select blue theme
private JButton purpleBurron;
private JButton myColor;
Random rand= new Random();
public E3() {
setTitle("Theme Color Selector");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(500,500);
mainPanel = new JPanel();
setLocationRelativeTo(null);
redButton = new JButton("Red");
greenButton = new JButton("Green");
blueButton = new JButton("Blue");
purpleBurron=new JButton("purple");
myColor= new JButton(("RandomColor"));
redButton.setActionCommand("RED");
greenButton.setActionCommand("GREEN");
blueButton.setActionCommand("BLUE");
purpleBurron.setActionCommand("Purple");
myColor.setActionCommand("RandColor");

redButton.addActionListener(this);
greenButton.addActionListener(this);
blueButton.addActionListener(this);
purpleBurron.addActionListener(this);
myColor.addActionListener(this);
JPanel buttonPanel = new JPanel();
buttonPanel.add(redButton);
buttonPanel.add(greenButton);
buttonPanel.add(blueButton);
buttonPanel.add(purpleBurron);
buttonPanel.add(myColor);
setLayout(new BorderLayout());
add(buttonPanel, BorderLayout.NORTH);
add(mainPanel, BorderLayout.CENTER);
}


@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case "RED": mainPanel.setBackground(Color.RED); break;
case "GREEN": mainPanel.setBackground(Color.GREEN); break;
case "BLUE": mainPanel.setBackground(Color.BLUE); break;
case "Purple": mainPanel.setBackground(new Color(128, 0, 128)); break;
case "RandColor": mainPanel.setBackground(new Color(rand.nextInt(255),rand.nextInt(255),rand.nextInt(255)));


}

}
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> new E3().setVisible(true));
}
}
129 changes: 129 additions & 0 deletions part-4/E4.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class E4 extends JFrame implements ActionListener {
private JTextField txtName; // User name input
private JTextField txtEmail; // User email input
private JPasswordField txtPassword; // Password input
private JTextField YourAddress;
private JTextField PostalCode;
private JRadioButton rbMale, rbFemale; // Gender selection
private JCheckBox cbJava, cbPython, cbCpp; // Interests selection
private JCheckBox veryGood,Good,notBad,Bad;
private JButton btnSubmit; // Submit form button
private GridBagConstraints gbc; // Layout constraints
public E4() {
setTitle("User Registration");
setSize(500, 350);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setResizable(false);
JPanel panel = new JPanel(new GridBagLayout());
gbc = new GridBagConstraints();
gbc.insets = new Insets(5, 5, 5, 5);
gbc.fill = GridBagConstraints.HORIZONTAL;

// Row 0: Name label & field
gbc.gridx = 0; gbc.gridy = 0;
panel.add(new JLabel("Name:"), gbc);
gbc.gridx = 1;
txtName = new JTextField(20);
panel.add(txtName, gbc);

// Row 1: Email label & field
gbc.gridx = 0; gbc.gridy = 1;
panel.add(new JLabel("Email:"), gbc);
gbc.gridx = 1;
txtEmail = new JTextField(20);
panel.add(txtEmail, gbc);

// Row 2: Password label & field
gbc.gridx = 0; gbc.gridy = 2;
panel.add(new JLabel("Password:"), gbc);
gbc.gridx = 1;
txtPassword = new JPasswordField(20);
panel.add(txtPassword, gbc);
gbc.gridx =0; gbc.gridy=3;
panel.add(new JLabel("YourAddress:"),gbc);
gbc.gridx=1;
YourAddress = new JTextField(20);
panel.add(YourAddress,gbc);
gbc.gridx=0; gbc.gridy=4;
panel.add(new JLabel("PostalCode:"),gbc);
gbc.gridx=1;
PostalCode= new JTextField(20);
panel.add(PostalCode,gbc);

// Row 3: Gender selection
gbc.gridx = 0; gbc.gridy = 5;
panel.add(new JLabel("Gender:"), gbc);
gbc.gridx = 1;
rbMale = new JRadioButton("Male"); rbFemale = new JRadioButton("Female");
ButtonGroup bg = new ButtonGroup(); bg.add(rbMale); bg.add(rbFemale);
JPanel genderPanel = new JPanel(); genderPanel.add(rbMale); genderPanel.add(rbFemale);
panel.add(genderPanel, gbc);

// Row 4: Interests selection
gbc.gridx = 0; gbc.gridy = 6;
panel.add(new JLabel("Interests:"), gbc);
gbc.gridx = 1;
cbJava = new JCheckBox("Java"); cbPython = new JCheckBox("Python"); cbCpp = new JCheckBox("C++");
JPanel interestPanel = new JPanel();
interestPanel.add(cbJava); interestPanel.add(cbPython); interestPanel.add(cbCpp);
panel.add(interestPanel, gbc);

gbc.gridx =0; gbc.gridy =7;
panel.add(new JLabel("HowGoodIn"),gbc);
gbc.gridx=1;
veryGood=new JCheckBox("VeryGood"); Good=new JCheckBox("Good");
notBad=new JCheckBox("Not Bad"); Bad=new JCheckBox("Bad");
JPanel HowGood= new JPanel();
HowGood.add(veryGood); HowGood.add(Good);HowGood.add(notBad);HowGood.add(Bad);
panel.add(HowGood,gbc);

// Row 5: Submit button
gbc.gridx = 1; gbc.gridy = 8;
gbc.anchor = GridBagConstraints.CENTER;
btnSubmit = new JButton("Submit");
btnSubmit.addActionListener(this);
panel.add(btnSubmit, gbc);

add(panel);
}
@Override
public void actionPerformed(ActionEvent e) {
String name = txtName.getText();
String email = txtEmail.getText();
String yourAddress=YourAddress.getText();
String postalCode=PostalCode.getText();
String gender = rbMale.isSelected() ? "Male" : rbFemale.isSelected() ? "Female" : "Unspecified";
String interests = "";
if (cbJava.isSelected()) interests += "Java ";
if (cbPython.isSelected()) interests += "Python ";
if (cbCpp.isSelected()) interests += "C++ ";
String HowGood = "";
if(veryGood.isSelected()) HowGood+="VeryGood";
if(Good.isSelected()) HowGood+="Good";
if(notBad.isSelected()) HowGood+="NotBad";
if (Bad.isSelected())HowGood+="Bad";

JOptionPane.showMessageDialog(this,
"Name: " + name + "\n" +
"Email: " + email + "\n" +
"YourAddress:"+yourAddress+"\n"+
"PostalCode:"+postalCode+"\n"+
"Gender: " + gender + "\n" +
"HowGoodIn:"+ HowGood + "\n"+
"Interests: " + interests,

"Registration Details", JOptionPane.INFORMATION_MESSAGE);
}

public static void main(String[] args) {
SwingUtilities.invokeLater(() -> new E4().setVisible(true));
}


}