From: amwaterhouse Date: Fri, 7 Oct 2005 10:22:57 +0000 (+0000) Subject: Select all cutandpaste X-Git-Tag: Release_2_07~64 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=3cc7159787bd31859f7bc27916e7ff854b895280;p=jalview.git Select all cutandpaste --- diff --git a/src/jalview/gui/CutAndPasteTransfer.java b/src/jalview/gui/CutAndPasteTransfer.java index db6fb18..a10f433 100755 --- a/src/jalview/gui/CutAndPasteTransfer.java +++ b/src/jalview/gui/CutAndPasteTransfer.java @@ -39,19 +39,25 @@ import javax.swing.*; */ public class CutAndPasteTransfer extends GCutAndPasteTransfer { + + public CutAndPasteTransfer() + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + textarea.requestFocus(); + } + }); + + } + /** * DOCUMENT ME! */ public void setForInput() { getContentPane().add(inputButtonPanel, java.awt.BorderLayout.SOUTH); - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - textarea.requestFocus(); - } - }); } /** @@ -81,8 +87,9 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer */ public void copyItem_actionPerformed(ActionEvent e) { + textarea.getSelectedText(); Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard(); - c.setContents(new StringSelection(textarea.getText()), null); + c.setContents(new StringSelection(textarea.getSelectedText()), null); } /** diff --git a/src/jalview/jbgui/GCutAndPasteTransfer.java b/src/jalview/jbgui/GCutAndPasteTransfer.java index 384f09e..a917ebe 100755 --- a/src/jalview/jbgui/GCutAndPasteTransfer.java +++ b/src/jalview/jbgui/GCutAndPasteTransfer.java @@ -47,8 +47,9 @@ public class GCutAndPasteTransfer extends JInternalFrame protected JPanel inputButtonPanel = new JPanel(); JButton ok = new JButton(); JButton cancel = new JButton(); + JMenuItem selectAll = new JMenuItem(); - /** + /** * Creates a new GCutAndPasteTransfer object. */ public GCutAndPasteTransfer() @@ -104,7 +105,15 @@ public class GCutAndPasteTransfer extends JInternalFrame } } }); - editMenubar.add(editMenu); + selectAll.setText("Select All"); + selectAll.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + selectAll_actionPerformed(e); + } + }); + editMenubar.add(editMenu); textarea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 12)); textarea.addMouseListener(new java.awt.event.MouseAdapter() { @@ -133,7 +142,8 @@ public class GCutAndPasteTransfer extends JInternalFrame this.getContentPane().setLayout(borderLayout2); scrollPane.setBorder(null); scrollPane.getViewport().add(textarea, null); - editMenu.add(copyItem); + editMenu.add(selectAll); + editMenu.add(copyItem); editMenu.add(pasteMenu); this.getContentPane().add(scrollPane, java.awt.BorderLayout.CENTER); inputButtonPanel.add(ok); @@ -197,4 +207,9 @@ public class GCutAndPasteTransfer extends JInternalFrame throws PropertyVetoException { } + + public void selectAll_actionPerformed(ActionEvent e) + { + textarea.selectAll(); + } }