A modern, premium desktop application built in Java that simulates and visualizes Memory Allocation algorithms (First-Fit and Best-Fit). It features a sleek, dark-themed dashboard UI tailored for a professional operating system monitoring experience.
- Real-time Memory Visualization: Watch how processes are dynamically allocated to memory blocks using a visual representation of memory bars.
- Algorithm Comparison: Side-by-side comparison of First-Fit vs Best-Fit allocation strategies.
- Detailed Analytics: View detailed statistics including total allocated memory, internal fragmentation, and external fragmentation.
- Modern UI: Built entirely in Java Swing but styled to look like a premium modern desktop application (similar to Windows 11 Settings, NZXT CAM, or MSI Center).
- Interactive Configuration: Customize memory blocks, processes, and animation speeds on the fly.
- Java (JDK 8+): The core programming language used for both the logic and the graphical user interface.
- Java Swing: The standard GUI toolkit used to render the application. We implemented heavily customized
JPanelandJButtonsubclasses to achieve rounded corners, gradients, and soft shadows without relying on web technologies like HTML/CSS. - FlatLaf (Flat Look and Feel): A modern, open-source Look and Feel for Java Swing. Specifically, the
FlatDarkLaftheme is used as the base to override outdated Java Swing defaults and provide a crisp, dark aesthetic, seamless typography, and better DPI scaling.
The project follows the classic MVC (Model-View-Controller) design pattern:
Contains the core data structures and simulation logic. It is completely independent of the GUI.
Simulator.java: The engine. Contains the implementation of thefirstFit()andbestFit()algorithms. It calculates fragmentation and tracks which processes go where.MemoryBlock.java: Represents a chunk of physical memory, tracking its size and whether it's currently occupied by a process.Process.java: Represents a process requesting memory, tracking its requested size and allocation status.AllocationResult.java: A data transfer object that stores the final state of an allocation run (the state of all blocks and total fragmentation).
Contains all the graphical components. Everything here extends standard Swing components but overrides paintComponent to draw modern UI elements.
MainDashboardView.java: The root window (JFrame). It uses aCardLayoutto switch between the Dashboard, Results, and Settings pages.LeftSidebar.java: The interactive navigation menu on the left. It takes user input for memory sizes and allows triggering simulations.MemoryVisualizerPanel.java&MemoryBar.java: Renders the animated horizontal bars representing memory blocks and their filled states.ResultsPage.java: A detailed data table view showing the side-by-side metrics of the algorithms.SettingsPage.java: A configuration page to toggle algorithms and adjust animation speeds.- Custom UI Elements: Classes like
RoundedPanel,RoundedButton,DashboardCard, andModernUI(a central UI token dictionary) handle the premium aesthetics (gradients, rounded corners, modern typography).
MainController.java: The bridge. It listens for button clicks from the View, reads the input data, passes it to theSimulator(Model), and then pushes the calculated results back to the View to trigger animations and update charts.
- Initializes the
FlatDarkLaftheme. - Bootstraps the application by instantiating the View and the Controller, then makes the window visible.
- Ensure you have the Java Development Kit (JDK) installed.
- The project requires the
flatlaf-3.4.1.jardependency to run. Make sure it is in the root directory alongsideApp.java. - Compile the code (Windows):
javac -cp ".;flatlaf-3.4.1.jar" App.java model/*.java view/*.java controller/*.java
- Run the application (Windows):
java -cp ".;flatlaf-3.4.1.jar" App
(Note: On Mac/Linux environments, use : instead of ; in the classpath: -cp ".:flatlaf-3.4.1.jar")