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"));
126 javax.swing.KeyStroke
127 .getKeyStroke(java.awt.event.KeyEvent.VK_A,
128 jalview.util.ShortcutKeyMaskExWrapper
129 .getMenuShortcutKeyMaskEx(),
131 selectAll.addActionListener(new ActionListener()
134 public void actionPerformed(ActionEvent e)
136 selectAll_actionPerformed(e);
139 jMenu1.setText(MessageManager.getString("action.file"));
140 save.setText(MessageManager.getString("action.save"));
142 javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
143 jalview.util.ShortcutKeyMaskExWrapper
144 .getMenuShortcutKeyMaskEx(),
146 save.addActionListener(new ActionListener()
149 public void actionPerformed(ActionEvent e)
151 save_actionPerformed(e);
154 copyItem.setAccelerator(
155 javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
156 jalview.util.ShortcutKeyMaskExWrapper
157 .getMenuShortcutKeyMaskEx(),
161 javax.swing.KeyStroke
162 .getKeyStroke(java.awt.event.KeyEvent.VK_V,
163 jalview.util.ShortcutKeyMaskExWrapper
164 .getMenuShortcutKeyMaskEx(),
166 editMenubar.add(jMenu1);
167 editMenubar.add(editMenu);
168 textarea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 12));
169 textarea.addMouseListener(new java.awt.event.MouseAdapter()
172 public void mousePressed(MouseEvent e)
174 textarea_mousePressed(e); // on Mac
178 public void mouseReleased(MouseEvent e)
180 textarea_mousePressed(e); // on Windows
183 editMenu.setText(MessageManager.getString("action.edit"));
184 pasteMenu.setText(MessageManager.getString("action.paste"));
185 pasteMenu.addActionListener(new ActionListener()
188 public void actionPerformed(ActionEvent e)
190 pasteMenu_actionPerformed(e);
193 copyItem.setText(MessageManager.getString("action.copy"));
194 copyItem.addActionListener(new ActionListener()
197 public void actionPerformed(ActionEvent e)
199 copyItem_actionPerformed(e);
202 this.getContentPane().setLayout(borderLayout2);
203 scrollPane.setBorder(null);
204 scrollPane.getViewport().add(textarea, null);
205 editMenu.add(selectAll);
206 editMenu.add(copyItem);
207 editMenu.add(pasteMenu);
208 this.getContentPane().add(scrollPane, java.awt.BorderLayout.CENTER);
209 inputButtonPanel.add(ok);
210 inputButtonPanel.add(cancel);
220 public void textarea_mousePressed(MouseEvent e)
231 public void copyItem_actionPerformed(ActionEvent e)
241 public void pasteMenu_actionPerformed(ActionEvent e)
251 public void ok_actionPerformed(ActionEvent e)
261 public void cancel_actionPerformed(ActionEvent e)
265 public void selectAll_actionPerformed(ActionEvent e)
267 textarea.selectAll();
270 public void save_actionPerformed(ActionEvent e)