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;
28 public class EditNameDialog
30 JTextField id, description;
32 JButton ok = new JButton(MessageManager.getString("action.accept"));
34 JButton cancel = new JButton(MessageManager.getString("action.cancel"));
36 boolean accept = false;
38 public String getName()
43 public String getDescription()
45 if (description.getText().length() < 1)
51 return description.getText();
55 public EditNameDialog(String name, String desc, String label1,
56 String label2, String title, JComponent parent)
58 JLabel idlabel = new JLabel(label1);
59 JLabel desclabel = new JLabel(label2);
60 idlabel.setFont(new Font("Courier", Font.PLAIN, 12));
61 desclabel.setFont(new Font("Courier", Font.PLAIN, 12));
62 id = new JTextField(name, 40);
63 description = new JTextField(desc, 40);
64 JPanel panel = new JPanel(new BorderLayout());
65 JPanel panel2 = new JPanel(new BorderLayout());
66 panel2.add(idlabel, BorderLayout.WEST);
67 panel2.add(id, BorderLayout.CENTER);
68 panel.add(panel2, BorderLayout.NORTH);
69 if (desc != null || label2 != null)
71 panel2 = new JPanel(new BorderLayout());
72 panel2.add(desclabel, BorderLayout.WEST);
73 panel2.add(description, BorderLayout.CENTER);
74 panel.add(panel2, BorderLayout.SOUTH);
76 int reply = JOptionPane.showInternalConfirmDialog(parent, panel, title,
77 JOptionPane.OK_CANCEL_OPTION);
78 if (!parent.requestFocusInWindow())
80 System.err.println("Bad focus for dialog!");
82 if (reply == JOptionPane.OK_OPTION)