This repository contains MadHelix itself, along with compiled libraries with its dependencies.

[[ 🗃 ^ZEkyo madhelix ]] :: [📥 Inbox] [📤 Outbox] [🐤 Followers] [🤝 Collaborators] [🛠 Commits]

Clone

HTTPS: git clone https://vervis.peers.community/repos/ZEkyo

SSH: git clone USERNAME@vervis.peers.community:ZEkyo

Branches

Tags

v0.0.1 :: src / org / ultrasonicmadness / ultrasonichelix / dialogs /

AboutBox.java

/*
 * UltrasonicHelix is a Java Swing-based GUI frontend for SoundHelix.
 * Copyright (C) 2017 UltrasonicMadness
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.ultrasonicmadness.ultrasonichelix.dialogs;

// Get SoundHelix version
import com.soundhelix.util.VersionUtils;

// AWT widgets
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

// Swing widgets
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;

public class AboutBox {
    // Main window.
    private static JFrame mainWindow;
    
    // Only public method, shows the about box.
    public static void show() {
        // Declare and initialize objects
        mainWindow = new JFrame("About UltrasonicHelix");
        JPanel mainPanel = new JPanel();
        
        // Info, credits, license and button panels.
        JPanel infoPanel = getInfoPanel();
        JTabbedPane mainPane = getMainPane();
        JPanel buttonPanel = getButtonPanel();
        
        // Layouts
        mainPanel.setLayout(new GridBagLayout());
        
        // Set up constraints
        GridBagConstraints constraints = new GridBagConstraints();
        constraints.insets = new Insets(4, 4, 4, 4);
        constraints.fill = GridBagConstraints.BOTH;
        constraints.weightx = 1;
        
        // Add widgets to about box
        constraints.gridy = 0;
        constraints.weighty = 0;
        mainPanel.add(infoPanel, constraints);
        
        constraints.gridy = 1;
        constraints.weighty = 1;
        mainPanel.add(mainPane, constraints);
        
        constraints.gridy = 2;
        constraints.weighty = 0;
        mainPanel.add(buttonPanel, constraints);
        
        // Show main frame
        mainWindow.add(mainPanel);
        mainWindow.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        mainWindow.setResizable(false);
        mainWindow.pack();
        mainWindow.setVisible(true);
    }
    
    // Get panel containing a short description of UltrasonicHelix.
    private static JPanel getInfoPanel() {
        // Set up info panel
        JPanel infoPanel = new JPanel();
        infoPanel.setLayout(new GridBagLayout());
        
        // Set up labels
        JLabel headerLabel = new JLabel("UltrasonicHelix 0.0.1");
        JLabel descriptionLabel = new JLabel("A Java Swing frontend for the SoundHelix music generation tool.");
        JLabel helixVersionLabel = new JLabel();
        
        // In case an error occurs or SoundHelix.jar cannot be found
        try {
            helixVersionLabel.setText("Using SoundHelix version: " + VersionUtils.getVersion());
        } catch (Exception e) {
            helixVersionLabel.setText(e.getMessage().toString());
        } catch (NoClassDefFoundError e) {
            helixVersionLabel.setText("Cannot find module " + e.getMessage());
        }
        
        // Display the application's name as a header with a larger font
        headerLabel.setFont(new Font("sans-serif", Font.BOLD, 24));
        
        // Set up constraints
        GridBagConstraints constraints = new GridBagConstraints();
        constraints.insets = new Insets(4, 4, 4, 4);
        
        // Add objects to information panel
        constraints.gridy = 0;
        infoPanel.add(headerLabel, constraints);
        
        constraints.gridy = 1;
        infoPanel.add(descriptionLabel, constraints);
        
        constraints.gridy = 2;
        infoPanel.add(helixVersionLabel, constraints);
        
        return infoPanel;
    }
    
    // Get tabbed pane with credits and license.
    private static JTabbedPane getMainPane() {
        // Set up tabbed pane and panels
        JTabbedPane mainPane = new JTabbedPane();
        JPanel creditsPanel = getCreditsPanel();
        JPanel licensePanel = getLicensePanel();
        
        // Add panels to pane as tabs.
        mainPane.add("Credits", creditsPanel);
        mainPane.add("License", licensePanel);
        
        return mainPane;
    }
    
    // Get a panel containing credits for UltrasonicHelix
    private static JPanel getCreditsPanel() {
        // Set up panel and text area
        JPanel creditsPanel = new JPanel();
        JTextArea creditsTextArea = new JTextArea();
        
        creditsPanel.setLayout(new BorderLayout());
        
        // Text area configuration
        creditsTextArea.setEditable(false);
        creditsTextArea.setText(
            "UltrasonicMadness <contact@ultrasonicmadness.org> - UltrasonicHelix developer\n" +
            "Thomas Schürger <thomas@schuerger.com> - SoundHelix developer"
        );
        
        // Add objects to main frame
        creditsPanel.add(new JScrollPane(creditsTextArea));
        return creditsPanel;
    }
    
    // Get a panel containing information about the program's license
    private static JPanel getLicensePanel() {
        // Set up panel and text area
        JPanel licensePanel = new JPanel();
        JTextArea licenseTextArea = new JTextArea();
        
        licensePanel.setLayout(new BorderLayout());
        
        // Text area configuration.
        licenseTextArea.setEditable(false);
        licenseTextArea.setText(
            "This program is free software: you can redistribute it and/or modify\n" +
            "it under the terms of the GNU General Public License as published by\n" +
            "the Free Software Foundation, either version 3 of the License, or\n" +
            "(at your option) any later version.\n\n" +

            "This program is distributed in the hope that it will be useful,\n" +
            "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" +
            "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n" +
            "GNU General Public License for more details.\n\n" +

            "You should have received a copy of the GNU General Public License\n" +
            "along with this program.  If not, see <http://www.gnu.org/licenses/>."
        );
        
        // Add text area to panel.
        licensePanel.add(new JScrollPane(licenseTextArea));
        return licensePanel;
    }
    
    // Get a panel containing a right-aligned close button.
    private static JPanel getButtonPanel() {
        // Set up the button and the panel
        JPanel buttonPanel = new JPanel();
        JButton closeButton = new JButton("Close");
        
        // Set up the layout
        buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
        
        // Add listener to button
        closeButton.addActionListener(e -> {
            mainWindow.dispose(); // Closes the about box
        });
        
        // Add the button to the panel
        buttonPanel.add(closeButton);
        return buttonPanel;
    }
}

[See repo JSON]