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.
21 package jalview.jbgui;
23 import jalview.gui.JvSwingUtils;
24 import jalview.util.MessageManager;
26 import java.awt.BorderLayout;
28 import java.awt.Toolkit;
29 import java.awt.event.ActionEvent;
30 import java.awt.event.ActionListener;
31 import java.awt.event.MouseEvent;
33 import javax.swing.JButton;
34 import javax.swing.JInternalFrame;
35 import javax.swing.JMenu;
36 import javax.swing.JMenuBar;
37 import javax.swing.JMenuItem;
38 import javax.swing.JPanel;
39 import javax.swing.JScrollPane;
40 import javax.swing.JTextArea;
48 public class GCutAndPasteTransfer extends JInternalFrame
50 protected JTextArea textarea = new JTextArea();
52 protected JScrollPane scrollPane = new JScrollPane();
54 BorderLayout borderLayout1 = new BorderLayout();
56 JMenuBar editMenubar = new JMenuBar();
58 JMenu editMenu = new JMenu();
60 JMenuItem copyItem = new JMenuItem();
62 JMenuItem pasteMenu = new JMenuItem();
64 BorderLayout borderLayout2 = new BorderLayout();
66 protected JPanel inputButtonPanel = new JPanel();
68 protected JButton ok = new JButton();
70 JButton cancel = new JButton();
72 JMenuItem selectAll = new JMenuItem();
74 JMenu jMenu1 = new JMenu();
76 JMenuItem save = new JMenuItem();
79 * Creates a new GCutAndPasteTransfer object.
81 public GCutAndPasteTransfer()
85 setJMenuBar(editMenubar);
99 private void jbInit() throws Exception
101 scrollPane.setBorder(null);
102 ok.setFont(JvSwingUtils.getLabelFont());
103 ok.setText(MessageManager.getString("label.new_window"));
104 ok.addActionListener(new ActionListener()
107 public void actionPerformed(ActionEvent e)
109 ok_actionPerformed(e);
112 cancel.setText(MessageManager.getString("action.close"));
113 cancel.addActionListener(new ActionListener()
116 public void actionPerformed(ActionEvent e)
118 cancel_actionPerformed(e);
121 textarea.setBorder(null);
123 selectAll.setText(MessageManager.getString("action.select_all"));
124 selectAll.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
125 java.awt.event.KeyEvent.VK_A,
126 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false));
127 selectAll.addActionListener(new ActionListener()
130 public void actionPerformed(ActionEvent e)
132 selectAll_actionPerformed(e);
135 jMenu1.setText(MessageManager.getString("action.file"));
136 save.setText(MessageManager.getString("action.save"));
137 save.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
138 java.awt.event.KeyEvent.VK_S,
139 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false));
140 save.addActionListener(new ActionListener()
143 public void actionPerformed(ActionEvent e)
145 save_actionPerformed(e);
148 copyItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
149 java.awt.event.KeyEvent.VK_C,
150 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false));
151 pasteMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
152 java.awt.event.KeyEvent.VK_V,
153 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false));
154 editMenubar.add(jMenu1);
155 editMenubar.add(editMenu);
156 textarea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 12));
157 textarea.addMouseListener(new java.awt.event.MouseAdapter()
160 public void mousePressed(MouseEvent e)
162 textarea_mousePressed(e); // on Mac
166 public void mouseReleased(MouseEvent e)
168 textarea_mousePressed(e); // on Windows
171 editMenu.setText(MessageManager.getString("action.edit"));
172 pasteMenu.setText(MessageManager.getString("action.paste"));
173 pasteMenu.addActionListener(new ActionListener()
176 public void actionPerformed(ActionEvent e)
178 pasteMenu_actionPerformed(e);
181 copyItem.setText(MessageManager.getString("action.copy"));
182 copyItem.addActionListener(new ActionListener()
185 public void actionPerformed(ActionEvent e)
187 copyItem_actionPerformed(e);
190 this.getContentPane().setLayout(borderLayout2);
191 scrollPane.setBorder(null);
192 scrollPane.getViewport().add(textarea, null);
193 editMenu.add(selectAll);
194 editMenu.add(copyItem);
195 editMenu.add(pasteMenu);
196 this.getContentPane().add(scrollPane, java.awt.BorderLayout.CENTER);
197 inputButtonPanel.add(ok);
198 inputButtonPanel.add(cancel);
208 public void textarea_mousePressed(MouseEvent e)
219 public void copyItem_actionPerformed(ActionEvent e)
229 public void pasteMenu_actionPerformed(ActionEvent e)
239 public void ok_actionPerformed(ActionEvent e)
249 public void cancel_actionPerformed(ActionEvent e)
253 public void selectAll_actionPerformed(ActionEvent e)
255 textarea.selectAll();
258 public void save_actionPerformed(ActionEvent e)