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

e-commerce management system in java Introduction The e-commerce management system is a GUI-based desktop application designed using Java swing in Netbean IDE. …

time table generator in java introduction The Time Table Generator is a Java utility that helps educational institutions automatically create class schedules …

crime record management system in java introduction The Crime Record Management System is a secure and systematic way of maintaining criminal and …

car rental system in java(GUI swing) introduction The Car Rental System is a Java application tailored for vehicle rental agencies. It allows …

food delivery management system in java introduction This Food Delivery Management System helps restaurants manage customer orders, menus, deliveries, and billing using …

online course registration in java introduction The Online Course Registration System allows students to enroll in courses using a Java application with …

More java Pojects
Get Huge Discounts