The Artima Developer Community
Sponsored Link

Java Answers Forum
cutText Method

1 reply on 1 page. Most recent reply: Jul 26, 2004 11:48 PM by Firmin Dani

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Nate Hultman

Posts: 8
Nickname: vtgunner14
Registered: May, 2004

cutText Method Posted: Jul 26, 2004 12:30 PM
Reply to this message Reply
Advertisement
I was wondering if anyone here knows how to cut text. i was given some of the code and i was able to get alittle bit done, but i cant figure out the rest. Could someone please help me out with this. This is the last part of my program that I have to do.

public void cutText()
        {
             tempText = area.getSelectedText();   // get text highlighted to be cut
             int lenCut = tempText.length();    // size of cut text
             String oldText = area.getText();  // get all text
             String newText = area.getText();
             int lenAll = oldText.length();   // size of all text
             int start = area.getSelectionStart();   // get cursor position of beginning of highlight
             int end = area.getSelectionEnd() ;    // get cursor position of end of highlighted text
               // Get the substring of oldText from beginning to start of highlight
               // Get the substring of oldText from end  of highlighted text to end of oldText (lenAll)
               // Concatenate the two substrings and place in String newText
               // place one statement here to do the above 3 commented lines
               // Place your line here
             if (oldText.equals(tempText)) return;
             area.setText(""); // set Text of area to be the newText
             area.setCaretPosition(start );//places cursor at the beginning of where cut was made
        }
 


Firmin Dani

Posts: 2
Nickname: firdan
Registered: Jul, 2004

Re: cutText Method Posted: Jul 26, 2004 11:48 PM
Reply to this message Reply
Hi,
I think you are using a JTextBox and the code gets the selected text and places it in the temp variable and removes it form the display but i am not clear what exactly u want coz there are enough comments to understand it. If u can specify the exact problem then i might help u out.
regards,
Firmin Dani

Flat View: This topic has 1 reply on 1 page
Topic: pixelgrabber() Previous Topic   Next Topic Topic: inverse interpolation

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use