🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: aus.computers.java
2 messages
2 total messages Started by Michael Rowlands Tue, 29 Jun 1999 00:00
Help needed using textArea
#1174
Author: Michael Rowlands
Date: Tue, 29 Jun 1999 00:00
40 lines
2112 bytes
Hi,
I wondered if anyone could tell me how to capture a users selection in the
textArea
i.e. when they want to cut and paste. As my methods currently overwrite all
text in the textArea, how do you get where the cursor  is currently
positioned and paste the text there. i.e.

   else
   if (cmd.equals(cutText))
   {
   StringSelection data = new StringSelection(textArea.getText());
   clipboard.setContents(data, data);
   textArea.setText("");
   // Think about select selection etc as setText does the lot
   }
   else
   if (cmd.equals(pasteText))
   {
        Transferable clipData = clipboard.getContents(this);
        String s;
        try
            {
             s =
(String)(clipData.getTransferData(DataFlavor.stringFlavor));
            }
            catch (Exception evtt)
             {
             s = evtt.toString();
            }
        textArea.setText(s);
// I HAVE TRIED THE FOLLOWING
    // need anotrher var "int"  textArea.insert(s);
    // try insert from that Aussie "StringBuffer.insert(int, String);"
    // testing paste from editMan, doesnt work
    // textArea.paste(s);
   }

Cheers

Michael Rowlands
Re: Help needed using textArea
#1175
Author: Mr. Tines
Date: Tue, 29 Jun 1999 00:00
21 lines
1748 bytes
###

On Tue, 29 Jun 1999 11:38:03 +1200, in <930613456.245685@Chaos.es.co.nz>
          "Michael Rowlands" <michaelrowlands@bigfoot.com> wrote.....

> I wondered if anyone could tell me how to capture a users selection in
the
> textArea

use the getSelectedText() method and its related methods
inherited from java.awt.TextComponent

-- PGPfingerprint: BC01 5527 B493 7C9B  3C54 D1B7 248C 08BC --
 _______ {pegwit v8 public key =581cbf05be9899262ab4bb6a08470}
/_  __(_)__  ___ ___     {69c10bcfbca894a5bf8d208d001b829d4d0}
 / / / / _ \/ -_|_-<      www.geocities.com/SiliconValley/1394
/_/ /_/_//_/\__/___/@windsong.demon.co.uk      PGP key on page

### end pegwit v8 signed text
e354bf9c006794e58973b2e676ad9b652611ce715fa8015fd358c21b9f6e
768e1a802224e5777a82ed5b6c4e58dd7807076c991ebffb58538b27e509
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads