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

Similar Messages

  • JTextArea.setText("String ") not updating the GUI.

    Hi,
    When i tried to update the JTextArea with a new String it is not replacing the string in the TextArea.
    If I try to print the content by retrieving the data in the TextArea using JTextArea.getText() it is showing the latest string set to the JTextArea.
    What might be the problem?
    DP

    Here is the code. I am calling the displayMessage() from onMessage() method.
    private void displayMessage(String str){
         textArea.setText(str);
         textArea.revalidate();
         System.out.println("Message Received from QUE: "+ textArea.getText());
    public void onMessage(Message msg) {
    try {
    if (msg instanceof TextMessage) {
         msgText = ((TextMessage)msg).getText();
    } else {
         msgText = msg.toString();
         msgText = msgText.trim();
    System.out.println(msgText );
    displayMessage(msgText);

  • String str = " Select ? , ...

    Hi ,
    I have a query for which I need to use PreparedStatement .The query runs likes this :-
    String str = " Select ? , ename from emp where deptno ? ";
    The values of ? need to be assigned dynamically.
    But I cannot create Prepared Statement from this query .
    If you have got answer to your questions can you inform me at
    Thanks in advance

    No, and you can't use a PreparedStatement where you have ? for the table name either. The database can't prepare it because it doesn't know what fields you will be asking for. So you will have to use a Statement and generate the SQL with string calculations. Sorry.

  • 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

  • Append string to stringbuffer in same line

    I have stringbuffer in which i append string thiesestring is of variable lengt
    has different value .I want that when i append string to stringbuffer it append
    to same line .I use append method of stringbuffer.But the whole value is not
    in same line it breaks into many line all lines are not of same size.
    Thanks

    Try making the textarea larger and see if it still
    shows on a new line...Textarea width is very large .There are many line break sometimes all lines
    are of different length so there is no issue of word wrap .I check the output
    sometimes it gives newline when it encounter space but not always .there are also spaces in single line .Sometimes it gives new line when it encounter >
    and sometimes it continue in same line after enconter > .
    Thanks

  • How to Convert JTextArea to String

    How would i convert JTextArea to string?

    elaborate, whats RTFAPI? I searched for it and got
    nothing.Since I'm not quite sure if you are being sarcastic, that translates to "read the f*cking application programmer interface". :)

  • "String str=new String("My String")" v.s. "String str="My String";

    -- what's the difference bet String str="My String"; to this
    String str=new String("My String");

    Its a subtle one. Its also been asked a hundred times before :-)
    When a java class is compiled it "interns" all the Strings it can find.
    Anywhere that you use that string, gets replaced with a reference to that string.
    So the first gets a reference to the interned String.
    The second creates a new String, using the interned String as an argument - results in reserving new memory.
    Take this code:
    String str1 = "My String";
    String str2 = "My String";
    String str3=  new String("My String");In effect the compiler turns it into something like this:
    String internedString = "My String"
    String str1 = internedString;
    String str2 = internedString;
    String str3 = new String(internedString);So initially, it only stores "MyString" once, and all your String variables point at that same memory space. As Strings are immutable in java (the contents never change) this is safe to do. str3 creates a NEW String, which reserves new memory, and copies the contents of internedString into it.
    So
    str1 == str2 (they point to the same bit of memory)
    str1 != str3 (str3 created a new String, so is in new memory)
    str1.equals(str3) (the contents of the strings are the same)
    Hope this helps,
    evnafets

  • Append string in BPEL

    Hello,
    I have three values coming in the XML elements like
    FirstName, LastName and ZipCode
    I want to append these 3 using inside BPEL (using BPEL way) and then at the end also append current TimeStamp.
    So final appended string will look like FirstNameLastNameZipCodeTimeStamp
    How can i go about doing this appending ? also, Do I have to create a holder element that will hold this appended string ?
    thx
    d

    Hi,
    Use Concat(), inside Assign activity, give the values like, concat(FirstName,LastName,ZipCode, currectTime), offcourse this FirstName and other values will come from XML elements which you can select in the Expression Builder
    concat(bpws:getVariableData('inputVariable','payload','/ns4:FirstName'),bpws:getVariableData('inputVariable','payload','/ns4:LastName'),bpws:getVariableData('inputVariable','payload','/ns4:ZipCodeName'),xp20:current-time())
    Next you can create a new Variable and assign this value concat() to it.
    -Yatan

  • Strinig.indexOf(String str, Int fromIndex)

    Hello.
    In the API reference manual J2SE 5.0 (and earlyer also),
    "public indexOf(String str, int fromIndex)"
    is discribed such as,
    | Returns the index within this string of the first occurrence of the specified substring,
    | starting at the specified index. The integer returned is the smallest value k for which:
    | k >= Math.min(fromIndex, str.length()) && this.startsWith(str, k)
    I can't understand why str.length() is needed here.
    For example,
    String string = "my beautiful dream";
    String str = "ea";
    int fromIndex = 10;
    in the case, str.ng.indexOf(str, fromIndex) returns 15, the value is what I what to get.
    But,I think the smallest value k for which
    | k >= Math.min(fromIndex, str.length()) && this.startsWith(str, k)
    is 4, isn't it?
    import junit.framework.TestCase;
    * @author phinloda
    * test String.indexOf
    public class IndexOfTest extends TestCase {
         public final void testIndexOf() {
              String targetString = "my beautiful dream";
              String str = "ea";
              int fromIndex = 10;
              int k1 = myIndexOf(targetString, str, fromIndex);
              assertTrue(k1 >= Math.min(fromIndex, str.length()) && targetString.startsWith(str, k1));
              int k2 = targetString.indexOf(str, fromIndex);
              assertTrue(k2 >= Math.min(fromIndex, str.length()) && targetString.startsWith(str, k2));
              assertEquals(k1, k2);
         private int myIndexOf(String targetStr, String str, int fromIndex) {
              for (int n = 0; n < targetStr.length(); n++) {
                   if (n >= Math.min(fromIndex, str.length()) && targetStr.startsWith(str, n)) {
                        return n;
              return -1;
         public static void main(String[] args) {
              junit.textui.TestRunner.run(IndexOfTest.class);
    }lastIndexOf(String str, int fromIndex) is more difficult for me.
    ("this.length()" is right?, but it's nonsense.)

    ("this.length()" is right?, but it's nonsense.)Yes, it should be this.length() and not str.length().
    I don't think it's nonsense because now the empty
    string always gives a non-negative index, e.g.
    "string".indexOf("", 1000) returns 6...perhaps this
    property is useful for some string algorithmsI think it only does this for an empty String, so it would be clearer if the docs said something about returning this.length() if str.length()==0.

  • 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

  • Quick question about null terminator string!

    Hello,
    I always feel that a char array should end with a "\0".
    But just to clear up something here, if I do:
    char *a[10];
    and I fill out the array with 10 characters, then, should we *always* append the "\0" at the end of this array?
    And if so, should it be appended at a[9] location or a[10] ??? It confuses me a little because since the array is supposed to take 10 characters, then does the compiler save an extra space at the 11th character location for the null terminator string?
    OR
    Is it up to us to make sure we fill the array with up to 9 characters making sure to save the 10th location in the array for the null terminator string?
    So in a nutshell, once we finish up with a char array do we do this:
    a[9] = '\0';
    or this:
    a[10] = '\0';
    I excuse the simple question but this has been haunting me for a while, but thanks for all replies!!!
    r

    Ok, a few misconceptions here.
    I always feel that a char array should end with a "\0".
    This is not strictly true.  This is only true of the data is to be treated as a string.  Often you will use a char array to hold binary data.  Normally such binary data will NOT end in a NUL character.  In fact, most binary data may contain
    NUL characters sprinkled throughout the data.
    char *a[10];
    This is NOT an array of ten characters.  This is an array of ten pointers to characters (or character arrays).  You probably intended
    char a[10];
    You then state
    I fill out the array with 10 characters, then, should we *always* append the "\0" at the end of this array?
    Again, this depends on whether you intend the data to be a string or binary data.  I will assume you mean string from here on out.  For a string, yes you should probably always append a '\0' Of course you don't actually have room for that NUL --
    see the following answer.  (Actually there are some string APIs that let you pass in a number of characters to process and those will work with no terminating NUL, but frankly you are playing with fire when you do that so I would recommend always putting
    the trailing NUL in myself.)
    And if so, should it be appended at a[9] location or a[10]
    The declaration "char a[10]" causes the compiler to reserve *exactly* ten bytes of data for that array.  If you write to location a[10], that is the
    eleventh byte and will cause undefined behavior.  At best you might not notice anything bad.  At worst it could cause any sort of crazy data corruption.  It could easily crash your program.
    You would need to write the NUL character at a[9].   Note that writing NUL at a[9] will overwrite the last byte that you put into that array.
    As a side note here:  This is why you try to always use a proper string class like std::string when using C++ -- it takes care of all of that for you, including growing the string larger if you fill it up.  Then you don't need to worry
    about these pesky details that are easy to get wrong.

  • JTextArea methods + String Handling

    Hi There,
    My Question was, that i have made a small text editor application, and i was hoping that some one could tell me how to add the text, which is opened in a JTextArea to a Vector (or another data structure if this is more appropriate), which i can then parse using Regular expressions??
    Also, could u point me in the direction of a resource that has examples of how to use regular expressions in java 1.4 (util.regex)?
    Thanks in advance,
    much appreciated!

    I'd use getText() and put the text in a String, like the previous poster said. From there you can parse the string using the Pattern and Matcher objects.
    Here's a link that has some examples of regular expressions:
    http://developer.java.sun.com/developer/technicalArticles/releases/1.4regex/

  • 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.

  • Tokenizing a JTextArea(how do i make the JTextArea a string?)

    I am working on this text analyzer program which is kinda like a replica of what you find when you a do a word count in many office suites. It tells you stuff like number of sentences, longest sentence, shortest sentence and average length. Number of words, longest shortest and average word length. In addtion there is a word search to it.
    It took me a good 3 hours to realize that there was such a thing as a panel and I could impliment this to add more than one object to a borderlayout section.
    I think I have figured out everything with the StringTokenizer part, well except for how do add it to an array. Someone mentioned something to me about an
    islist.StringTokenizer or something, but I haven't been able to find anything else on this.
    Right now, however, my primary concern is how can I take input from a JTextArea and be able to parse it with the StringTokenizer, which to the best of my knowledge has to be a string. It this as simple as a getValue(); type thing or do i have to add some sort of action listener that finds out when it changes or something?
    thank you for your time

    I just figued out the JTextArea thing
    it is JTextArea.getText();
    im stupid :P

  • Question about reading a string or integer at the command line.

    Now I know java doesn't have something like scanf/readln buillt into it, but I was wondering what's the easiest, and what's the most robust way to add this functionality? (This may require two separate answers, sorry).
    The reason I ask is because I've been learning java via self study for the SCJA, and last night was the first time I ever attempted to do this and it was just hellish. I was trying to make a simple guessing game at the command line, I didn't realize there wasn't a command read keyboard input.
    After fighting with the code for an hour trying to figure it out, I finally got it to read the line via a buffered reader and InputStreamReader(System.in), and ran a try block that threw an exception. Then I just used parseInt to get the integer value for the guess.
    Another question: To take command line input, do you have to throw an exception? And is there an easier way to make this work? It seems awfully complicated to take user input without a jframe and calling swing.
    Edited by: JGannon on Nov 1, 2007 2:09 PM

    1. Does scanner still work in JDK1.6?Try it and see. (Hint: the 1.6 documentation for the class says "Since: 1.5")
    If you get behaviour that doesn't fit with what you expect it to do, post your code and a description of our expectations.
    2. Are scanner and console essentially the same thing?No.
    Scanner is a class that provides methods to break up its input into pieces and return them as strings and primitive values. The input can be a variety of things: File InputStream, String etc (see the Scanner constructor documentation). The emphasis is on the scanning methods, not the input source.
    Console, on the other hand, is for working with ... the console. What the "console" is (and whether it is anything) depends on the JVM. It doesn't provide a lot of functionality (although the "masked" password input can't be obtained easily any other way). In terms of your task it will provide a reader associated with the console from which you can create a BufferedReader and proceed as you are at the moment. The emphasis with this class is the particular input source (and output destination), not the scanning.
    http://java.sun.com/javase/6/docs/api/java/util/Scanner.html
    http://java.sun.com/javase/6/docs/api/java/io/Console.html

Maybe you are looking for

  • How to configure multiple listeners

    Hi All, I have installed 2 different Oracle instances on a single machine. I found that each oracle installation created its own Listener. I cant start both of the listeners at the same time. As a result, the respective applications cant talk to thei

  • Limitations for CIFing a material

    Hi,        Do we have any limitation to CIF a material to APO? I mean what are the prereqs to successful transfer of material from R/3 to APO, except Cifing the plant before materials. Any thing or MRP group, type, etc....?? I am trying to CIF a mate

  • N95 8GB Mass Memory in use error

    Hiya I have a N95 8GB and when I try to connect it to my PC I get the error message that the mass memory is in use by another application. I have stopped all running applications. (there where none) Done a factory soft reset. No difference. Still can

  • I'm trying to update my iPhone 5

    I'm trying to update my iPhone 5 & iPad 2 to iOS 7 but iTunes says it needs to be updated, however no updater will pop-up. I used both the Apple Software Updater and the 'check for update' option in iTunes but they both said my programs were up to da

  • Project Server SSRS report on project site list

    Hi All, We are using project server 2013. We need to generate the consolidated report using SSRS on the issues list in all project site. In SSRS we can create a data source for a particular project site, but how to get items from all project sites.