Results 1 to 5 of 5
  1. #1
    deepsree1417 is offline Member
    Join Date
    Feb 2012
    Posts
    2
    Rep Power
    0

    Default JTextArea content is not displayed

    Hi,

    I tried to display some text in JTextArea. but its not displayed , but when i did System.out.println(JtextArea.getTeaxt()) the content is displayed in the output window.

    Can anyone find the mistake in the code?

    Here is the code...

    public void scanner(File f) throws Exception
    {


    int worm_count=0,file_count=0,dir_count=0;

    String file_name;
    File[] listoffiles = f.listFiles();
    String pathforworms = "C:/Documents and Settings/Srudent/My Documents/NetBeansProjects/securenet/WormList.txt";
    File wormlist = new File(pathforworms);
    BufferedReader br = new BufferedReader(new FileReader(wormlist));
    for(int i=0;i<listoffiles.length;i++)
    {
    if (listoffiles[i].isFile())// for checking wether it is a file or not
    {
    file_count++;
    file_name = listoffiles[i].toString();

    //outwindow is the name of textarea
    outwindow.setText(outwindow.getText()+ "\n Scanning ..... "+file_name);
    Thread.sleep(100);

    System.out.println(outwindow.getText());
    while(br.readLine()!=null)
    {
    String name = br.readLine();
    // System.out.println(name);
    if(file_name.contains(name))// if it is a file then checking its name from
    { // the list
    worm_count++;
    outwindow.append("\n Worm Detected of the type"+name);
    listoffiles[i].delete();
    outwindow.append("\n Worm has been deleted");
    }
    }
    }
    else if(listoffiles[i].isDirectory()) // this is to check wether its a directory or not
    {
    dir_count++;

    outwindow.append("\n Now scanning .."+listoffiles[i].getName());
    scanner(listoffiles[i]);

    }
    }
    }

    Thanks
    Deepsree

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: JTextArea content is not displayed

    Quote Originally Posted by deepsree1417 View Post
    Here is the code...
    You didn't post the code that's the cause of the issue. To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem. Not all your code.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: JTextArea content is not displayed

    Two likely candidates: (1) the JTextArea you're appending to isn't the one displayed in the GUI or (2) calling sleep(...) on the EDT.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    deepsree1417 is offline Member
    Join Date
    Feb 2012
    Posts
    2
    Rep Power
    0

    Default Re: JTextArea content is not displayed

    thanks sir...

    i confirmed the control name . and i removed the sleep() also.
    but still the problem exists.

    outwindow.append("\n Scanning ..... "+file_name);

    i gave this statement to display the contents in the textarea.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: JTextArea content is not displayed

    So where's that SSCCE?

    edit
    1) Java doesn't have 'controls' -- there are AWT and Swing components
    2) A component doesn't have a name, unles you set one via the setName(...) method

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Nee help in writing the JTextarea content to a file
    By ArpanSe in forum AWT / Swing
    Replies: 1
    Last Post: 09-18-2011, 05:04 PM
  2. Replies: 1
    Last Post: 04-19-2011, 08:52 AM
  3. Replies: 10
    Last Post: 05-24-2010, 08:25 PM
  4. Update content on a JTextArea.
    By Masochist in forum New To Java
    Replies: 7
    Last Post: 05-13-2010, 10:18 PM
  5. Jtextarea Content Display Problem
    By REVANSIDDHA in forum Advanced Java
    Replies: 1
    Last Post: 03-31-2009, 06:53 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •