Doubt to be Clarified on JTextArea appending a string

Hi All,
Here is the actual code.
String msg="Settings Details Will be Produced after the Connection is Successful";
                    String msg1=      "-------------------------------------------------------------------------";
                    String comdetails="1)Comport Enabled is:";
                    String baudratedetails="2)BaudRate Selected is:";
                    String databitdetails="3)DataBit is:";
                    String paritybitdetails="4)ParityBit is:";
                    String stopbitdetails="5)Stopbit is:";
contentarea.setText("");
                       contentarea.append(msg);
                    contentarea.append("\r\n");
                    contentarea.append(msg1);
                    contentarea.append("\r\n");
                    contentarea.append(msg1);
                    contentarea.append("\r\n");
                    contentarea.append(comdetails);contentarea.append(cv);
                    contentarea.append("\r\n");
                    contentarea.append(baudratedetails);contentarea.append(bv);
                    contentarea.append("\r\n");
                    contentarea.append(databitdetails);contentarea.append(dv);
                    contentarea.append("\r\n");
                    contentarea.append(paritybitdetails);contentarea.append(pv);
                    contentarea.append("\r\n");
                    contentarea.append(stopbitdetails);contentarea.append(sv);
                    contentarea.append("\r\n");
                    contentarea.append(msg1);
                    contentarea.append("\r\n");
                    contentarea.append(msg1);I have a JTextArea which is basically linked up with a JBUtton.So when i click on JButton in the JTextArea thte following will be displayed.
"Settings Details Will be Produced after the Connection is Successful"
1)Comport Enabled is:COM3
2)BaudRate Selected is:38400
3)DataBit is:8bit
4)ParityBit is:NONE
5)Stopbit is:1bitSo my question when i again click on the same JButton the same data which is highlighted in the code tags need to be displayed again from the next end line of the previous data instead of overriding operation.Can any one help me out in doing this???
Thanks in advance.
regards,
Viswanadh

Hi toodburch,
Thanks for the reply.My requirement is for every click on the JButton it should be in the following way.Assume i have pressed 3 times.then it should be displayed as shown.
"Settings Details Will be Produced after the Connection is Successful"
1)Comport Enabled is:COM3
2)BaudRate Selected is:38400
3)DataBit is:8bit
4)ParityBit is:NONE
5)Stopbit is:1bit
"Settings Details Will be Produced after the Connection is Successful"
1)Comport Enabled is:COM3
2)BaudRate Selected is:38400
3)DataBit is:8bit
4)ParityBit is:NONE
5)Stopbit is:1bit
"Settings Details Will be Produced after the Connection is Successful"
1)Comport Enabled is:COM3
2)BaudRate Selected is:38400
3)DataBit is:8bit
4)ParityBit is:NONE
5)Stopbit is:1bitThanks
regards,
Viswanadh

