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.2.0 :: src / org / ultrasonicmadness / madhelix / dialogs /

AboutBox.java

/*
 * MadHelix is a Java Swing-based GUI frontend for SoundHelix.
 * Copyright (C) 2018 UltrasonicMadness
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3 only,
 * as published by the Free Software Foundation.
 *
 * 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.madhelix.dialogs;

// Get SoundHelix version
import org.ultrasonicmadness.madhelix.utils.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;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

// Swing widgets
import javax.swing.JButton;
import javax.swing.JDialog;
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 extends JDialog
{
    private JPanel infoPanel = new JPanel();
    private JTabbedPane mainPane = new JTabbedPane();
    private JPanel creditsPanel = new JPanel();
    private JPanel licensePanel = new JPanel();
    private JPanel buttonPanel = new JPanel();
    
    public AboutBox(JFrame mainWindow)
    {
        super(mainWindow, true);
        initAboutBox();
    }
    
    private void initAboutBox()
    {
        // Declare and initialize objects
        this.setTitle("About");
        JPanel mainPanel = new JPanel();
        
        // Setup
        setUpInfoPanel();
        setUpMainPane();
        setUpButtonPanel();
        
        // 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);
        
        // Set up the main window
        this.add(mainPanel);
        this.setSize(540, 405);
        this.setResizable(false);
        this.setLocationRelativeTo(null);
    }
    
    private void setUpInfoPanel()
    {
        infoPanel.setLayout(new GridBagLayout());
        
        // Set up labels
        JLabel headerLabel = new JLabel("MadHelix " +
                VersionUtils.getMadHelixVersionAsString());
        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.getSoundHelixVersionAsString());
        }
        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);
    }
    
    private void setUpMainPane()
    {
        setUpCreditsPanel();
        setUpLicensePanel();
        
        // Add panels to pane as tabs.
        mainPane.add("Credits", creditsPanel);
        mainPane.add("License", licensePanel);
    }
    
    private void setUpCreditsPanel()
    {
        // Set up text area
        JTextArea textArea = new JTextArea();
        
        creditsPanel.setLayout(new BorderLayout());
        
        // Text area configuration
        textArea.setEditable(false);
        textArea.setText(
            "UltrasonicMadness <contact@ultrasonicmadness.org> - MadHelix developer\n" +
            "Thomas Sch\u00FCrger <thomas@schuerger.com> - SoundHelix developer\n" + 
            "GNOME Project <http://www.gnome.org/> - Icons from the Adwaita Icon Theme"
        );
        
        // Add objects to main frame
        creditsPanel.add(new JScrollPane(textArea));
    }
    
    private void setUpLicensePanel()
    {
        // Set up text area
        JTextArea textArea = new JTextArea();
        
        licensePanel.setLayout(new BorderLayout());
        
        // Text area configuration
        textArea.setEditable(false);
        textArea.setText(
            "This program is free software: you can redistribute it and/or modify\n" +
            "it under the terms of the GNU General Public License version 3 only,\n" +
            "as published by the Free Software Foundation.\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 objects to main frame
        licensePanel.add(new JScrollPane(textArea));
    }
    
    private void setUpButtonPanel()
    {
        // Set up the button
        JButton closeButton = new JButton("Close");
        
        // Set up the layout
        buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
        
        // Add listener to button
        closeButton.addActionListener(e ->
        {
            this.dispose();
        });
        
        // Add the button to the panel
        buttonPanel.add(closeButton);
    }
}

[See repo JSON]