Skip to content

Commit db07a95

Browse files
committed
Java Projects
0 parents  commit db07a95

68 files changed

Lines changed: 1257 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/jarRepositories.xml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Java-Beginner-Projects
2+
Explore a variety of simple, hands-on Java projects ideal for beginners. Sharpen your coding skills while creating command-line applications, games, and practical tools in Java. Perfect for those new to programming or looking to learn Java.
3+
4+
## Project List
5+
6+
- [To-Do List Application]
7+
- [Calculator]
8+
- [Expense Tracker]
9+
- [Simple Blog]
10+
- [Weather App]
11+
- [Chat Application]
12+
- [Tic-Tac-Toe Game]
13+
- [Inventory Management System]
14+
- [Library Management System]
15+
- [Basic Social Media Platform]
16+
- [Currency Converter]
17+
- [Quiz Application]
18+
- [Random Password Generator]
19+
- [Simple Game]
20+
21+
Navigate to the project folder you're interested in. Each project has its own folder containing a README.md with specific instructions.
22+
Follow the instructions in the project's README.md file to explore project requirements.
23+
24+
## Contributing
25+
Contributions are welcome! If you want to contribute to this project, please follow these guidelines:
26+
27+
1. Star the repository ⭐
28+
2. Fork the repository.
29+
3. Create a branch: git checkout -b feature/your-feature-name.
30+
4. Make your changes and commit them: git commit -m 'Add some feature'.
31+
5. Push to the branch: git push origin feature/your-feature-name.
32+
6. Submit a pull request (Add a screenshot of the command line output of the project to the pull request message).
33+
34+
Thanks to all contributors for their valuable contributions to this project. ❤️💻🚀

pom.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>org.example</groupId>
8+
<artifactId>JavaBeginnerProjects</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<properties>
12+
<maven.compiler.source>17</maven.compiler.source>
13+
<maven.compiler.target>17</maven.compiler.target>
14+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+
</properties>
16+
17+
</project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
A simplified social media platform implemented in Java. Users can create accounts, post messages, and view posts from other users within the same program.
2+
3+
## Features
4+
5+
- Create user accounts with unique usernames.
6+
- Post messages and view posts from other users.
7+
- Basic, easy-to-use Swing-based user interface.
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
package BlogAppUsingSwing;
2+
3+
import javax.swing.*;
4+
import java.awt.*;
5+
import java.awt.event.ActionEvent;
6+
import java.awt.event.ActionListener;
7+
import java.util.ArrayList;
8+
9+
class BlogPost {
10+
private String title;
11+
private String content;
12+
13+
public BlogPost(String title, String content) {
14+
this.title = title;
15+
this.content = content;
16+
}
17+
18+
public String getTitle() {
19+
return title;
20+
}
21+
22+
public String getContent() {
23+
return content;
24+
}
25+
}
26+
27+
public class MyBlogApp {
28+
private ArrayList<BlogPost> blogPosts;
29+
private JFrame mainFrame;
30+
private JTextArea textArea;
31+
32+
public MyBlogApp() {
33+
blogPosts = new ArrayList<>();
34+
mainFrame = new JFrame("Simple BlogApp Using Swing");
35+
mainFrame.setSize(800, 800);
36+
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
37+
38+
createMainUI();
39+
}
40+
41+
private void createMainUI() {
42+
JPanel panel = new JPanel();
43+
mainFrame.add(panel);
44+
panel.setLayout(new GridLayout(3, 1));
45+
46+
JButton createButton = new JButton("Create a new blog post");
47+
JButton viewButton = new JButton("View all blog posts");
48+
JButton exitButton = new JButton("Exit");
49+
50+
createButton.addActionListener(new ActionListener() {
51+
@Override
52+
public void actionPerformed(ActionEvent e) {
53+
openCreateBlogFrame();
54+
}
55+
});
56+
57+
viewButton.addActionListener(new ActionListener() {
58+
@Override
59+
public void actionPerformed(ActionEvent e) {
60+
openViewBlogsFrame();
61+
}
62+
});
63+
64+
exitButton.addActionListener(new ActionListener() {
65+
@Override
66+
public void actionPerformed(ActionEvent e) {
67+
System.exit(0);
68+
}
69+
});
70+
71+
panel.add(createButton);
72+
panel.add(viewButton);
73+
panel.add(exitButton);
74+
}
75+
76+
private void openCreateBlogFrame() {
77+
JFrame createFrame = new JFrame("Create a new blog post");
78+
createFrame.setSize(800, 800);
79+
80+
JPanel createPanel = new JPanel(new BorderLayout(10, 10));
81+
82+
JTextField titleField = new JTextField(20);
83+
84+
JTextArea contentArea = new JTextArea(5, 2);
85+
contentArea.setLineWrap(true);
86+
JButton submitButton = new JButton("Submit");
87+
88+
submitButton.addActionListener(new ActionListener() {
89+
@Override
90+
public void actionPerformed(ActionEvent e) {
91+
String title = titleField.getText();
92+
String content = contentArea.getText();
93+
if (!title.isEmpty() && !content.isEmpty()) {
94+
BlogPost newBlogPost = new BlogPost(title, content);
95+
blogPosts.add(newBlogPost);
96+
JOptionPane.showMessageDialog(createFrame, "Blog post created!");
97+
createFrame.dispose();
98+
} else {
99+
JOptionPane.showMessageDialog(createFrame, "Please enter both title and content.");
100+
}
101+
}
102+
});
103+
104+
createPanel.add(new JLabel("Title:"));
105+
createPanel.add(titleField, BorderLayout.NORTH);
106+
createPanel.add(new JLabel("Content:"));
107+
createPanel.add(contentArea, BorderLayout.CENTER);
108+
createPanel.add(submitButton, BorderLayout.SOUTH);
109+
110+
createFrame.add(createPanel);
111+
createFrame.setVisible(true);
112+
}
113+
114+
private void openViewBlogsFrame() {
115+
JFrame viewFrame = new JFrame("View all blog posts");
116+
viewFrame.setSize(500, 500);
117+
118+
JPanel viewPanel = new JPanel(new BorderLayout());
119+
120+
textArea = new JTextArea(10, 30);
121+
textArea.setEditable(false);
122+
textArea.setText("All Blog Posts:\n");
123+
textArea.setLineWrap(true);
124+
textArea.setToolTipText("Enter Title");
125+
126+
for (BlogPost post : blogPosts) {
127+
textArea.append("Title: " + post.getTitle() + "\n");
128+
textArea.append("Content: " + post.getContent() + "\n");
129+
textArea.append(
130+
"--------------------------------------------------------------------------------------------------\n"
131+
+ "\n");
132+
}
133+
134+
JScrollPane scrollPane = new JScrollPane(textArea);
135+
viewPanel.add(scrollPane, BorderLayout.CENTER);
136+
137+
JButton backButton = new JButton("Back");
138+
backButton.addActionListener(new ActionListener() {
139+
@Override
140+
public void actionPerformed(ActionEvent e) {
141+
viewFrame.dispose();
142+
}
143+
});
144+
145+
viewPanel.add(backButton, BorderLayout.SOUTH);
146+
147+
viewFrame.add(viewPanel);
148+
viewFrame.setVisible(true);
149+
}
150+
151+
public void run() {
152+
mainFrame.setVisible(true);
153+
}
154+
155+
public static void main(String[] args) {
156+
MyBlogApp blogApp = new MyBlogApp();
157+
blogApp.run();
158+
}
159+
}

0 commit comments

Comments
 (0)