2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 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;
27 import java.awt.event.*;
36 public class GCutAndPasteTransfer extends JInternalFrame
38 protected JTextArea textarea = new JTextArea();
40 protected JScrollPane scrollPane = new JScrollPane();
42 BorderLayout borderLayout1 = new BorderLayout();
44 JMenuBar editMenubar = new JMenuBar();
46 JMenu editMenu = new JMenu();
48 JMenuItem copyItem = new JMenuItem();
50 JMenuItem pasteMenu = new JMenuItem();
52 BorderLayout borderLayout2 = new BorderLayout();
54 protected JPanel inputButtonPanel = new JPanel();
56 protected JButton ok = new JButton();
58 JButton cancel = new JButton();
60 JMenuItem selectAll = new JMenuItem();
62 JMenu jMenu1 = new JMenu();
64 JMenuItem save = new JMenuItem();
67 * Creates a new GCutAndPasteTransfer object.
69 public GCutAndPasteTransfer()
73 setJMenuBar(editMenubar);
87 private void jbInit() throws Exception
89 scrollPane.setBorder(null);
90 ok.setFont(JvSwingUtils.getLabelFont());
91 ok.setText(MessageManager.getString("label.new_window"));
92 ok.addActionListener(new ActionListener()
94 public void actionPerformed(ActionEvent e)
96 ok_actionPerformed(e);
99 cancel.setText(MessageManager.getString("action.close"));
100 cancel.addActionListener(new ActionListener()
102 public void actionPerformed(ActionEvent e)
104 cancel_actionPerformed(e);
107 textarea.setBorder(null);
109 selectAll.setText(MessageManager.getString("action.select_all"));
110 selectAll.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
111 java.awt.event.KeyEvent.VK_A, Toolkit.getDefaultToolkit()
112 .getMenuShortcutKeyMask(), false));
113 selectAll.addActionListener(new ActionListener()
115 public void actionPerformed(ActionEvent e)
117 selectAll_actionPerformed(e);
120 jMenu1.setText(MessageManager.getString("action.file"));
121 save.setText(MessageManager.getString("action.save"));
122 save.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
123 java.awt.event.KeyEvent.VK_S, Toolkit.getDefaultToolkit()
124 .getMenuShortcutKeyMask(), false));
125 save.addActionListener(new ActionListener()
127 public void actionPerformed(ActionEvent e)
129 save_actionPerformed(e);
132 copyItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
133 java.awt.event.KeyEvent.VK_C, Toolkit.getDefaultToolkit()
134 .getMenuShortcutKeyMask(), false));
135 pasteMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
136 java.awt.event.KeyEvent.VK_V, Toolkit.getDefaultToolkit()
137 .getMenuShortcutKeyMask(), false));
138 editMenubar.add(jMenu1);
139 editMenubar.add(editMenu);
140 textarea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 12));
141 textarea.addMouseListener(new java.awt.event.MouseAdapter()
143 public void mousePressed(MouseEvent e)
145 textarea_mousePressed(e);
148 editMenu.setText(MessageManager.getString("action.edit"));
149 pasteMenu.setText(MessageManager.getString("action.paste"));
150 pasteMenu.addActionListener(new ActionListener()
152 public void actionPerformed(ActionEvent e)
154 pasteMenu_actionPerformed(e);
157 copyItem.setText(MessageManager.getString("action.copy"));
158 copyItem.addActionListener(new ActionListener()
160 public void actionPerformed(ActionEvent e)
162 copyItem_actionPerformed(e);
165 this.getContentPane().setLayout(borderLayout2);
166 scrollPane.setBorder(null);
167 scrollPane.getViewport().add(textarea, null);
168 editMenu.add(selectAll);
169 editMenu.add(copyItem);
170 editMenu.add(pasteMenu);
171 this.getContentPane().add(scrollPane, java.awt.BorderLayout.CENTER);
172 inputButtonPanel.add(ok);
173 inputButtonPanel.add(cancel);
183 public void textarea_mousePressed(MouseEvent e)
194 public void copyItem_actionPerformed(ActionEvent e)
204 public void pasteMenu_actionPerformed(ActionEvent e)
214 public void ok_actionPerformed(ActionEvent e)
224 public void cancel_actionPerformed(ActionEvent e)
228 public void selectAll_actionPerformed(ActionEvent e)
230 textarea.selectAll();
233 public void save_actionPerformed(ActionEvent e)