Results 1 to 8 of 8
  1. #1
    dougie1809 is offline Senior Member
    Join Date
    Nov 2011
    Posts
    116
    Rep Power
    0

    Default JTextArea problem

    Hi,

    I'm trying to list String elements that I add into a Stack data structure onto a JTextArea, but no data does not seem to appear. Would I need some JTextArea lister object or anything?

    Thanks

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: JTextArea problem

    Moved from New to Java.

    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
    dougie1809 is offline Senior Member
    Join Date
    Nov 2011
    Posts
    116
    Rep Power
    0

    Default Re: JTextArea problem

    Ok. I've got a class called Dvd which has only one instance field String 'title'. I've then got another class called DvdFileHandler which has methods to push String elements (DVD title's) onto a Stack list and also to push String elements off the top Stack, and then a list method to return the Stack (contains dvd title String titles).

    In my GUI, a third class, I have all components which I need and layed out, which I need to show here. Here is the code to try and list the contents of the Stack from the DvdFileHandler class:

    Java Code:
    dvds = dvdHandler.list();
    		for(int i=0; i<dvds.size(); i++)
    		{
    			jList.setText(jList.getText()+""+dvds.get(i)+ "\n");
    		}
    Thanks

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: JTextArea problem

    When you're offered a link to a web resource, we expect you to go through it. No SSCCE, no help -- not because we won't but because we can't.

    But. Do you really have a variable jList that refers to a JTextArea? That's a bad choice.

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

  5. #5
    dougie1809 is offline Senior Member
    Join Date
    Nov 2011
    Posts
    116
    Rep Power
    0

    Default Re: JTextArea problem

    Yes I did go through it, its NOT all the code, its just a snipped of code. Rather than giving me links, I'd like you to explain what you want me to do, in order for you to provide me some help.
    And yes, why shall I change the variable name to area or some other related name? Does that even matter to the post I started here?

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: JTextArea problem

    Quote Originally Posted by dougie1809 View Post
    Yes I did go through it, its NOT all the code, its just a snipped of code.
    And is that what the web page describes as an SSCCE?

    Quote Originally Posted by dougie1809 View Post
    Rather than giving me links, I'd like you to explain what you want me to do, in order for you to provide me some help.
    I already did.

    Quote Originally Posted by dougie1809 View Post
    And yes, why shall I change the variable name to area or some other related name? Does that even matter to the post I started here?
    Using meaningful variable names is good programming practice. Considering that a commonly used class exists named JList, using the variable name jList for a JTextArea is a bad choice. And no, a variable name doesn't make a difference how the code executes. Why should it?

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

  7. #7
    dougie1809 is offline Senior Member
    Join Date
    Nov 2011
    Posts
    116
    Rep Power
    0

    Default Re: JTextArea problem

    Ok fair enough. I've seen other posts that you have replied on, and they have posted their full entire code, but your giving out to me on one small snipped of code?
    All Id like to know is, can you understand my concept of the problem in terms of the way I am trying to list the contents of Stack elements?

    Thanks.

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: JTextArea problem

    For the last time, without an SSCCE I have no idea whether that code snippet should be even expected to do what you say you want it to do.

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

Similar Threads

  1. Problem in JtextArea
    By justbeller in forum AWT / Swing
    Replies: 11
    Last Post: 07-25-2011, 10:20 AM
  2. JTextArea resizing problem
    By me.anchit in forum AWT / Swing
    Replies: 5
    Last Post: 07-24-2011, 03:01 PM
  3. Problem in JTextArea
    By justbeller in forum AWT / Swing
    Replies: 6
    Last Post: 02-15-2011, 04:02 PM
  4. Problem with JTEXTAREA
    By javanew in forum New To Java
    Replies: 6
    Last Post: 05-07-2010, 03:14 PM
  5. JTextArea problem
    By javanew in forum AWT / Swing
    Replies: 2
    Last Post: 05-04-2010, 11:31 PM

Posting Permissions

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