comparison java/src/uk/ac/qmul/eecs/ccmi/simpletemplate/SpeechWizardDialog.java @ 0:78b7fc5391a2

first import, outcome of NIME 2014 hackaton
author Fiore Martin <f.martin@qmul.ac.uk>
date Tue, 08 Jul 2014 16:28:59 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:78b7fc5391a2
1 /*
2 CCmI Editor - A Collaborative Cross-Modal Diagram Editing Tool
3
4 Copyright (C) 2011 Queen Mary University of London (http://ccmi.eecs.qmul.ac.uk/)
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 package uk.ac.qmul.eecs.ccmi.simpletemplate;
21
22 import java.awt.Frame;
23 import java.awt.event.ActionEvent;
24 import java.awt.event.KeyEvent;
25 import java.util.ResourceBundle;
26
27 import javax.swing.AbstractAction;
28 import javax.swing.JButton;
29 import javax.swing.JComponent;
30 import javax.swing.JRootPane;
31 import javax.swing.KeyStroke;
32 import javax.swing.event.ChangeEvent;
33
34 import jwizardcomponent.dialog.SimpleJWizardDialog;
35
36 /*
37 * The dialog where the template wizard is displayed
38 *
39 * @see Wizard
40 *
41 */
42 @SuppressWarnings("serial")
43 public class SpeechWizardDialog extends SimpleJWizardDialog {
44 public SpeechWizardDialog(Frame owner){
45 super(owner,true);
46 finished = false;
47
48 ResourceBundle resources = ResourceBundle.getBundle(getClass().getName());
49 setSize(350, 200);
50 setTitle(resources.getString("dialog.wizard.title"));
51 setLocationRelativeTo(owner);
52
53 JButton button;
54 button = getWizardComponents().getNextButton();
55 button.setText(resources.getString("button.next.label"));
56 button.getAccessibleContext().setAccessibleName(resources.getString("button.next.speech"));
57
58 button = getWizardComponents().getBackButton();
59 button.setText(resources.getString("button.previous.label"));
60 button.getAccessibleContext().setAccessibleName(resources.getString("button.previous.speech"));
61
62 button = getWizardComponents().getCancelButton();
63 button.setText(resources.getString("button.cancel.label"));
64
65 button = getWizardComponents().getFinishButton();
66 button.setText(resources.getString("button.finish.label"));
67 button.addChangeListener(new javax.swing.event.ChangeListener(){
68 @Override
69 public void stateChanged(ChangeEvent e) {
70 ((JButton)e.getSource()).setEnabled(finished);
71 }
72 });
73 JRootPane rootPane = getRootPane();
74 rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0), "close");
75 rootPane.getActionMap().put("close", new AbstractAction(){
76 @Override
77 public void actionPerformed(ActionEvent arg0) {
78 dispose();
79 }
80 });
81 }
82
83 /**
84 * Enables or disables the finish button.
85 * @param enabled {@code true} to enable the button, {@code false} to disable
86 */
87 public void setFinishButtonEnabled(boolean enabled){
88 finished = enabled;
89 getWizardComponents().getFinishButton().setEnabled(true);
90 }
91
92 private boolean finished;
93 }
94