Similar Messages

  • JTextArea append problem

    I have the following problem:
    I am creating a JFrame with a JTextArea in it.
    After all components are added to the JFrame
    I call:
    setLocation(100, 100);
    pack();
    setVisible(true);
    Then a method is called that generates files and uses
    jTextArea.append(".");
    to add a "." to the JTextArea for each created file
    to show the progress.
    Now the problem is that the dots are not shown one after the other.
    The window pops up AFTER all the dots are written and not when
    setVisible(true);
    is called.
    What do I have to do that every single dot is shown in the
    JTextArea right after it is appended ?

    Move your actual file generating process to a different thread. The best way to do it is using SwingWorker. There is a tutorial on the Sun's web site at http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html that demonstrates how to use SwingWorker.
    Hope this helps
    Sai Pullabhotla

  • Question on JTextArea.append(String str)

    Hi All,
    When i provide JTextArea.append("FMTL") it is showing me on the JTextArea but when i give it as
    String item="Viswanadh";
    JTextArea.append(item).this particular statement is remaming blank on the TextArea.
    Any idea why this is happening and is there any other method to be used instead of append.???
    Thanks in advance..
    regards,
    Viswanadh

    class OnApplyFormat implements ActionListener{
         public void actionPerformed(ActionEvent formatevent){
              JComboBox source = (JComboBox) formatevent.getSource();
                   String item =  source.getSelectedItem().toString();
                     System.out.println("Selected Format is:"+item);
                     try
                       if ( item!=null )
                              System.out.println("Format is:"+item);
                     infoarea.append("FMTL");
                   infoarea.append(item);
                     infoarea.append("\r\n");
                   infoarea.append("FMTU");
                   infoarea.append("\r\n");
                   infoarea.append("wait 5");
                   infoarea.append("\r\n");
              else
                   throw new Exception("FormatNotFoundException");
                          }catch(Exception e){
                          e.printStackTrace();
    }That is my code and still i am facing the same FMTL is not getting appended with the item variable.
    Help me in solving this issue.
    Thanks in advance.
    regards,
    Viswanadh

  • I need to append a string to another string

    I'm working with some inherited code, I'm a Colf Fusion
    novice myself, and I'm trying to make this order form display the
    correct data. The problem is a lot of data in the database is
    missing. Description in the QStockDB query can contain a lot of
    stuff. For our full color work the text "4/0", "4/BLACK", and "4/4"
    are consistent so I'm changing the newitem (I know, not very
    descriptive but it's not my code) to CMYK Printing.
    <cfif #QStockDB.description# contains "4/0"><cfset
    newitem = "CMYK Printing"></cfif>
    <cfif #QStockDB.description# contains
    "4/4/BLACK"><cfset newitem = "CMYK Printing"></cfif>
    <cfif #QStockDB.description# contains "4/4"><cfset
    newitem = "CMYK Printing"></cfif>
    I want to then go back through description and compare it
    more to add more description. For instance with this:
    <cfif #QStockDB.description# contains "12 pt"><cfset
    newitem = newitem + " - BC"></cfif>
    I know that the job is a business card. So I want to append
    the newitem variable with " - BC". Likewise:
    <cfif #QStockDB.description# contains
    "catalog"><cfset newitem = newitem + " - Catalog
    Sheets"></cfif>
    displays CMYK Printing - Catalog Sheets. Or, it should... or,
    more precisely, I want it to. :)
    How do I append a string to another string?

    + is the addiion operator and works with numbers. Because
    your string is a ...well, string... you need to use an ampersand.
    Thus, instead of:
    <cfif #QStockDB.description# contains
    "catalog"><cfset newitem = newitem + " - Catalog
    Sheets"></cfif>
    Use...
    <cfif #QStockDB.description# contains
    "catalog"><cfset newitem = newitem & " - Catalog
    Sheets"></cfif>
    <cfoutput>#newitem#</cfoutput>
    At least I think that will work - haven't tested it
    though.

  • How to append a string whose content is XML file to the child of other XML?

    Hi guys,
    I have a question:
    I obtain a string which is actually a response from HTTP servlet, and I want to append this string as child of another XML, how can I do it? Is there any method to convert string to XML node, opposite to the method "render_2_string"?
    Thanks in advance
    Message was edited by: Liying Wang

    If I understand your question correctly, this may be helpful.
    types: begin of myStructure,
             myNumber type n,
             myChar   type c,
           end of myStructure.
    Data:
    IXML   Type Ref To     IF_IXML,
    XMLDOC Type Ref To     IF_IXML_DOCUMENT,
    RC     Type             SY-SUBRC.
    data rootNode type ref to if_ixml_element.
    data newNode type ref to if_ixml_element.
    data sourceString type string.
    types
      ixml = cl_ixml=>create( ).
      xmlDoc = ixml->create_document( ).
      rootNode = xmlDoc->create_element( 'RootElement' ).
      setAttributesFromStructure( node = rootNode structure = 
      mystructure ).
      newNode = xmlDoc->create_element( 'newNodeAdded' ).
      if sourceString is not initial.
        rc = newNode->IF_IXML_NODE~SET_VALUE( sourceString ).
      endif.
      add navigation graph entry
        rc = rootNode->append_child( newNode ).
    Quack

  • Is it possible to append a string on canvas without calling repaint() ??

    Hi..experts
    I am new to J2ME programming. i want to append characters on canvas one by one.
    is it possible to append a string to another that is allready drawn without repainting all canvas.
    please help me.
    Thanks a lot

    without repainting all canvas.if your not comfortable repainting the entire canvas, You can use the selective repaint function. it repaints only the area specified by you
    repaint(int x, int y, int width, int height)
    //Requests a repaint for the specified region(x,y) of the Canvas.ps: selective repainting is the VM's decision

  • How to append the string into blob content

    the blob column will have a string with comma separated values which needs to be changed to column wise data and update it back with the existing BLOB content.
    string like:-'V,CTMF,1.0,M,ICD-9 to 10 CM,CODE_COMMENTS_UPLOAD,0,A,bsns,2012-04-01,Author,pa admin,Comment,50 Record Map,F,Vascular,C,M'
    after i got splitting the values to column wise:
    V
    CTMF
    1.0
    M
    ICD-9 to 10 CM
    CODE_COMMENTS_UPLOAD
    0
    A
    bsns
    2012-04-01
    Author
    pa admin
    Comment
    50 Record Map
    F
    Vascular
    C
    M
    finally i need the blob append data output look like below,please do the needful................
    blob_value
    V,CTMF,1.0,M,ICD-9 to 10 CM,CODE_COMMENTS_UPLOAD,0,A,bsns,2012-04-01,Author,pa admin,Comment,50 Record Map,F,Vascular,C,M
    V
    CTMF
    1.0
    M
    ICD-9 to 10 CM
    CODE_COMMENTS_UPLOAD
    0
    A
    bsns
    2012-04-01
    Author
    pa admin
    Comment
    50 Record Map
    F
    Vascular
    C
    M

    actually
    my blob column values is:
    V,CTMF,1.0,M,ICD-9 to 10 CM,CODE_COMMENTS_UPLOAD,0,A,bsns,2012-04-01,Author,pa admin,Comment,50 Record Map,F,Vascular,C,M
    splitting column wise data is:-**
    V
    CTMF
    1.0
    M
    ICD-9 to 10 CM
    CODE_COMMENTS_UPLOAD
    0
    A
    bsns
    2012-04-01
    Author
    pa admin
    Comment
    50 Record Map
    F
    Vascular
    C
    M
    now i am appending the string to blob content at the end of the line only like
    V,CTMF,1.0,M,ICD-9 to 10 CM,CODE_COMMENTS_UPLOAD,0,A,bsns,2012-04-01,Author,pa admin,Comment,50 Record Map,F,Vascular,C,MVCTMF1.0MICD-9 to 10 CMCODE_COMMENTS_UPLOAD0Absns2012-04-01Authorpa adminComment50 Record MapFVascularCM
    but my requirement is should be to append the column wise data to existing blob column as new line like:
    V,CTMF,1.0,M,ICD-9 to 10 CM,CODE_COMMENTS_UPLOAD,0,A,bsns,2012-04-01,Author,pa admin,Comment,50 Record Map,F,Vascular,C,M
    VCTMF1.0MICD-9 to 10 CMCODE_COMMENTS_UPLOAD0Absns2012-04-01Authorpa adminComment50 Record MapFVascularCM
    my procedure:
    create or replace
    PROCEDURE PR_TEST_BLOB2 IS
    RES_BLOB CLOB;
    DEST_BLOB BLOB;
    SRC_BLOB BLOB;
    CURSOR CUR_TEST_BLOB2 IS
    SELECT REGEXP_SUBSTR(STR, '[^,]+', 1, LEVEL) FROM (SELECT UTL_RAW.CAST_TO_VARCHAR2(BLOB_VALUE) STR FROM TEST_BLOB2 WHERE TEST_ID=10)
    CONNECT BY LEVEL <= LENGTH(STR) - LENGTH(REPLACE(STR,','))+1;
    BEGIN
    OPEN CUR_TEST_BLOB2;
    LOOP
    FETCH CUR_TEST_BLOB2 INTO RES_BLOB;
    EXIT WHEN CUR_TEST_BLOB2%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE(RES_BLOB);
    DEST_BLOB:=UTL_RAW.CAST_TO_RAW(RES_BLOB);--converting clob to blob;
    SELECT BLOB_VALUE INTO SRC_BLOB
    FROM TEST_BLOB2
    WHERE TEST_ID = 10 FOR UPDATE;
    --move the blob values to source file
    DBMS_LOB.APPEND(SRC_BLOB,DEST_BLOB);-- append the blob values
    COMMIT;
    END LOOP;
    CLOSE CUR_TEST_BLOB2;
    END;
    could you please help me.

  • Append a string

    I have forgotten when the underline "_" should be used to append a string that has been broken into two lines.
    Let take an example:
    out.println("hello"); // result is hello
    out.println("he"+"llo"); //result is also "hello" // append he + llo for this case
    But this is not allowed:
    out.println("hel <----- problem // line break here
    lo); <----- problem
    So, is there any method that can make the output to be "hello" for this problem.
    I just remembered in VB Script, you can append strings by one underline.

    I'm not entirely sure what you're asking, but if it's what I think it is: out.println("he" +
        "llo"); By the way, you've been posting here enough that you should know to use code tags by now.

  • Append a string to a file without overwritting.

    OK, let's do this as easy as can be...
    I have a file "A.txt" and its contents is:
    AAAAAAAAAAIf we retreive the File data, its length is 10.
    Now, I have the next code:
    import java.io.*;
    public class MyClass {
        public static void writeToFile(File f, String writeThis, int where) throws IOException, FileNotFoundException {
            RandomAccessFile raf = new RandomAccessFile(f, "rw");
            raf.seek((long)where);
            raf.writeBytes(writeThis);
            raf.close();
        public static void main(String args[]){
            try {
                writeToFile(new File("A.txt"), "java", 3);
            } catch (Exception anyE) {}
    }This is what I want:
    File A.txt contents
    AAAjavaAAAAAAA
       ^ Appended to the fileNow the file data length is 14, 10 A's + java (4)
    This is what I get:
    AAAjavaAAA
       ^ Overwrote the file contents.Now the file data length is still 10, Java overwrote 4 A's.
    How can I append a string to a file at any desired position without overwriting nothing.
    I've checked all java.io package and I found that only RandomAccessFile class allow me to have a file pointer in order to read from there.
    It's important not to append data at the end of the file, I have some tokens there in my app.

    Hi, i am trying to do the same thing. Can u use a randomaccessfile and seek to the pt where u want to insert. save that location. store the data from that pt to the end of the file in a string buffer. then append the string to be inserted at the position u had saved earlier. and then append the string buffer to it. think this should do it. i dont know if it works.
    i had another problem .. i was looking to delete some portion from a file and maintain the continuity. for eg. i have file containing "aaaaajavaaaaaa" and i want to remove java .. from it resulting in "aaaaaaaaaa". is there a easier way to do it. let me know thanks

  • JTextArea.append

    I have got some problem using the .append method of the JTextArea class. Below is my statement.
    The declaration
    private JTextArea ulist;
    ulist = new JTextArea();
    ulist.setFont(new Font("Tahoma", 0, 11));
    ulist.setEnabled(false);
    JScrollPane spulist = new JScrollPane(ulist);
    spulist.setLocation(24, 285);
    spulist.setSize(187, 150);
    con.add(spulist);
    spulist.append("Client" + clientno + "'s host name is" inetAddress.getHostName() "\n");
    The error message i got was " cannot find symbol method in java.lang.string"
    Can anyone help?

    try ulist.append() rather than spulist.append. it
    might workYes I rather think it will. I was hoping in reply 1 that the OP would spot the error of their ways with just a hint.

  • Doubt on line removal in JTextArea

    Hi All,
    I have 3 lines which are on the JTextArea like
    sample.pl
    sample1.pl
    sample2.pl
    So i want to remove the whole from Jtextarea..how is it possible??
    thanks in advance.
    regards,
    Viswanadh

    TechnicalGuy7 wrote:
    Thanks for the reply.
    If suppose i want to remove only the middle line..How can i do???
    regards,
    Viswanadh
    Edited by: TechnicalGuy7 on Feb 16, 2009 5:21 AMI've written a simple example which will remove the second line of the input when you press a button. Obviously you can manipulate the logic to remove whatever line you want (programmatically determining where the middle lines is, removing odd lines etc).
    package tester;
    import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowEvent;
    import java.awt.event.WindowListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JTextArea;
    public class Tester extends JFrame implements WindowListener {
         private JTextArea textArea;
         public static void main(String[] args) {
              new Tester();
         public Tester() {
              textArea = new JTextArea();
              JButton checkTextButton = new JButton("Click to remove the second line");
              checkTextButton.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        checkTextButton_actionPerformed(e);
              this.setLayout(new BorderLayout());
              this.add(textArea, BorderLayout.CENTER);
              this.add(checkTextButton, BorderLayout.SOUTH);
              this.setTitle("Second Line Remover");
              this.setSize(500, 500);
              this.addWindowListener(this);
              this.setVisible(true);
         private void checkTextButton_actionPerformed(ActionEvent e) {
              // Get the text from the text area
              String inputText = textArea.getText();
               * Split the text into lines using the new line character as the split point. lines[0] is
               * the first line, lines[1] is the second and so on...
              String[] lines = inputText.split("\n");
              // If there aren't 2 or more lines we can't do anything
              if(lines.length < 2) {
                   JOptionPane.showMessageDialog(this, "Cannot remove the second line because it doesn't exist.");
                   return;
              StringBuilder outputString = new StringBuilder();
              for(int i=0; i<lines.length; i++) {
                   // Append all lines except from the second line to the new text to put in the area
                   if(i != 1) {
                        outputString.append(lines[i]+"\n");
              // Set the new text in the area to be the input minus the second line
              textArea.setText(outputString.toString());
         @Override
         public void windowActivated(WindowEvent e) {}
         public void windowClosed(WindowEvent e) {}
         public void windowClosing(WindowEvent e) {
              System.exit(0);
         public void windowDeactivated(WindowEvent e) {}
         public void windowDeiconified(WindowEvent e) {}
         public void windowIconified(WindowEvent e) {}
         public void windowOpened(WindowEvent e) {}
    }Sample interaction (before and after pressing the button:
    http://img4.imageshack.us/img4/4307/beforeandafterva5.jpg

  • How do i append each String on a different line in a JTextArea

    Hi,
    I have the following lines of code and I would like each line to append into the JTextArea on a separate line. I know I need to use \n but i forgot how to do it with the following code:
    invoiceJTextArea.append(FirstName);
    invoiceJTextArea.append(Surname);
    invoiceJTextArea.append(Age);
    At the moment, it prints right next to each other like this: JohnSmith28
    Thanks for your help.

    A JTextComponent will accept "\r\n", and it will seem
    to work, but the "\r" will not be treated as part of
    the line separator. And "\r" alone won't function as
    a line separator--in fact, it won't be displayed at
    all.
    When you read text into a JTextComponent from a file
    via the built-in read() method, all line separators
    are converted to "\n". The type of separator used in
    the file is saved as a property of the Document, and
    when you write the text back to the file, they are
    reconverted. Text pasted in from the clipboard also
    undergoes this conversion (but I don't think it gets
    reconverted when you copy or cut).
    The issue of line separators is meant to be
    completely transparent to the user. Programmers
    usually don't have to think about it either, but we
    do have the power to insert any whitespace character
    into a text component. We need to be aware that only
    spaces, tabs and linefeeds will render as expected.First off, I apologize for being a bit curt or dogmatic ... I was in a bit of a hurry.
    Note thought that I did not state: Don't use '\n'.
    What I did state as being wrong was your statement of:
    "No, don't use the system line separator. JTextArea can only use "\n" as a line separator"
    I have tried used the system line separator and it works. So I am not saying one should not use '\n', only that should not say the system line sep does not work.

  • Doubt about  a null value assigned to a String variable

    Hi,
    I have a doubt about a behavior when assigning a null value to a string variable and then seeing the output, the code is the next one:
    public static void main(String[] args) {
            String total = null;
            System.out.println(total);
            total = total+"one";
            System.out.println(total);
    }the doubt comes when i see the output, the output i get is this:
    null
    nulloneA variable with null value means it does not contains a reference to an object in memory, so the question is why the null is printed when i concatenate the total variable which has a null value with the string "one".
    Is the null value converted to string ??
    Please clarify
    Regards and thanks!
    Carlos

    null is a keyword to inform compiler that the reference contain nothingNo. 'null' is not a keyword, it is a literal. Beyond that the compiler doesn't care. It has a runtime value as well.
    total contains null value means it does not have memory,No, it means it refers to nothing, as opposed to referring to an object.
    for representation purpose it contain "null"No. println(String) has special behaviour if the argument is null. This is documented and has already been described above. Your handwaving about 'for representation purpose' is meaningless. The compiler and the JVM don't know the purpose of the code.
    e.g. this keyword shows a hash value instead of memory addressNo it doesn't: it depends entirely on the actual class of the object referred to by 'this', and specifically what its toString() method does.
    similarly "total" maps null as a literal.Completely meaningless. "total" doesn't 'map' anything, it is just a literal. The behaviour you describe is a property of the string concatenation operator, not of string literals.
    I hope you can understand this.Nobody could understand it. It is compete nonsense. The correct answer has already been given. Please read the thread before you contribute.

  • Help needed in - appending query string

    Hai All,
    Its very Urgent for me.Can anyone pls tell me how can I do the following.
    I want the query String of first page to be appended to the next following pages also.

    u want first page URL to second page or page data?

  • How to append a string from a file to a string???????????

    hi there
    the following code reads a line from a file,
    while (true)
    try
    line = br.readLine();
    catch (IOException e)
    System.out.println("Error reading data file");
    System.exit(1);
    if (line == null) break;
    st = new StringTokenizer(line, delimiterString);
    n = st.countTokens();
    if (first == 0) first = n;
    if (n != first)
    System.out.println("Data format error!");
    System.exit(1);
    how will i append the line to itself each time the loop runs? the line should contain all the lines in the file, not just a single line. thank you

    You can make a StringBuffer object with the same scope as the line String and keep appending to the StringBuffer. You can use StringBuffer's toString() method to get a String back when you need it. You can also do this with a String instead of a StringBuffer using +=, but the String buffer is a lot more efficient.
    StringBuffer wholeFile = new StringBuffer();
    while (true)
    try
    line = br.readLine();
    wholeFile.append(line);  // or put this wherever it makes most sense
    catch (IOException e)
    System.out.println("Error reading data file");
    System.exit(1);
    if (line == null) break;
    st = new StringTokenizer(line, delimiterString);
    n = st.countTokens();
    if (first == 0) first = n;
    if (n != first)
    System.out.println("Data format error!");
    System.exit(1);
    }

Maybe you are looking for