Results 1 to 20 of 20
- 07-28-2012, 12:47 PM #1
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
Error with displaying int textArea
reads from the database:
My Object class with getters and setters: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 }
Class where i display the information read: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 = ""; }
the line with the error: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(); }
Error:Java Code:textArea1 = new java.awt.TextArea(data.getNaam());
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.
- 07-28-2012, 12:59 PM #2
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.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 07-28-2012, 01:12 PM #3
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
Re: Error with displaying int textArea
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?1. data isn't a DierObj. Look at line 4 in the third code segment you posted. What is the type of data?
- 07-28-2012, 01:14 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,379
- Blog Entries
- 7
- Rep Power
- 17
- 07-28-2012, 01:30 PM #5
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
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.
- 07-28-2012, 01:43 PM #6
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
Re: Error with displaying int textArea
Please help! I'm wasting so much time on this.
- 07-28-2012, 01:51 PM #7
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,379
- Blog Entries
- 7
- Rep Power
- 17
- 07-28-2012, 01:59 PM #8
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
- 07-28-2012, 02:07 PM #9
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
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());
- 07-28-2012, 02:10 PM #10
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,379
- Blog Entries
- 7
- Rep Power
- 17
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,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 07-28-2012, 02:17 PM #11
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
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.
- 07-28-2012, 02:41 PM #12
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,379
- Blog Entries
- 7
- Rep Power
- 17
- 07-28-2012, 03:29 PM #13
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
Re: Error with displaying int textArea
I can speak Suid-Afrikaans and understand a little Duch.
- 07-28-2012, 03:35 PM #14
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,379
- Blog Entries
- 7
- Rep Power
- 17
- 07-28-2012, 03:39 PM #15
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
Re: Error with displaying int textArea
Hahahaha omw! Ek sou nooit dink daars iemand hier wat Nederlands praat nie. =D
- 07-28-2012, 03:51 PM #16
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,379
- Blog Entries
- 7
- Rep Power
- 17
Re: Error with displaying int textArea
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 07-28-2012, 03:56 PM #17
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
Re: Error with displaying int textArea
Yeah, its thanks to Duch that we have Afrikaans.
Vriendelike groete
Johannes
- 07-28-2012, 04:06 PM #18
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,379
- Blog Entries
- 7
- Rep Power
- 17
Re: Error with displaying int textArea
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 07-29-2012, 07:51 PM #19
Senior Member
- Join Date
- Oct 2010
- Posts
- 139
- Rep Power
- 0
- 07-29-2012, 09:00 PM #20
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,379
- Blog Entries
- 7
- Rep Power
- 17
Re: Error with displaying int textArea
When people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
Error displaying an Image!
By javabeginner29 in forum Java AppletsReplies: 4Last Post: 02-15-2012, 06:21 PM -
Displaying text in textarea with a button
By brendan89 in forum New To JavaReplies: 1Last Post: 11-29-2011, 04:53 PM -
Displaying a selected image with a JFileChooser into a textarea
By Jonte79 in forum AWT / SwingReplies: 2Last Post: 04-24-2009, 08:10 AM -
Displaying a file slected with a JFileChooser into a textarea
By happysal in forum AWT / SwingReplies: 1Last Post: 11-13-2008, 07:43 AM -
Error With Simply Displaying Picture
By JDCAce in forum Java AppletsReplies: 4Last Post: 10-07-2008, 08:09 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks