How to remove last char in a string by space

I have to implement backspace application(remove a last char in a string , when we pressed a button).
for ex: I enter the no
1234
instead of 1236
So when i press a button on the JWindow... it should display
123
so that i can enter 6 now.
I tried to display the string "123 " instead over "1234" but it is not working when the no background is specified. but works fine when a background color is specified.
The string is displayed as
Graphics2D g = (Graphics2D)window.getGraphics();
AttributedString as = new AttributedString(string, map);
g.drawString(as.getIterator(),x,y);
In the map, the background is set to NO_BACKGROUND.
Thanks and regards

Deja vu. I saw this kind of post before, and I'm sure
it was today.http://forum.java.sun.com/thread.jspa?threadID=588110&tstart=0
Here it is.

Similar Messages

  • How to remove empty char from a string

    Hi,
    In my code I should get numeric int numbers and convert them to 1 and 0 , concatenate thm to make an string ( 8 chars) . the problem I have is the empty chars as result of conversion from number to string
    so lets say pxiAnaIn=1 dutVdd=2 and dutOut=5 so then the output should be 10110001 but now the output is 10110  1 . could you please let me know how can I fix this problem
    thanks

    tintin_99 wrote:
    Hi,
    In my code I should get numeric int numbers and convert them to 1 and 0 , concatenate thm to make an string ( 8 chars) . the problem I have is the empty chars as result of conversion from number to string
    so lets say pxiAnaIn=1 dutVdd=2 and dutOut=5 so then the output should be 10110001 but now the output is 10110  1 . could you please let me know how can I fix this problem
    thanks
    You could make your life a little easier and only use 1 format string.  Use "%03b%02b%03b" for the format string.  You can then expand the format string to allow multiple inputs.  You will do the job of 4 functions with just 1.
    "%3b" just says to give 3 spaces for the binary number.  But any preceding 0s will be turned into spaces.  Adding the 0 in there tells the format string to prepend 0s instead of using spaces.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Remove last char of string

    Hi Guys
    How can I remove the last char of a String ?

    With [the substring method|http://java.sun.com/javase/6/docs/api/java/lang/String.html#substring(int,%20int)] .

  • How to delete the last char in a String?

    i want to delete the last char in a String, but i don't want to convert the String to a StringBuffer or an array, who knows how to do?

    Try it in this way
    String MyString = "ABCDEF";
    MyString = MyString.substring(0,MyString.length()-1);

  • Remove last char

    Ok i am trying to make just a simple calculator program for a class. I am trying to get the backspace button to work. How would i delete the last char in the string.

    use a substring, the last char. will be:
    myString.length
    that will give you the length and from that you know what the last char. is

  • Deleting the last char of a string

    How can I Delete the last char of a string???
    example:
    asd@fdg@vvdfgfd@gdgdfgfd@gdfgdf@
    I want delete the last @!
    Tks in advance!

    hi,
    try this:
    lv_count = strlen(string).
    lv_count_last = lv-count - 1.
    replace string+lv_count_last(lv_count) in string by ' '.
    This should work.
    thnx,
    ags.
    Edited by: Agasti Kale on Jun 4, 2008 9:03 PM

  • Deleting last char in a string...

    I have a string that is created as follows: strBuffer += k.getKeyChar();(k is KeyPressed ...KeyEvent) How can I delete the last Char in the string strBuffer?

    Hi
    // simply substring
    if (strBuffer.length() > 1)
        strBuffer = strBuffer.substring(0, strBuffer.length()-1);
    // you may also use
    if (strBuffer.length() > 1)
        StringBuffer buffer = new StringBuffer(strBuffer).
                                   deleteCharAt(strBuffer.length()-1);
        strBuffer = buffer.toString();
    }I've not tested the above code myself & I've written the above code on the go after reading your query. The above code definitely work & help you.
    Regards,
    JPassion

  • How to remove the Char.from one Operating Concern

    Hi Guys,
    How to remove the Char. from one Operating Concern.
    I have created one Char. (WWDOC) and moved to Operating Concern (OOCC). Operating Concern is in red status.
    Now, i want to remove that new assigned Char. (WWDOC)from the operating concern (OOCC). I did't find any option in the menu also.
    Appreciate your help.....
    T&R
    VVR

    Hi Sasi,
    Iam not able to push back that char. from my operating concern. In help it is given you have to delete the data contents in the table before pushing back. Please let me know if any other option available.
    Thanks for your reply.
    VVR

  • Finding last char in the string

    Hi
    i need to find out whether the last char of a string is '/' (forward slash). please let me know if there's a FM to do that. Other post me the logic for this ASAP.
    thanks

    len = strlen(char).
    len = len - 1.
    if char+len(1) = '/'.
      *write ur code
    endif.
    chk this code
    REPORT ychatest.
    DATA : str(5) VALUE '123/',
           len TYPE i.
    len = STRLEN( str ).
    len = len - 1.
    IF str+len(1) = '/'.
      WRITE : '/ found'.
    ENDIF.
    <b>Reward points if helpful and close thrad if solved</b>
    Message was edited by: Chandrasekhar Jagarlamudi

  • How to get a char from a String Class?

    How to get a char from a String Class?

    Use charAt(int index), like this for example:
    String s = "Java";
    char c = s.charAt(2);
    System.out.println(c);

  • Read last char of a String

    I have the following code that functions like a basic RPN calculator:
    public class Main {
         * @param args the command line arguments
         static public ArrayList<Double> stack = new ArrayList<Double>();
         static double numberInput;
         static double answer;
         static String operation;
    //Prints Welcome screen, initialized checkforInput
         public static void main(String[] args) {
             System.out.println();
             System.out.println("Welcome to RPNCalc by theCoffeeShop()");
             checkForInput();
    //Checks for input, redirects to appropriate method
         public static void checkForInput() {
             Scanner reader = new Scanner(System.in);
          String input = reader.nextLine();
             if(isDouble(input) == true) {
                double number = Double.parseDouble( input );
                stack.add(0, number);
                repeat();
             } else {
                operation = input;
                operation();
    //Processes numeric operations
         public static void operation () {
             if(operation.equals("+")) {
                 answer = stack.get(1)+stack.get(0);
                 stack.add(0, answer);
                 System.out.println(answer);
                 repeat();
             } else if (operation.equals("-")) {
                 answer = stack.get(1)-stack.get(0);
                 stack.add(0, answer);
                 System.out.println(answer);
                 repeat();
             } else if (operation.equals("*")) {
                 answer = stack.get(1)*stack.get(0);
                 stack.add(0, answer);
                 System.out.println(answer);
                 repeat();
             } else if (operation.equals("/")) {
                 answer = stack.get(1)/stack.get(0);
                 stack.add(0, answer);
                 System.out.println(answer);
                 repeat();
             } else {
                 System.out.println("Incompatible operation");
                 repeat();
    //Called when ready to recheck for input
         public static void repeat() {
             checkForInput();
    //Checks if string is double
         public static boolean isDouble( String input )
            try
                Double.parseDouble( input );
                return true;
            catch(Exception e)
               return false;
    }To perform a basic operation (5+2), you would do the following
    5
    enter
    2
    enter
    (plus)
    enter
    Computer prints 7.
    I would like it to function like this:
    5
    enter
    2(plus)
    enter
    Computer prints 7.
    To do this, I have to be a be to split a string into 2 parts, the operation and the number. I think I could do this with a StringBuffer, but How to read the LAST char of a StringBuffer, instead of just a specific char? If there is a way to do it w/out a StringBuffer, I'm open to suggestions.

    Hint:
    The last character of a String (or StringBuilder or StringBuffer, etc.) is at the index (length_of_string - 1).
    Are you sure you're supposed to solve the problem this way? Usually homework assignments of this sort involve writing a whole parser.

  • How to remove HTML tags from a String ?

    Hello,
    How can I remove all HTML Tags from a String ?
    Would you please to give me a simple example ?
    Best regards,
    Eric

    Here's some code I cooked up. I have created an object that processes code so that it can be incorporated directly into a project. There is some redundancy so that the it can be used in more than one way. Depending on your situation you might have to make the condition statement a little more sophisticated to catch stray ">" tags.
    I have also included a Tester application.
    //This removes Html tags from a String either by submitting the String during construction and then
    // calling getProcessedString() or
    // by simply calling " stringwithoutTags=removeHtmlTags(stringWithTagsSubmission); "
    //Note: This code assumes that all"<" tags are accompanied by a ">" tag in the proper order.
    public class HtmlTagRemover
         private String stringSubmission,processedString,stringBeingProcessed;
         private int indexOfTagStart,indexOfTagEnd;
         public HtmlTagRemover()
         public HtmlTagRemover(String s)
              removeHtmlTags(s);          
         public String removeHtmlTags(String s)
              stringSubmission=s;
              stringBeingProcessed=stringSubmission;
              removeNextTag();
              return processedString;
         private void removeNextTag()
              checkForNextTag();
              while((!(indexOfTagStart==-1||indexOfTagEnd==-1))&<indexOfTagEnd)
                   removeTag();
                   checkForNextTag();
              processedString=stringBeingProcessed;
         private void checkForNextTag()
              indexOfTagStart=stringBeingProcessed.indexOf("<");
              indexOfTagEnd=stringBeingProcessed.indexOf(">");
         private void removeTag()
              StringBuffer sb=new StringBuffer("");
              sb.append(stringBeingProcessed);
              sb.delete(indexOfTagStart,indexOfTagEnd+1);
              stringBeingProcessed=sb.toString();
         public String getProcessedString()
              return processedString;
         public String getLastStringSubmission()
              return stringSubmission;
    public class HtmlRemovalTester
         static void main(String[] args)
              String output;
              HtmlTagRemover h=new HtmlTagRemover();
              output="The processed String: "+h.removeHtmlTags("<Html tag>This is a test<another Html tag> string<yet another Html tag>.");
              output=output+"\n"+" The original string:"+h.getLastStringSubmission();
              System.out.print(output);

  • How to remove extra char in the uploaded file...?

    Dear All,
    There is file upload page in our portal.When user uploads the file (CSV) i can see there is extra char (^M) in the unix env.How can I remove that extra char before inserting into the database.For inserting into database I am using below code:
    BlobDomain blobdomain = (BlobDomain)pageContext.getParameterObject(upldFileNameHD);
    header.setFileData(blobdomain);
    Did anyone can help me on this...
    Thanks

    Raffy is right in giving the explanation on why this happens.
    Now way to
    1. Remove it:
    A. open file in vi
    B. use this command, the way it works is, search(%s) for the ^M char and replace it with space (//) , and do this globally (g)
    :%s/^M//g
    C. To type ^M char press Ctrl Key and press either M or J, it should print that char.
    D. Save the file (:wq)
    2. Avoid it:
    when doing FTP, use binary mode, just type bin before you do a put.
    Thanks,
    Tapash

  • How to delete last character in a string

    Guys i have a question...
    how can i delete the last character in a string..
    for example
    String myString = "helloWorld, ";
    how do i delete the last character in this string which is a "," ?

    String newString = myString.substring(0, myString.length()-1);

  • How to remove last blank page from preview of Smartform

    Hi Experts ,
    I am creating a smartform having vbeln range option. Now if i give range from 2 to 10 then After Doc NO. 10
    i got a blank page . So can u please tell me how to remove that.
    Rgds,
    Premraj

    hey,
    Create a program lines node.....
    in that describe the internal table in which you are having the document number.If you are having 10 document number then you will be having 10 pages.... so create program lines befor the command line in the command line just give a flag ok.
    when the 10th page is created then the control comes to program line where the pagenumber will be equal to the number of document number there create a flag ( f = 'X') then give this codition in command line.Trigger the command line when ever f NE 'X'.So in the last time new page will not be triggered.
    Regards,
    Midhun Abraham

Maybe you are looking for

  • Is there a way to install Windows (with programs) on an external drive and run it from the Pro?

    I have a 1TB Seagate Goflex that I am using to backup the Mac, but I want to partition it and run Windows and Windows Apps from it, rather than risk my HDD.  Does anyone have any experience doing that or have any ideas on how it might be done?  I am

  • Digital Signatures with Adobe Reader

    So i created an adobe form with acrobat 9 and sent it out for all to digitally sign.  about half are getting an error when they try to sign it.  "The credential selected for signature is invalid" We are a government agency and use Common Access Cards

  • Madness with iTunes 7 !!

    Apple how can you mess up this release so badly ? I mean come on didn't you test iTunes 7 properly before releasing this crippled piece of software to the masses ? Isn't itunes first and foremost a software for playing music ?? If it cant even do tha

  • Impli?it import in JSP

    Hi,           Could anybody clear the following question? Which way does jsp compiler make           import of packages on weblogic 6.0? I looked through JSP examples and did           not find any import declaration in some of them, but there were s

  • What is the best image rsolution to use

    I use Photoshop CS2 and DVDSP3. When adding images from photoshop to my project, what resolution should I use? 300dpi, 96, 72? I have used 30Odpi, converting the images to d1/DV NTSC picture aspect, yet they look pixelated and unclear. I used photos,