83d19fc3f732eead4d2318089d6eac4ef2d0284d
[jalviewjs.git] / unused / appletgui / JVDialog.java
1 /*\r
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)\r
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors\r
4  * \r
5  * This file is part of Jalview.\r
6  * \r
7  * Jalview is free software: you can redistribute it and/or\r
8  * modify it under the terms of the GNU General Public License \r
9  * as published by the Free Software Foundation, either version 3\r
10  * of the License, or (at your option) any later version.\r
11  *  \r
12  * Jalview is distributed in the hope that it will be useful, but \r
13  * WITHOUT ANY WARRANTY; without even the implied warranty \r
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR \r
15  * PURPOSE.  See the GNU General Public License for more details.\r
16  * \r
17  * You should have received a copy of the GNU General Public License\r
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.\r
19  * The Jalview Authors are detailed in the 'AUTHORS' file.\r
20  */\r
21 package jalview.appletgui;\r
22 \r
23 import java.awt.BorderLayout;\r
24 import java.awt.FlowLayout;\r
25 import java.awt.event.ActionEvent;\r
26 import java.awt.event.ActionListener;\r
27 \r
28 import javax.swing.JButton;\r
29 import javax.swing.JDialog;\r
30 import javax.swing.JFrame;\r
31 import javax.swing.JPanel;\r
32 \r
33 public class JVDialog extends JDialog implements ActionListener\r
34 {\r
35   AlignmentPanel ap;\r
36 \r
37   JPanel buttonPanel;\r
38 \r
39   JButton ok = new JButton("Accept");\r
40 \r
41   JButton cancel = new JButton("Cancel");\r
42 \r
43   boolean accept = false;\r
44 \r
45   JFrame owner;\r
46 \r
47   public JVDialog(JFrame owner, String title, boolean modal, int width,\r
48           int height)\r
49   {\r
50     super(owner, title, modal);\r
51     this.owner = owner;\r
52 \r
53     height += owner.getInsets().top + getInsets().bottom;\r
54 \r
55     setBounds(owner.getBounds().x + (owner.getSize().width - width) / 2,\r
56             owner.getBounds().y + (owner.getSize().height - height) / 2,\r
57             width, height);\r
58   }\r
59 \r
60   void setMainPanel(JPanel panel)\r
61   {\r
62     add(panel, BorderLayout.NORTH);\r
63 \r
64     buttonPanel = new JPanel(new FlowLayout());\r
65 \r
66     buttonPanel.add(ok);\r
67     buttonPanel.add(cancel);\r
68     ok.addActionListener(this);\r
69     cancel.addActionListener(this);\r
70 \r
71     add(buttonPanel, BorderLayout.SOUTH);\r
72 \r
73     pack();\r
74 \r
75   }\r
76 \r
77   public void actionPerformed(ActionEvent evt)\r
78   {\r
79     if (evt.getSource() == ok)\r
80     {\r
81       accept = true;\r
82     }\r
83 \r
84     setVisible(false);\r
85   }\r
86 \r
87 }\r