The Artima Developer Community
Sponsored Link

Java Answers Forum
Help with Cut Text Method

0 replies on 1 page.

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 0 replies on 1 page
B J

Posts: 1
Nickname: bnizzle
Registered: Dec, 2005

Help with Cut Text Method Posted: Dec 6, 2005 6:46 AM
Reply to this message Reply
Advertisement
I'm working on a program but I cannot figure out how to do the following commented out lines of text in bold below...can anyone help?

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
int lenAll = oldText.length(); // size of all text
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

area.setText(newText); // set Text of area to be the newText
area.setCaretPosition(start );//places cursor at the beginning of where cut was made
}

Thanks,'
-BJ

Topic: program that create objects of the class, & use the methods of the class Previous Topic   Next Topic Topic: NullPointerException

Sponsored Links



Google
  Web Artima.com   

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