Ajp Micro 1.2
Ajp Micro 1.2
The Blogging Platform is a desktop application developed using Java Swing. It provides
basic interface for users to manage blog posts in a local environment. This application
allows users to create, view, and delete blog posts, making it an ideal solution for a basic
blogging tool or for educational purposes to understand core Java Swing concepts. The
application targets users who need a lightweight and intuitive blogging solution without the
complexity of server-side infrastructure or web-based technologies. It is particularly
suitable for educational purposes, offering a hands-on example of Java Swing's capabilities
and the principles of event-driven programming. By leveraging Java's Swing toolkit, this
project demonstrates how to build a responsive desktop application with essential crud
functionalities and a user-friendly layout.
1
CONTENT
Objectives
User Interaction: The GUI allows users to interact with the application
through a series of intuitive controls, including text fields for input and lists
for display. The interaction model is designed to be as simple as possible,
focusing on core functionalities without additional complexities.
2
CONTENT
Technical details
Language and Framework: Developed in Java using the Swing GUI toolkit
as desktop application environment.
Data Storage: Blog posts are stored in memory using Java Array List and
Default List Model providing a simple, ephemeral storage solution.
Benefits
3
CONTENT
CODE:
package blogging;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
public class SimpleBlogApp {
private static List<String> blogPosts = new ArrayList<>();
private static DefaultListModel<String> listModel = new DefaultListModel<>();
private static JList<String> postList = new JList<>(listModel);
private static JTextArea contentArea = new JTextArea(10, 30);
private static JTextField titleField = new JTextField(30);
public static void main(String[] args) {
SwingUtilities.invokeLater(SimpleBlogApp::createAndShowGUI);
private static void createAndShowGUI() {
JFrame frame = new JFrame("Simple Blog Application");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 400);
JPanel panel = new JPanel(); panel.setLayout(new
BorderLayout());
JPanel northPanel = new JPanel();
northPanel.add(new JLabel("Title:"));
northPanel.add(titleField);
JButton addButton = new JButton("Add Post");
JButton deleteButton = new JButton("Delete
Post"); northPanel.add(addButton);
northPanel.add(deleteButton);
panel.add(northPanel, BorderLayout.NORTH);
JPanel centerPanel = new JPanel(new
GridLayout(1, 2));
centerPanel.add(newJScrollPane(postList));
centerPanel.add(newJScrollPane(contentArea));
panel.add(centerPanel, BorderLayout.CENTER);
4
addButton.addActionListener(new AddPostAction());
deleteButton.addActionListener(new DeletePostAction());
postList.addListSelectionListener(e -> {
if (!e.getValueIsAdjusting()) {
int selectedIndex = postList.getSelectedIndex();
if (selectedIndex >= 0) {
contentArea.setText(blogPosts.get(selectedIndex));}}
});
frame.add(panel);
frame.setVisible(true);
}
private static class AddPostAction implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
String title = titleField.getText();
String content = contentArea.getText();
if (!title.isEmpty() && !content.isEmpty()) {
blogPosts.add(content);
listModel.addElement(title);
titleField.setText("");
contentArea.setText("");
} else {
JOptionPane.showMessageDialog(null, "Title and content
cannot be empty", "Error", JOptionPane.ERROR_MESSAGE);}}}
private static class DeletePostAction implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
int selectedIndex = postList.getSelectedIndex();
if (selectedIndex >= 0) {
blogPosts.remove(selectedIndex);
listModel.remove(selectedIndex);
contentArea.setText("");
titleField.setText("");
} else {
JOptionPane.showMessageDialog(null, "No post selected to
delete","Errror”,JOptionPane.ERROR_MESSAGE);}}}
5
CONTENT
Output :
6
CONCLUSION
The Blogging Platform offers a compact yet functional introduction to Java Swing and
desktop application development. By focusing on essential functionalities and a clean
interface, this project provides a practical starting point for understanding GUI-based
applications and can be further expanded with additional features as needed. project
effectively demonstrates the core concepts of desktop application development using Java
Swing. By focusing on essential blogging functionalities—creating, viewing, and deleting
posts—this project provides a practical and accessible introduction to building graphical
user interfaces in Java. The Simple Blogging Platform successfully balances functionality
with ease of use, making it an excellent tool for learning and experimentation. It offers a clear
path to understanding Java Swing while providing a practical solution for local blog
management. Whether used as an educational exercise or a starting point for more advanced
applications, this project underscores the potential of desktop applications in delivering
effective and user- friendly software solutions.
7
WEEKLY PROGRESS REPORT
MICRO PROJECT
SR.NO. WEEK ACTIVITY PERFORMED SIGN OF GUIDE DATE
10 10th Seminar
8
REFERENCE:
https://www.geeksforgeeks.org/
https://www.w3schools.com/
https://www.javatpoint.com/
SOURCES USED:
Eclipse
Online gdb
VS code
9
ANEEXURE II
(Signature of Faculty)
10