Tables In Java

A

azzamqazi

Hi,
I was wondering if someone can help me out here please. I am creating a
JTable and displaying it in a window but it gives me Array Out Of
Bounds Exception. The code is as follows

Object[][] data = {
{"j"},
{"j"},
{"j"},
{"j"},
{"j"},
{"j"},{"j"},{"j"},{"j"},{"j"},{"j"} };

String[] columnNames = {"a",
"a","a","a","a","a","a","a","a","a","a"};



JTable table = new JTable(data,columnNames);

JScrollPane scrollPane = new JScrollPane(table);


Thanks a lot for help!!!>
 
A

azzamqazi

Thanks you so much. I finally figured it out. I have a problem though.
Lets
say i have names( And other information) seperated by ",". How can i
display them in different fields. I wrote it as follows but it displays

it in one line. Any help will be much appreciated.

Thanks a lot!!!


Object[][] data = { { name, last name, family, series1, series2,
series3,series4, series1, series6, series7, series8} };


String[] columnNames = {"Event name",
"Event type",
"Event series",
"Event eventDate",
"Event eventStartTime","Event eventEndTime","Event
sellStartDate","Event sellEndDate","Event price","Event
performance","Event sponser"};


The names, lastname etc is all display in one line.


Thanks a lot!!!.
 
H

Henry

Thanks you so much. I finally figured it out. I have a problem though.
Lets
say i have names( And other information) seperated by ",". How can i
display them in different fields. I wrote it as follows but it displays

it in one line. Any help will be much appreciated.

Thanks a lot!!!


Object[][] data = { { name, last name, family, series1, series2,
series3,series4, series1, series6, series7, series8} };


String[] columnNames = {"Event name",
"Event type",
"Event series",
"Event eventDate",
"Event eventStartTime","Event eventEndTime","Event
sellStartDate","Event sellEndDate","Event price","Event
performance","Event sponser"};


The names, lastname etc is all display in one line.


Thanks a lot!!!.

Have a look at the Java Tutorial:
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html.

--
Rhino

Hi,
I was wondering if someone can help me out here please. I am creating a
JTable and displaying it in a window but it gives me Array Out Of
Bounds Exception. The code is as follows

Object[][] data = {
{"j"},
{"j"},
{"j"},
{"j"},
{"j"},
{"j"},{"j"},{"j"},{"j"},{"j"},{"j"} };

String[] columnNames = {"a",
"a","a","a","a","a","a","a","a","a","a"};



JTable table = new JTable(data,columnNames);

JScrollPane scrollPane = new JScrollPane(table);


Thanks a lot for help!!!>
 
A

azzamqazi

yeah i took a loook at this but cant figure out what i am doing wrong.
Henry said:
Thanks you so much. I finally figured it out. I have a problem though.
Lets
say i have names( And other information) seperated by ",". How can i
display them in different fields. I wrote it as follows but it displays

it in one line. Any help will be much appreciated.

Thanks a lot!!!


Object[][] data = { { name, last name, family, series1, series2,
series3,series4, series1, series6, series7, series8} };


String[] columnNames = {"Event name",
"Event type",
"Event series",
"Event eventDate",
"Event eventStartTime","Event eventEndTime","Event
sellStartDate","Event sellEndDate","Event price","Event
performance","Event sponser"};


The names, lastname etc is all display in one line.


Thanks a lot!!!.

Have a look at the Java Tutorial:
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html.

--
Rhino

Hi,
I was wondering if someone can help me out here please. I am creating a
JTable and displaying it in a window but it gives me Array Out Of
Bounds Exception. The code is as follows

Object[][] data = {
{"j"},
{"j"},
{"j"},
{"j"},
{"j"},
{"j"},{"j"},{"j"},{"j"},{"j"},{"j"} };

String[] columnNames = {"a",
"a","a","a","a","a","a","a","a","a","a"};



JTable table = new JTable(data,columnNames);

JScrollPane scrollPane = new JScrollPane(table);


Thanks a lot for help!!!>
 
H

Henry

yeah i took a loook at this but cant figure out what i am doing wrong.

The code in your post looks okay so have a look at the code that ISN'T
in your post and compare it to the article from the Java Tutorial.
Somewhere, there has to be a difference.

If you still don't see a difference, run your code in a debugger and
step through it one statement at a time, carefully watching all of the
variables to ensure each is behaving exactly as it should. That should
reveal your problem.

Most IDEs have integrated debuggers and these are wonderful tools for
finding problems. If you aren't using an IDE, maybe it is time to
consider using one. There are lots of good free ones. I'm quite fond of
Eclipse, as are many others on this newsgroup, and its debugger would
help you find your problem quite quickly. There's a learning curve
involved in learning to use your IDE and its debugger but it can pay
for itself many times over in speeding up software development. I
wouldn't typically recommend an IDE to someone who is just starting to
learn Java but, once you've written your first few play programs and
are ready to do some serious development, an IDE can really help your
productivity, especially for finding problems.

--
Henry


Henry said:
Thanks you so much. I finally figured it out. I have a problem though.
Lets
say i have names( And other information) seperated by ",". How can i
display them in different fields. I wrote it as follows but it displays

it in one line. Any help will be much appreciated.

Thanks a lot!!!


Object[][] data = { { name, last name, family, series1, series2,
series3,series4, series1, series6, series7, series8} };


String[] columnNames = {"Event name",
"Event type",
"Event series",
"Event eventDate",
"Event eventStartTime","Event eventEndTime","Event
sellStartDate","Event sellEndDate","Event price","Event
performance","Event sponser"};


The names, lastname etc is all display in one line.


Thanks a lot!!!.

Have a look at the Java Tutorial:
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html.

--
Rhino

(e-mail address removed) wrote:
Hi,
I was wondering if someone can help me out here please. I am creating a
JTable and displaying it in a window but it gives me Array Out Of
Bounds Exception. The code is as follows

Object[][] data = {
{"j"},
{"j"},
{"j"},
{"j"},
{"j"},
{"j"},{"j"},{"j"},{"j"},{"j"},{"j"} };

String[] columnNames = {"a",
"a","a","a","a","a","a","a","a","a","a"};



JTable table = new JTable(data,columnNames);

JScrollPane scrollPane = new JScrollPane(table);


Thanks a lot for help!!!>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top