Results 1 to 20 of 20
  1. #1
    Johanis is offline Senior Member
    Join Date
    Oct 2010
    Posts
    139
    Rep Power
    0

    Question Error with displaying int textArea

    reads from the database:
    Java Code:
    public DierObj[] result ()
          {
          DierObj[] arr = new DierObj[60];
          
             try
             {
                Statement stmt = dbcon.createStatement ();
                String sql = "SELECT * FROM Diere";
                ResultSet rs = stmt.executeQuery (sql);
                int tel = 0;
                while (rs.next ())
                {
                   arr[tel] = new DierObj();
                   arr[tel].setId(rs.getInt ("ID"));
                   arr[tel].setWetnam(rs.getString ("Scientific Name"));
                   arr[tel].setNaam(rs.getString ("Naam"));
                   arr[tel].setBeskrywing(rs.getString ("Beskrywing"));
                   tel++;
                } // while
    
             }
    My Object class with getters and setters:
    Java Code:
    class DierObj {
    
        private int Id;
        private String Wetnam;
        private String naam;
        private String Beskrywing;
    
        public DierObj(int Id, String Wetnam, String naam, String Beskrywing) {
            this.Id = Id;
            this.Wetnam = Wetnam;
            this.naam = naam;
            this.Beskrywing = Beskrywing;
        }
    
        public DierObj() {
            this.Id = 0;
            this.Wetnam = "";
            this.naam = "";
            this.Beskrywing = "";
        }
    Class where i display the information read:
    Java Code:
    public class Dier extends javax.swing.JFrame {
        Connect dierinfo = new Connect();
          String[] gSkik;
            DierObj[] data;
            String koos;
        /** Creates new form Dier */
        public Dier() {
            data = dierinfo.result();
            this.setVisible(true);
            initComponents();
        }
    the line with the error:
    Java Code:
    textArea1 = new java.awt.TextArea(data.getNaam());
    Error:
    C:\Users\Johannes\Documents\IT\2012\PAT 2012\Fase 3\Wildresjava\src\Dier.java:40: cannot find symbol
    symbol : method getNaam()
    location: class DierObj[]
    textArea1 = new java.awt.TextArea(data.getNaam());
    1 error

    I cannot understand why it can't find the method getNaam. At School it was working.

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

    Default Re: Error with displaying int textArea

    1. data isn't a DierObj. Look at line 4 in the third code segment you posted. What is the type of data?

    2. (but more important) Follow the Java coding conventions. Variable names should not start with an uppercase letter.

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

  3. #3
    Johanis is offline Senior Member
    Join Date
    Oct 2010
    Posts
    139
    Rep Power
    0

    Default Re: Error with displaying int textArea

    Ill be sure to read through the coding convention thanks.
    1. data isn't a DierObj. Look at line 4 in the third code segment you posted. What is the type of data?
    I don't understand what you mean. According to what I know the types are correct?

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,344
    Blog Entries
    7
    Rep Power
    20

    Default Re: Error with displaying int textArea

    Quote Originally Posted by Johanis View Post
    Ill be sure to read through the coding convention thanks.

    I don't understand what you mean. According to what I know the types are correct?
    Those little square brackets are significant, e.g. a DierObj isn't a DierObj[].

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    Johanis is offline Senior Member
    Join Date
    Oct 2010
    Posts
    139
    Rep Power
    0

    Default Re: Error with displaying int textArea

    Its suppose to be [] because I'm working with a array?
    Ive tried everything, can't seem to figure it out and my project's deadline is due for two days.

  6. #6
    Johanis is offline Senior Member
    Join Date
    Oct 2010
    Posts
    139
    Rep Power
    0

    Default Re: Error with displaying int textArea

    Please help! I'm wasting so much time on this.

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,344
    Blog Entries
    7
    Rep Power
    20

    Default Re: Error with displaying int textArea

    Quote Originally Posted by Johanis View Post
    Please help! I'm wasting so much time on this.
    'data' is an array of DierObj but you're treating it as if it were a single DierObj; the compiler doesn't buy that.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    Johanis is offline Senior Member
    Join Date
    Oct 2010
    Posts
    139
    Rep Power
    0

    Default Re: Error with displaying int textArea

    Quote Originally Posted by JosAH View Post
    'data' is an array of DierObj but you're treating it as if it were a single DierObj; the compiler doesn't buy that.

    kind regards,

    Jos
    I'm first trying to display only the first thing read out. I'm so completely confused, because at school it worked. I don't know how to fix the problem you confronted me with...

  9. #9
    Johanis is offline Senior Member
    Join Date
    Oct 2010
    Posts
    139
    Rep Power
    0

    Default Re: Error with displaying int textArea

    I got it working!

    Java Code:
    public class Dier extends javax.swing.JFrame {
        Connect dierinfo = new Connect();
        String[] gSkik;
        DierObj[] data;
        int tel = 0;
       /** Creates new form Dier */
        public Dier() {
            data = dierinfo.result();
            this.setVisible(true);
            initComponents();
        
        }
    Java Code:
    textArea1 = new java.awt.TextArea(data[tel].getNaam());

  10. #10
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,344
    Blog Entries
    7
    Rep Power
    20

    Default Re: Error with displaying int textArea

    If you have put the 'first thing read' in the array, data[0] might be what you're looking for; if it worked at school you must've ran different code there. b.t.w. I didn't confront you with anything; your compiler did that (and rightly so).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  11. #11
    Johanis is offline Senior Member
    Join Date
    Oct 2010
    Posts
    139
    Rep Power
    0

    Default Re: Error with displaying int textArea

    I'm actually Afrikaans, not that great in English, the confront part was meant like the problem that you are talking about.

  12. #12
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,344
    Blog Entries
    7
    Rep Power
    20

    Default Re: Error with displaying int textArea

    Quote Originally Posted by Johanis View Post
    I'm actually Afrikaans, not that great in English, the confront part was meant like the problem that you are talking about.
    Can you speak Zuid Afrikaans or even Dutch?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  13. #13
    Johanis is offline Senior Member
    Join Date
    Oct 2010
    Posts
    139
    Rep Power
    0

    Default Re: Error with displaying int textArea

    I can speak Suid-Afrikaans and understand a little Duch.

  14. #14
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,344
    Blog Entries
    7
    Rep Power
    20

    Default Re: Error with displaying int textArea

    Quote Originally Posted by Johanis View Post
    I can speak Suid-Afrikaans and understand a little Duch.
    This is so cool; let's do the secret dance and the secret handshake (zodat andere mensen er helemaal niets van begrijpen ;-)

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  15. #15
    Johanis is offline Senior Member
    Join Date
    Oct 2010
    Posts
    139
    Rep Power
    0

    Default Re: Error with displaying int textArea

    Hahahaha omw! Ek sou nooit dink daars iemand hier wat Nederlands praat nie. =D

  16. #16
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,344
    Blog Entries
    7
    Rep Power
    20

    Default Re: Error with displaying int textArea

    Quote Originally Posted by Johanis View Post
    Hahahaha omw! Ek sou nooit dink daars iemand hier wat Nederlands praat nie. =D
    I understood that; Zuid Afrikaans (Suid Afrikaans) must sound and look like some medieval form of Dutch (they were both the same in those days); fascinating ...

    vriendelijke groet,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  17. #17
    Johanis is offline Senior Member
    Join Date
    Oct 2010
    Posts
    139
    Rep Power
    0

    Default Re: Error with displaying int textArea

    Yeah, its thanks to Duch that we have Afrikaans.
    Vriendelike groete
    Johannes

  18. #18
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,344
    Blog Entries
    7
    Rep Power
    20

    Default Re: Error with displaying int textArea

    Quote Originally Posted by Johanis View Post
    Yeah, its thanks to Duch that we have Afrikaans.
    Vriendelike groete
    Johannes
    Yep, us Dutch have always been good, altuistic, fine benevolent people; while other tribes went to war, us Dutch gave away our beautiful language for free ;-)

    kind regards,

    Jos (<--- braaf mannetje)
    cenosillicaphobia: the fear for an empty beer glass

  19. #19
    Johanis is offline Senior Member
    Join Date
    Oct 2010
    Posts
    139
    Rep Power
    0

    Default Re: Error with displaying int textArea

    Quote Originally Posted by JosAH View Post
    Yep, us Dutch have always been good, altuistic, fine benevolent people; while other tribes went to war, us Dutch gave away our beautiful language for free ;-)

    kind regards,

    Jos (<--- braaf mannetje)
    Hahaha yes braaf mannetjie you are :)
    You Duch are nice people, I have as Duch friend as here is South Africa as well.

  20. #20
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,344
    Blog Entries
    7
    Rep Power
    20

    Default Re: Error with displaying int textArea

    Quote Originally Posted by Johanis View Post
    Hahaha yes braaf mannetjie you are :)
    You Duch are nice people, I have as Duch friend as here is South Africa as well.
    Tell them to behave for once ... the Dutch are everywhere around the globe as in 'scum floats' ;-)

    kind regards,

    Jos (<--- heilig boontje)

    ps. thanks for the nice words; I'll tell my fellow Dutchmen around here about you, so be warned ;-)
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Error displaying an Image!
    By javabeginner29 in forum Java Applets
    Replies: 4
    Last Post: 02-15-2012, 06:21 PM
  2. Displaying text in textarea with a button
    By brendan89 in forum New To Java
    Replies: 1
    Last Post: 11-29-2011, 04:53 PM
  3. Replies: 2
    Last Post: 04-24-2009, 08:10 AM
  4. Replies: 1
    Last Post: 11-13-2008, 07:43 AM
  5. Error With Simply Displaying Picture
    By JDCAce in forum Java Applets
    Replies: 4
    Last Post: 10-07-2008, 08:09 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
  •