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.2 :: src / org / ultrasonicmadness / ultrasonichelix / panels /

ControlsPanel.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.panels;

// AWT event modules
import java.awt.event.ActionListener;

// AWT widgets
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

// Swing widgets
import javax.swing.JButton;
import javax.swing.JPanel;

public class ControlsPanel extends JPanel {
    // Buttons
    private JButton playButton;
    private JButton stopButton;
    private JButton aboutButton;
    
    public ControlsPanel() {
        // Set up buttons
        playButton = new JButton("\u25B6");
        stopButton = new JButton("\u25A0");
        aboutButton = new JButton("About");
        
        addButtons();
    }
    
    public void addButtons() {
        // Set up layout
        this.setLayout(new GridBagLayout());
        
        GridBagConstraints constraints = new GridBagConstraints();
        constraints.insets = new Insets(2, 2, 2, 2);
        constraints.fill = GridBagConstraints.HORIZONTAL;
        
        constraints.weightx = 0;
        this.add(playButton, constraints);
        this.add(stopButton, constraints);
        
        // Add a blank panel to separate player controls and the about button
        constraints.weightx = 1;
        this.add(new JPanel(), constraints);
        
        constraints.weightx = 0;
        this.add(aboutButton, constraints);
    }
    
    // Function to enable and disable player controls
    public void setControlsEnabled(boolean enabled) {
        playButton.setEnabled(enabled);
        stopButton.setEnabled(enabled);
    }
    
    // Functions to add action listeners to buttons
    public void addPlayAction(ActionListener listener) {
        playButton.addActionListener(listener);
    }
    
    public void addStopAction(ActionListener listener) {
        stopButton.addActionListener(listener);
    }
    
    public void addAboutAction(ActionListener listener) {
        aboutButton.addActionListener(listener);
    }
}

[See repo JSON]