A simple Java Swing application that lets users create and manage a live log through an interactive GUI.
You can add timestamped entries, insert separators, and clear all logs with a single click.
- 🕒 Timestamped entries — each log line records the current hour, minute, and second.
- ➕ Add entries — type a short message and press Add Log Entry.
- 🧹 Clear log — instantly clears all log text and resets the counter.
- 🔹 Add separators — insert visual separators between log sections.
- 🎨 Simple GUI — intuitive layout with tooltips for each button.
When the program runs:
- A window titled “Mini Log” opens.
- Users can type into the text box at the bottom.
- Three buttons are available:
- Clear Log — clears all log entries.
- Add Log Entry — adds a new line with a timestamp.
- Add Separator — inserts a dashed separator line.
- All entries appear in the center text area, with timestamps generated using
Calendar.
| Component | Description |
|---|---|
JFrame |
Main application window |
JTextArea |
Displays the log content |
JTextField |
Allows user input for new entries |
JButton |
Controls (Clear, Add Entry, Add Separator) |
ActionListener |
Handles all button events |
Calendar |
Generates timestamps for each entry |
- Time Complexity:
O(1)per operation - Space Complexity:
O(n)wheren= number of log entries
Open your terminal in the project directory and run:
javac logGame.java