How to remove the last new line in text area ?

I have a calculator Applet that shows the calculation in a text area.
if i enter 2+6, the text area shows
2+
6
and i have a clear last button, which deletes the last entry by user.
in the example above, one hit of clear last, deletes 6. another hit should delete +.
I can delete the numbers, but I don't know how to go back to the previous line and delete the operator.
I may have other calculations in that text area above the current calculation. so replaceAll("\n","") would not work here.
Please someone help me here.

it's an applet, i am developing in Eclipse ( mac environment)
so for deleting a number i used this code, and works fine
String temp = t.getText();
                         String lastChar = temp.substring(temp.length()-1);
                         for (int i=0; i<numbers.length; i++) // deleting a number
                              if (lastChar.equals(numbers)){
                                   temp = temp.substring(0,temp.length()-1);
                                   number = number.substring(0,number.length()-1);
                                   t.setText(temp);
which t is the text area, and numbers is the string array of 0 to 9, and number is a string where i store the entered number
so i thought for deleting an operator i should use something similar, where i need to go back to the previous line and delete it,
String temp = t.getText();
                         String lastChar = temp.substring(temp.length()-1);
                         if(lastChar.equals("n")){
                                                        temp = temp.substring(0,temp.length()-3);// deleting n , \ , and the operator
                                   t.setText(temp);
                         } but it doesn't work

Similar Messages

  • How to remove the last blank line in the downloaded text file?

    Hi All,
    I am downloading the one internal table content using the GUI_DOWNLOAD to a text file(.txt). The cursor is in last position of the text file where there is no content. For example consider the below is downloaded txt file:
    This is test file.
    Downloaded from the internal table
    using GUI_DOWNLOAD
    | <----
    In above the internal table content first three lines..
    Once I press page down in the text file, the cursor goes below the third line..(i.e., next to the last line)
    How to avoid that ?
    Thanks in Advance,
    Regards,
    Raghu

    I solved this problem with BIN mode.
    See this code example
    DATA: FILESIZE TYPE I.
    CALL FUNCTION 'SCMS_TEXT_TO_BINARY'
    IMPORTING
       OUTPUT_LENGTH         = filesize
      TABLES
        TEXT_TAB              =   i_record
        BINARY_TAB            = i_Record
          filesize = filesize - 1. "TRUNCATED LAST LINE!!!
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          BIN_FILESIZE = filesize
          filename                = l_file
          filetype                = 'BIN'
         TRUNC_TRAILING_BLANKS = 'X'
         TRUNC_TRAILING_BLANKS_EOL = 'X'
         WRITE_LF_AFTER_LAST_LINE = ' '
       TABLES
          data_tab                = i_record
    Hope this can help you.

  • How to remove the Blue Fuzzy Line in Spry Collapsible Panels

    Do anyone know exactly how to remove the blue fuzzy line that appears when a tab is focussed on in the Collapsible Panels feature?
    I heard there was some code that could be implemented into one of the style sheets which could solve this but I am yet to find a solution
    Thanks

    .CollapsiblePanelTab { outline:none; }
    Try that.

  • How to Remove the Last line of Instance in subform ?

    I thought I ran across an example in this forum of how to specify which instance you want to delete from a subform but I can not find it. I can get removeInstance to work but it removes the top line and I just want it to remove the bottom or last instance that was added. I can do it if I only had 2 instances and tell it to removeInstance(1); but the form is going to be dynamic and there will be more than 2 lines when people start to use the form.

    I've found the reason... :-)
    I'm using the designer from Acrobat professional instead of the designer from Adobe LiveCycle.
    I've got Acrobat professionnal 7.0.0 and trying your sample it didn't function.
    Knowing that there was a new version of Acrobat professional (7.0.7)I've installed it, and now your sample function.
    I have to mention that the count method is not listed in the choice menu that appears when you're typing code inside the designer. It means that some functions have to be tryed even if the popup menu of the list of available methods doesn't mention it.. (in this case it's the count method)... :-)
    There are a lot of things like that (for example there is the checkbox problems that are not good managed before Acrobat Reader 7.0.7, and Acrobat professional 7.0.7)
    So I suggest to the developpers that are reading this post to always install the last version of Acrobat Reader, Acrobat Professionnal, Designer, in order that everything goes well with the product.
    gpalmieri

  • How to remove the last line input into a string indicator??

    I am currently working on a program where the user has the ability to create a profile for one of our lab machines to run.  When the user selects what parameters they would like, a string indicator shows the user the last input they set followed by a comma.  For example, if the user selects which profile they want, and the times they would like to set, the following string would be displayed:
    As you can see in the picture above, the profile is updated in the string indicator after every set button is hit.  In the event the user makes a mistake, I want them to have the ability to delete the last line that was added.
    This is the code I developed so far.  The string coming in and leaving is attached to a shift register so it continues to append to the indicator.  I tried in this case to count how many lines have been written in the string so far, and I built an array with the current string.  Using the delete from array.VI I indexed it to the number of lines that was created so that the last line is deleted.  I unfortunately had no luck.  Any suggestions?

    tbob wrote:
    Fonzie1104 wrote:
    Hey Tbob,
    That almost worked.  The only issue though is it leaves a null string in its place without moving everything after up one line.  Also, if i have a parameter repeating multiple times, it doenst seem to work.
    I'm confused.  If you are deleting the last line, how can there be anything after?  What do you mean by a parameter repeating multiple times?
    If you look at my example front panel, you will see that the last line is deleted.  Isn't this what you asked for?
    It's due to the fact that your constant doesn't have a comma in the last line. If you add that in, you should be able to reproduce his problem. This is just a guess though, I didn't actually test it to see.
    Message Edited by for(imstuck) on 06-08-2010 01:24 PM
    CLA, LabVIEW Versions 2010-2013

  • How to remove the last line of  SUBTOTAL_TEXT ?

    i have used this event but i am totaling displaying at bottom rather than total i am getting another line 
    that i no need so given a some idea a if possible give some code.
    it like as:
    saleso  item no quan  net amt
    5063        10       47.23   554.23
    5063         20      40.00   665.25
    TOTAL                87.23    1219.48
    ---> iam getting extra line  want to delete it give me some solution.
    thanks to all,
    shabeer ahmed

    >5063 10 47.23 554.23
    >5063 20 40.00 665.25
    >TOTAL 87.23 1219.48
    >---> iam getting extra line want to delete it give me some solution.
    what is that extra line, is it total line..?
    if You want to remove the total line
    layout-no_totalline = 'X'.

  • CM: how to block the last new sales order only and not all of them?

    Hi,
    We are testing the FSCM-CM and try to figure out this:
    We have for a customer a number of open sales orders that are all below the credit limit.
    Now someone creaetes a new order and with that amount the limit is exceeded.
    The system reaction is that all open orders are blocked.
    How can we set the system that only the last one is blocked?
    Thanks in advance
    Hein

    Hein,
    I dont think there is any standard function which specially points to the last order. System will consider all the orders in which the customer is involved. I think, the above post suggest the of number of days but not the last order. Try to play with the attributes of system messages and I am sure you will get a clue from it..
    Reward if helpful..
    Thanks,
    Srib

  • How to remove the red vertical line on your mac

    pls help ..,,, how to remove red horizontal line in your macbook pro??

    Take your MBP to an Apple store or an AASP for a definitive diagnoses.  I suspect you may have a GPU problem.
    Ciao.

  • How to determine the position of cursor in Text Area?

    I have to solve next problem.
    I need to create special editor for my application.
    Page consist of two regions. First one is Text Area. Second one is Toolbar.
    User input Text in Text Area. He can use toolbar for inputing additional text in the cursor position.
    It should look like in this forum. When I press on "B", tag <b> inserts in my text, in the cursor position.
    Regards, Kostya

    If the functionality you need is already implemented in this forum software, just pick it up from there!
    Look at the HTML Source of the Post Message page and you will see that the Bold, Italic and Underline buttons call a Javascript function called
    onclick="styleTag('b',document.postform.body);return false;All the Javascript functions are in http://forums.oracle.com/forums/utils.js
    Thanks

  • How to remove the blank lines at the end of the JTextArea .

    Hi,
    I need to remove the blank lines in the JTextArea at the end. Suppose i am giving 'A' in the first line and press the enter key two times, after i am giving the 'B' in the third line and press enter key for two times. I need to remove, the last two lines of JTextAreae, . How i can remove these lines?

    String#trim() removes all whitespace from both ends of the String.
    The requirement was to remove line breaks from the end of the String only.
    String#replaceAll with a suitable regex would do the trick. Untested regex for this:text.replaceAll("[\\n\\r]+$", "")db

  • How to read the last line in a txt file?

    Dear all,
    I want to read the last line in a txt file. There are thousands of lines in this file. What I want is to move the file pointer directly to the last line of the file. But I did not know how do to it. Can anybody help me out?
    Thank you very much!

    If the file is coded as ASCII or one of the encodings that maps a single byte to a char then the following class will assist you
    import java.io.*;
    import java.util.*;
    public class GetLinesFromEndOfFile
        static public class BackwardsFileInputStream extends InputStream
            public BackwardsFileInputStream(File file) throws IOException
                assert (file != null) && file.exists() && file.isFile() && file.canRead();
                raf = new RandomAccessFile(file, "r");
                currentPositionInFile = raf.length();
                currentPositionInBuffer = 0;
            public int read() throws IOException
                if (currentPositionInFile <= 0)
                    return -1;
                if (--currentPositionInBuffer < 0)
                    currentPositionInBuffer = buffer.length;
                    long startOfBlock = currentPositionInFile - buffer.length;
                    if (startOfBlock < 0)
                        currentPositionInBuffer = buffer.length + (int)startOfBlock;
                        startOfBlock = 0;
                    raf.seek(startOfBlock);
                    raf.readFully(buffer, 0, currentPositionInBuffer);
                    return read();
                currentPositionInFile--;
                return buffer[currentPositionInBuffer];
            public void close() throws IOException
                raf.close();
            private final byte[] buffer = new byte[4096];
            private final RandomAccessFile raf;
            private long currentPositionInFile;
            private int currentPositionInBuffer;
        public static List<String> head(File file, int numberOfLinesToRead) throws IOException
            return head(file, "ISO-8859-1" , numberOfLinesToRead);
        public static List<String> head(File file, String encoding, int numberOfLinesToRead) throws IOException
            assert (file != null) && file.exists() && file.isFile() && file.canRead();
            assert numberOfLinesToRead > 0;
            assert encoding != null;
            LinkedList<String> lines = new LinkedList<String>();
            BufferedReader reader= new BufferedReader(new InputStreamReader(new FileInputStream(file), encoding));
            for (String line = null; (numberOfLinesToRead-- > 0) && (line = reader.readLine()) != null;)
                lines.addLast(line);
            reader.close();
            return lines;
        public static List<String> tail(File file, int numberOfLinesToRead) throws IOException
            return tail(file, "ISO-8859-1" , numberOfLinesToRead);
        public static List<String> tail(File file, String encoding, int numberOfLinesToRead) throws IOException
            assert (file != null) && file.exists() && file.isFile() && file.canRead();
            assert numberOfLinesToRead > 0;
            assert (encoding != null) && encoding.matches("(?i)(iso-8859|ascii|us-ascii).*");
            LinkedList<String> lines = new LinkedList<String>();
            BufferedReader reader= new BufferedReader(new InputStreamReader(new BackwardsFileInputStream(file), encoding));
            for (String line = null; (numberOfLinesToRead-- > 0) && (line = reader.readLine()) != null;)
                // Reverse the order of the characters in the string
                char[] chars = line.toCharArray();
                for (int j = 0, k = chars.length - 1; j < k ; j++, k--)
                    char temp = chars[j];
                    chars[j] = chars[k];
                    chars[k]= temp;
                lines.addFirst(new String(chars));
            reader.close();
            return lines;
        public static void main(String[] args)
            try
                File file = new File("/usr/share/dict/words");
                int n = 10;
                    System.out.println("Head of " + file);
                    int index = 0;
                    for (String line : head(file, n))
                        System.out.println(++index + "\t[" + line + "]");
                    System.out.println("Tail of " + file);
                    int index = 0;
                    for (String line : tail(file, "us-ascii", n))
                        System.out.println(++index + "\t[" + line + "]");
            catch (Exception e)
                e.printStackTrace();
    }Note, the EOL characters are treated as line separators so you will probably need to read the last two lines (think about it for a bit).

  • I got a new wireless connection for my mac and cannot figure out how to delete the last connection service I had. Everytime I shut the computer, the network goes back to the other one. I cannot find the file ANYWHERE

    got a new wireless connection for my mac and cannot figure out how to delete the last connection service I had. Everytime I shut the computer, the network goes back to the other one. I cannot find the file ANYWHERE

    Under Network Preferences, select the WiFi
    click on "Advanced..." button
    Select the network you want to delete from the list and click on "-"
    Click "Ok"
    Click "Apply"
    Well done ;-)
    You may also want to delete the wireless key from Keychain.
    Open Keychain, seach for the old wifi network name, slect it and click delete

  • How to provide space and new line to the text in AI Script

    how to provide space and new line to the text in AI Script

    ?? can you explain better, can you at least add another sentence?
    space
    var mySpace = " ";
    new line
    var newLine = "\n";

  • How to make the last line of the textarea visible all the time?

    Hello,
    I am making an online chat application in JSP and XHTML. The chat log and online users� names textareas are refreshed every 5 seconds. When it comes to many messages in the chat log textarea, the scrollbar appears. Then, every time the chat log textarea is refreshed, I need to move the scrollbar down to see the last line of the textarea.
    Are there any ideas how to make the last line of the textarea visible all the time without moving the scrollbar?
    Thanks in advance.
    Dan

    I put the below code on the page, but it didn't work.
    Are there any ideas? Thanks.
    <table border="0" cellspacing="1">
    <tr>
    <th>Chat Log</th>
    <th>Users now online</th>
    </tr>
    <tr>
    <td><textarea rows="20" cols="60" name = "messages" readonly = "readonly"><%= texts %></textarea></td>
    <td><textarea rows="20" cols="20" name = "names" readonly = "readonly"><%= names %></textarea></td>
    </tr>
    </table>
    <script type="text/javascript">
    <!--
    document.messages.scrollIntoView(false);
    //-->
    </script>

  • I got a new macbook pro and now I need to know how to remove the prior owners itunes id from my computer?

    I got a new macbook pro and now I need to know how to remove the prior owners itunes id from my computer?

    If you purchased a computer from another person, you need to wipe it clean.  To do this, click on the link - Erasing disks securely 
    Depending on your model Macbook Pro...
    Start up from your install disc, go to Disk Utility and select the disk and click erase - to securely erase data click Security Options and Erase Free Space which will entirely wipe your disk, overwriting it with zeros so that no data is recoverable.

