1 |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
4 |
* Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
6 |
* This file is part of JSampler. |
7 |
* |
8 |
* JSampler is free software; you can redistribute it and/or modify |
9 |
* it under the terms of the GNU General Public License version 2 |
10 |
* as published by the Free Software Foundation. |
11 |
* |
12 |
* JSampler is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
16 |
* |
17 |
* You should have received a copy of the GNU General Public License |
18 |
* along with JSampler; if not, write to the Free Software |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
20 |
* MA 02111-1307 USA |
21 |
*/ |
22 |
|
23 |
package org.jsampler.view.std; |
24 |
|
25 |
import java.awt.BorderLayout; |
26 |
|
27 |
import java.awt.event.ActionEvent; |
28 |
import java.awt.event.ActionListener; |
29 |
|
30 |
import javax.swing.BorderFactory; |
31 |
import javax.swing.Box; |
32 |
import javax.swing.BoxLayout; |
33 |
import javax.swing.Icon; |
34 |
import javax.swing.JButton; |
35 |
import javax.swing.JLabel; |
36 |
import javax.swing.JPanel; |
37 |
|
38 |
import net.sf.juife.EnhancedDialog; |
39 |
import net.sf.juife.JuifeUtils; |
40 |
|
41 |
import org.jsampler.CC; |
42 |
|
43 |
import static org.jsampler.view.std.StdI18n.i18n; |
44 |
|
45 |
/** |
46 |
* |
47 |
* @author Grigor Iliev |
48 |
*/ |
49 |
public class JSQuitDlg extends EnhancedDialog { |
50 |
private final JButton btnExport = new JButton(i18n.getButtonLabel("JSQuitDlg.btnExport")); |
51 |
private final JButton btnQuit = new JButton(i18n.getButtonLabel("JSQuitDlg.btnQuit")); |
52 |
private final JButton btnDontQuit = new JButton(i18n.getButtonLabel("JSQuitDlg.btnDontQuit")); |
53 |
|
54 |
/** Creates a new instance of <code>JSQuitDlg</code> */ |
55 |
public |
56 |
JSQuitDlg(Icon questionIcon) { |
57 |
super(CC.getMainFrame()); |
58 |
getContentPane().setLayout(new BorderLayout()); |
59 |
|
60 |
JLabel l = new JLabel(i18n.getMessage("JSQuitDlg.sureToQuit?")); |
61 |
l.setIcon(questionIcon); |
62 |
l.setBorder(BorderFactory.createEmptyBorder(12, 12, 0, 12)); |
63 |
getContentPane().add(l); |
64 |
|
65 |
JPanel btnPane = new JPanel(); |
66 |
btnPane.setLayout(new BoxLayout(btnPane, BoxLayout.X_AXIS)); |
67 |
btnPane.add(btnExport); |
68 |
btnPane.add(Box.createRigidArea(new java.awt.Dimension(17, 0))); |
69 |
btnPane.add(Box.createGlue()); |
70 |
btnPane.add(btnQuit); |
71 |
btnPane.add(Box.createRigidArea(new java.awt.Dimension(5, 0))); |
72 |
btnPane.add(btnDontQuit); |
73 |
|
74 |
btnPane.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12)); |
75 |
|
76 |
getContentPane().add(btnPane, BorderLayout.SOUTH); |
77 |
pack(); |
78 |
|
79 |
setLocation(JuifeUtils.centerLocation(this, CC.getMainFrame())); |
80 |
|
81 |
btnQuit.requestFocus(); |
82 |
|
83 |
btnExport.addActionListener(new ActionListener() { |
84 |
public void |
85 |
actionPerformed(ActionEvent e) { |
86 |
StdA4n.a4n.exportSamplerConfig(); |
87 |
} |
88 |
}); |
89 |
|
90 |
btnQuit.addActionListener(new ActionListener() { |
91 |
public void |
92 |
actionPerformed(ActionEvent e) { |
93 |
onOk(); |
94 |
} |
95 |
}); |
96 |
|
97 |
btnDontQuit.addActionListener(new ActionListener() { |
98 |
public void |
99 |
actionPerformed(ActionEvent e) { |
100 |
onCancel(); |
101 |
} |
102 |
}); |
103 |
|
104 |
setCancelled(true); |
105 |
} |
106 |
|
107 |
protected void |
108 |
onOk() { |
109 |
setCancelled(false); |
110 |
setVisible(false); |
111 |
} |
112 |
|
113 |
protected void |
114 |
onCancel() { setVisible(false); } |
115 |
} |