Application Structure
MegaDownloader is a Java Swing desktop application that provides a graphical interface for downloading videos and audio from YouTube using yt-dlp. The application follows a panel-based navigation pattern using CardLayout to switch between different screens.Core Architecture
The application is structured around a main window (Main.java) that manages multiple panels:
The application uses an undecorated frame (no native title bar) and implements custom window dragging functionality through mouse listeners.
Technology Stack
UI Framework
Java Swing
Core GUI framework for building the desktop interface
FlatLaf Darcula
Modern dark theme for enhanced visual appearance
External Tools
yt-dlp
Command-line tool for downloading videos from YouTube and other platforms
FFmpeg
Media processing for audio extraction and format conversion
Key Technologies
- Java Swing: GUI components (JFrame, JPanel, CardLayout)
- FlatLaf Darcula: Dark theme (
FlatDarculaLaf.setup()) - yt-dlp: External process for media downloads
- FFmpeg: Audio/video processing (auto-detected or manually configured)
- Java Preferences API: Persistent storage for user credentials
- SwingWorker: Background task execution without blocking the UI
Design Patterns
1. CardLayout Navigation Pattern
The application uses CardLayout to manage multiple panels within a single window:Main class with methods like:
showMainPanel()showPreferencesPanel()showManageMediaPanel()showLoginForm()goBack()
2. Dependency Injection
Panels are connected through setter-based dependency injection:3. Observer Pattern
TheMediaPollingComponent uses listeners to notify panels of new media:
4. SwingWorker Pattern
Long-running operations use SwingWorker to avoid blocking the UI thread:Layered Layout
The application usesJLayeredPane to overlay components:
DEFAULT_LAYER- Main content panelsPALETTE_LAYER- Media polling status indicatorPOPUP_LAYER- Exit button
Configuration Management
The application stores configuration in a localconfig.txt file:
User credentials are stored separately using the Java Preferences API for secure session management.
Process Execution
The application executes external processes (yt-dlp) and parses their output in real-time:Next Steps
Core Components
Detailed overview of each component and its responsibilities
UI Panels
Panel navigation flow and UI implementation details

