2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.util.MessageManager;
25 import java.awt.BorderLayout;
28 import javax.swing.JButton;
29 import javax.swing.JComponent;
30 import javax.swing.JLabel;
31 import javax.swing.JPanel;
32 import javax.swing.JTextField;
34 public class EditNameDialog
36 JTextField id, description;
38 JButton ok = new JButton(MessageManager.getString("action.accept"));
40 JButton cancel = new JButton(MessageManager.getString("action.cancel"));
42 boolean accept = false;
44 public String getName()
49 public String getDescription()
51 if (description.getText().length() < 1)
57 return description.getText();
61 public EditNameDialog(String name, String desc, String label1,
62 String label2, String title, JComponent parent)
64 JLabel idlabel = new JLabel(label1);
65 JLabel desclabel = new JLabel(label2);
66 idlabel.setFont(new Font("Courier", Font.PLAIN, 12));
67 desclabel.setFont(new Font("Courier", Font.PLAIN, 12));
68 id = new JTextField(name, 40);
69 description = new JTextField(desc, 40);
70 JPanel panel = new JPanel(new BorderLayout());
71 JPanel panel2 = new JPanel(new BorderLayout());
72 panel2.add(idlabel, BorderLayout.WEST);
73 panel2.add(id, BorderLayout.CENTER);
74 panel.add(panel2, BorderLayout.NORTH);
75 if (desc != null || label2 != null)
77 panel2 = new JPanel(new BorderLayout());
78 panel2.add(desclabel, BorderLayout.WEST);
79 panel2.add(description, BorderLayout.CENTER);
80 panel.add(panel2, BorderLayout.SOUTH);
82 int reply = JvOptionPane.showInternalConfirmDialog(parent, panel, title,
83 JvOptionPane.OK_CANCEL_OPTION);
84 if (!parent.requestFocusInWindow())
86 System.err.println("Bad focus for dialog!");
88 if (reply == JvOptionPane.OK_OPTION)