2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2)
3 * Copyright (C) 2015 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.JOptionPane;
32 import javax.swing.JPanel;
33 import javax.swing.JTextField;
35 public class EditNameDialog
37 JTextField id, description;
39 JButton ok = new JButton(MessageManager.getString("action.accept"));
41 JButton cancel = new JButton(MessageManager.getString("action.cancel"));
43 boolean accept = false;
45 public String getName()
50 public String getDescription()
52 if (description.getText().length() < 1)
58 return description.getText();
62 public EditNameDialog(String name, String desc, String label1,
63 String label2, String title, JComponent parent)
65 JLabel idlabel = new JLabel(label1);
66 JLabel desclabel = new JLabel(label2);
67 idlabel.setFont(new Font("Courier", Font.PLAIN, 12));
68 desclabel.setFont(new Font("Courier", Font.PLAIN, 12));
69 id = new JTextField(name, 40);
70 description = new JTextField(desc, 40);
71 JPanel panel = new JPanel(new BorderLayout());
72 JPanel panel2 = new JPanel(new BorderLayout());
73 panel2.add(idlabel, BorderLayout.WEST);
74 panel2.add(id, BorderLayout.CENTER);
75 panel.add(panel2, BorderLayout.NORTH);
76 if (desc != null || label2 != null)
78 panel2 = new JPanel(new BorderLayout());
79 panel2.add(desclabel, BorderLayout.WEST);
80 panel2.add(description, BorderLayout.CENTER);
81 panel.add(panel2, BorderLayout.SOUTH);
83 int reply = JOptionPane.showInternalConfirmDialog(parent, panel, title,
84 JOptionPane.OK_CANCEL_OPTION);
85 if (!parent.requestFocusInWindow())
87 System.err.println("Bad focus for dialog!");
89 if (reply == JOptionPane.OK_OPTION)