JavaNote - Text-Based Note Taking Application

JavaNote - Text-Based Note Taking Application

Introduction:

JavaNote is a simple text-based note-taking application designed to help users create, organize, and manage their notes efficiently. With features like formatting, categorization, and basic search functionality, JavaNote provides a user-friendly interface for maintaining digital notes. This project is an excellent opportunity to practice Java programming and GUI development skills.

Key Features:

 

  1. User Authentication: Users can create accounts or log in securely to access their notes.

  2. Note Creation and Editing: Users can create new notes, edit existing ones, and apply basic formatting (such as bold, italic, and underline) using a user-friendly text editor.

  3. Categorization: Notes can be categorized into different topics or folders, allowing users to better organize their content.

  4. Search Functionality: Users can search for specific notes by keywords, titles, or tags.

  5. User Interface: A graphical user interface (GUI) will be provided for users to interact with the application. The GUI should include buttons, menus, and text areas for creating, editing, and managing notes.

  6. File Persistence: Notes and user data will be saved locally using file storage. Serialization can be used to save and load notes.

  7. Formatting Options: Implement a set of buttons or formatting shortcuts that users can use to apply formatting options to selected text in the note editor.

  8. Responsive Design: Design the application’s GUI to be responsive and user-friendly, ensuring that it works well on different screen sizes.

  9. Data Validation: Implement input validation to ensure that users enter valid data when creating or editing notes.

Source Code:

Get Discount on Top Educational Courses

Brand NameDiscount InformationCoupon Codes Link
Educative.io20% discount on Educative courses and plans
W3Schools20% discount on W3Schools courses
KodeKloud10% discount on KodeKloud courses and plans
GeeksforGeeks30% discount on GeeksforGeeks courses
Target Test Prep20% discount on Target Test Prep
Coding Ninjas₹5000 discount on Coding Ninjas courses
Skillshare40% discount on Skillshare
DataCamp50% discount on DataCamp
365 Data Science57% discount on 365 Data Science Plans
Get SmarterFlat 20% discount on Get Smarter courses
SmartKeedaFlat 40% discount on SmartKeeda courses
StackSocial20% discount on StackSocial courses

Note.java

				
					import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.ArrayList;

public class NoteAppFrame extends JFrame {
    private JTextArea noteTextArea;
    private JComboBox<String> categoryComboBox;
    private ArrayList<Note> notes;

