BorderLayout problem

Hello.

I want to add to my BorderLayout two things:

1) JTable

2) JToolBar

but I have problems with them, i can't do it to work them both in the same time. When i have got JTable I don't have JToolBar. What could be wrong?

Some code of layout:

pane.add(table, BorderLayout.NORTH);

pane.add(toolBar,BorderLayout.South);

I've tried many different BorderLayout but they don't work. I think the problem is something different.

Ok. My mistake i didn;t saw some mistake in code but i fix it. Problem was in Layout, but now I have another problem with JTable

I code JTable like this:

public SimpleTableDemo(){

super(new GridLayout(1,0));

String[] columnNames ={"First Name",

"Last Name",

"Sport",

"# of Years",

"Vegetarian"};

Object[][] data ={

{"Mary","Campione",

"Snowboarding",new Integer(5),new Boolean(false)},

{"Alison","Huml",

"Rowing",new Integer(3),new Boolean(true)},

{"Kathy","Walrath",

"Knitting",new Integer(2),new Boolean(false)},

{"Sharon","Zakhour",

"Speed reading",new Integer(20),new Boolean(true)},

{"Philip","Milne",

"Pool",new Integer(10),new Boolean(false)}

};

final JTable table =new JTable(data, columnNames);

but i don't have columnNames. They don't apper in my table.

Message was edited by:

Lukasz_1981

Message was edited by:

Lukasz_1981

[3054 byte] By [Lukasz_1981a] at [2007-10-3 9:31:23]
# 1

JTable uses Model - View - Controller design pattern.

for more information about how to use Table Model refere the following link

http://java.sun.com/docs/books/tutorial/uiswing/components/table.html

I'm not sure about how to do this without table model...

Hope some one else may give you a simple way to do...

But i suggest the above way.

chaos_begins_herea at 2007-7-15 4:46:11 > top of Java-index,Desktop,Core GUI APIs...
# 2
try adding the JTable to the CENTER
shirish-wagha at 2007-7-15 4:46:11 > top of Java-index,Desktop,Core GUI APIs...
# 3

> but i don't have columnNames. They don't apper in my table.

Look at the tutorial example closer. The table is not added directly to the content pane. It is added to another component, then that component is added to the content pane.

The idea of reading the tutorial is to execute the example code to prove that it works and then compare your code to the tutorial code to see whats different if it doesn't work.

You can also read the JTable API introduction for an explanation on how this works.

camickra at 2007-7-15 4:46:11 > top of Java-index,Desktop,Core GUI APIs...