Mercurial > hg > cmdp
view src/uk/ac/qmul/eecs/depic/daw/gui/PreferencesDialog.java @ 2:c0412c81d274
Added documentation
author | Fiore Martin <f.martin@qmul.ac.uk> |
---|---|
date | Thu, 18 Feb 2016 18:35:26 +0000 |
parents | 3074a84ef81e |
children |
line wrap: on
line source
/* Cross-Modal DAW Prototype - Prototype of a simple Cross-Modal Digital Audio Workstation. Copyright (C) 2015 Queen Mary University of London (http://depic.eecs.qmul.ac.uk/) 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 uk.ac.qmul.eecs.depic.daw.gui; import java.awt.BorderLayout; import java.awt.Color; import java.awt.FlowLayout; import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JPanel; import javax.swing.JTabbedPane; /** * * Preference Dialog. It contains preference panels and when OK button is pressed * it calls {@code savePrefs()} on all the panels. * */ public class PreferencesDialog extends JDialog { private static final long serialVersionUID = 1L; private final JTabbedPane content = new JTabbedPane(); private ArrayList<PreferencesPanel> panels; private ActionListener actionListener = new ActionListener(){ @Override public void actionPerformed(ActionEvent evt) { if("OK".equals(evt.getActionCommand())){ savePrefs(); dispose(); }else if("Cancel".equals(evt.getActionCommand())){ dispose(); } } }; /** * Create the dialog. */ public PreferencesDialog(Frame owner) { super(owner,"Preferences",true); panels = new ArrayList<>(); setBounds(100, 100, 387, 269); getContentPane().setLayout(new BorderLayout()); //content.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(content, BorderLayout.CENTER); { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); buttonPane.setBorder(BorderFactory.createMatteBorder(1,0,0,0,Color.GRAY)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton okButton = new JButton("OK"); okButton.setActionCommand("OK"); okButton.addActionListener(actionListener); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton("Cancel"); cancelButton.setActionCommand("Cancel"); cancelButton.addActionListener(actionListener); buttonPane.add(cancelButton); } } } private void savePrefs(){ for(PreferencesPanel p : panels) p.savePrefs(); } public void addPanel(PreferencesPanel p){ panels.add(p); content.add(p,p.getTitle()); } }