    public NoteAppFrame() {
        setTitle("JavaNote - Note Taking Application");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(600, 400);
        setLocationRelativeTo(null);

        notes = new ArrayList<>();

        noteTextArea = new JTextArea();
        categoryComboBox = new JComboBox<>();

        JButton createButton = new JButton("Create");
        JButton editButton = new JButton("Edit");
        JButton deleteButton = new JButton("Delete");
        JButton saveButton = new JButton("Save");

        JPanel controlPanel = new JPanel();
        controlPanel.setLayout(new FlowLayout());
        controlPanel.add(createButton);
        controlPanel.add(editButton);
        controlPanel.add(deleteButton);
        controlPanel.add(saveButton);

        createButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                createNote();
            }
        });

        editButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                editNote();
            }
        });

        deleteButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                deleteNote();
            }
        });

        saveButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                saveNotes();
            }
        });

        add(controlPanel, BorderLayout.NORTH);
        add(new JScrollPane(noteTextArea), BorderLayout.CENTER);

        loadNotes();
    }

    private void loadNotes() {
        try {
            FileInputStream fileIn = new FileInputStream("notes.ser");
            ObjectInputStream in = new ObjectInputStream(fileIn);
            notes = (ArrayList<Note>) in.readObject();
            in.close();
            fileIn.close();
            populateCategoryComboBox();
        } catch (IOException | ClassNotFoundException ex) {
            ex.printStackTrace();
        }
    }

    private void saveNotes() {
        try {
            FileOutputStream fileOut = new FileOutputStream("notes.ser");
            ObjectOutputStream out = new ObjectOutputStream(fileOut);
            out.writeObject(notes);
            out.close();
            fileOut.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    private void createNote() {
        String title = JOptionPane.showInputDialog(this, "Enter note title:");
        String content = noteTextArea.getText();
        String category = categoryComboBox.getSelectedItem().toString();

        Note note = new Note(title, content, category);
        notes.add(note);
        populateCategoryComboBox();
        saveNotes();

        noteTextArea.setText("");
        JOptionPane.showMessageDialog(this, "Note created successfully!");
    }

    private void editNote() {
        int selectedNoteIndex = notes.size() > 0 ? categoryComboBox.getSelectedIndex() : -1;

        if (selectedNoteIndex >= 0) {
            Note selectedNote = notes.get(selectedNoteIndex);
            selectedNote.setContent(noteTextArea.getText());
            saveNotes();
            JOptionPane.showMessageDialog(this, "Note edited successfully!");
        } else {
            JOptionPane.showMessageDialog(this, "No note selected.");
        }
    }

    private void deleteNote() {
        int selectedNoteIndex = notes.size() > 0 ? categoryComboBox.getSelectedIndex() : -1;

        if (selectedNoteIndex >= 0) {
            notes.remove(selectedNoteIndex);
            populateCategoryComboBox();
            saveNotes();
            noteTextArea.setText("");
            JOptionPane.showMessageDialog(this, "Note deleted successfully!");
        } else {
            JOptionPane.showMessageDialog(this, "No note selected.");
        }
    }

    private void populateCategoryComboBox() {
        categoryComboBox.removeAllItems();
        for (Note note : notes) {
            categoryComboBox.addItem(note.getTitle());
        }
    }

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

				
			

NoteAppFrame.java

				
					import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.ArrayList;

public class NoteAppFrame extends JFrame {
    private JTextArea noteTextArea;
    private JComboBox<String> categoryComboBox;
    private ArrayList<Note> notes;

    public NoteAppFrame() {
        setTitle("JavaNote - Note Taking Application");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(600, 400);
        setLocationRelativeTo(null);

        notes = new ArrayList<>();

        noteTextArea = new JTextArea();
        categoryComboBox = new JComboBox<>();

        JButton createButton = new JButton("Create");
        JButton editButton = new JButton("Edit");
        JButton deleteButton = new JButton("Delete");
        JButton saveButton = new JButton("Save");

        JPanel controlPanel = new JPanel();
        controlPanel.setLayout(new FlowLayout());
        controlPanel.add(createButton);
        controlPanel.add(editButton);
        controlPanel.add(deleteButton);
        controlPanel.add(saveButton);

        createButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                createNote();
            }
        });

        editButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                editNote();
            }
        });

        deleteButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                deleteNote();
            }
        });

        saveButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                saveNotes();
            }
        });

        add(controlPanel, BorderLayout.NORTH);
        add(new JScrollPane(noteTextArea), BorderLayout.CENTER);

        loadNotes();
    }

    private void loadNotes() {
        try {
            FileInputStream fileIn = new FileInputStream("notes.ser");
            ObjectInputStream in = new ObjectInputStream(fileIn);
            notes = (ArrayList<Note>) in.readObject();
            in.close();
            fileIn.close();
            populateCategoryComboBox();
        } catch (IOException | ClassNotFoundException ex) {
            ex.printStackTrace();
        }
    }

    private void saveNotes() {
        try {
            FileOutputStream fileOut = new FileOutputStream("notes.ser");
            ObjectOutputStream out = new ObjectOutputStream(fileOut);
            out.writeObject(notes);
            out.close();
            fileOut.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    private void createNote() {
        String title = JOptionPane.showInputDialog(this, "Enter note title:");
        String content = noteTextArea.getText();
        String category = categoryComboBox.getSelectedItem().toString();

        Note note = new Note(title, content, category);
        notes.add(note);
        populateCategoryComboBox();
        saveNotes();

        noteTextArea.setText("");
        JOptionPane.showMessageDialog(this, "Note created successfully!");
    }

    private void editNote() {
        int selectedNoteIndex = notes.size() > 0 ? categoryComboBox.getSelectedIndex() : -1;

        if (selectedNoteIndex >= 0) {
            Note selectedNote = notes.get(selectedNoteIndex);
            selectedNote.setContent(noteTextArea.getText());
            saveNotes();
            JOptionPane.showMessageDialog(this, "Note edited successfully!");
        } else {
            JOptionPane.showMessageDialog(this, "No note selected.");
        }
    }

    private void deleteNote() {
        int selectedNoteIndex = notes.size() > 0 ? categoryComboBox.getSelectedIndex() : -1;

        if (selectedNoteIndex >= 0) {
            notes.remove(selectedNoteIndex);
            populateCategoryComboBox();
            saveNotes();
            noteTextArea.setText("");
            JOptionPane.showMessageDialog(this, "Note deleted successfully!");
        } else {
            JOptionPane.showMessageDialog(this, "No note selected.");
        }
    }

    private void populateCategoryComboBox() {
        categoryComboBox.removeAllItems();
        for (Note note : notes) {
            categoryComboBox.addItem(note.getTitle());
        }
    }

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

				
			

Output:

Find More Projects

Drawing Chhatrapati Shivaji Maharaj Using Python Chhatrapati Shivaji Maharaj, the legendary Maratha warrior and founder of the Maratha Empire, is an inspiration …

Resume Builder Application using Java With Source Code Graphical User Interface [GUI] Introduction: The Resume Builder Application is a powerful and user-friendly …

Encryption Tool using java with complete source Code GUI Introduction: The Encryption Tool is a Java-based GUI application designed to help users …

Movie Ticket Booking System using Java With Source Code Graphical User Interface [GUI] Introduction: The Movie Ticket Booking System is a Java …

Video Call Website Using HTML, CSS, and JavaScript (Source Code) Introduction Hello friends, welcome to today’s new blog post. Today we have …

promise day using html CSS and JavaScript Introduction Hello all my developers friends my name is Gautam and everyone is welcome to …