Maybe you are looking for

  • MS Access and BODS

    Dear All, For one of my object, I need to read data from MS Access tables using SAP BODS tool. At a particular location, I have MS Access tables stored and I need to go to that path and extract the data present in these tables and load them to target

  • CS5.5 Production Premium via Akamai or direct download: unrecognised, small .dmg file size

    A discussion / open call for help about my experiences downloading the product. This may help Product: CS5.5 Production Premium (download version), Intel Based Mac My system: MacBook Pro OSX 10.6.8 FireFox 7.0 Safari 5.1 Chrome 15 Problem: Downloadin

  • Task assignment in Collab server

    Hi All, Not really sure where to post Collab server questions but here goes... It appears that a task can only be assigned to an individual Collab 3.02. Does anyone know if a task can be assigned to a group or several individuals in Collab 4? Thanks,

  • Signing Applets in IE

    Hi , I am coding an Applet, to write to a file in the client Machine. I followed the steps given in this forum to create Signed Applet. This applet is working fine in the local machine were the Server is running(TOmcat).But if I call the jsp from ano

  • How do I get grid, ruler, guides, etc., to show?

    Hi all, I'm still running Motion 1.01 but I can't get the guides to show. I have set the prefs and the view options but when I open a new document I get no guides. I re-installed 1.0 then downloaded to 1.01 but guides not a happening thing. When I op