GridLayout

Is there anyway to get the contents of each row?I'm building rows (JPanels) based on the number of results from a db file and adding them to GridLayout. now i need to retrieve each one to do a commit
[214 byte] By [llpindda] at [2007-11-27 2:22:25]
# 1
Use a JTable: http://forum.java.sun.com/thread.jspa?forumID=57&threadID=5123381Otherwise JPanel extends Container which has method to retrieve each component added to the container.
camickra at 2007-7-12 2:26:33 > top of Java-index,Desktop,Core GUI APIs...
# 2

Thanks for the response.

I don't think i can use a JTable for this particular problem (or i dont have enough experience w/JTable).

Here is what im trying to do:

Each row is a message which joins to another table which has various codes for that message,

they would like it to work like a word processor app, but i need to keep each line seprate

(adhere to the normalized db design).

each row will need jbuttons/jtextfields etc (for adding, editing, deleting message lines).

so what i did is... query the db build that many jPanels put them into a JGridLayout and showed on the screen.

everything works fine.

but when they make changes to a panel, i need a way to get that panel from the layout manager.

not components from JPanel, but JPanels from GridLayout.

or maybe im using the wrong layout for this problem?

Message was edited by:

llpindd

llpindda at 2007-7-12 2:26:33 > top of Java-index,Desktop,Core GUI APIs...
# 3
>>Otherwise JPanel extends Container which has method to retrieve >>each component added to the container. Nevermind, I don't know what I was thinking. DUHThanks
llpindda at 2007-7-12 2:26:33 > top of Java-index,Desktop,Core GUI APIs...
# 4

JFrame f = new JFrame("This is a test");

f.setSize(700, 600);

Container content = f.getContentPane();

//content.setBackground(Color.white);

CommentsMainPnl cp = new CommentsMainPnl ();

cp.getPnlAllComments().setLayout( new GridLayout(100,1));

cp.getPnlAllComments() .setPreferredSize( new Dimension(700,20));

for (int i = 0 ; i < 100 ; ++i){

cp.getPnlAllComments() .add( new CommentLnPanel () );

}

cp.getJspComments() .setViewportView(cp.getPnlAllComments() );

content.add( cp );

why does it sqeezes all the Jpanels together instead of creating a vertical scroll bar?

llpindda at 2007-7-12 2:26:33 > top of Java-index,Desktop,Core GUI APIs...
# 5

> why does it sqeezes all the Jpanels together instead of creating a vertical scroll bar?

I would guess that the preferred size of one of your custom panels is wrong, but the code you posted is of little use in determining the problem.

If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program[/url] (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.

Don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags[/url] so the posted code retains its original formatting.

camickra at 2007-7-12 2:26:34 > top of Java-index,Desktop,Core GUI APIs...
# 6
Yea, not excatly sure what it was, but i changed some layout properties in the custom panels, and it started working. It must have been the preferred size. thanks for your help.
llpindda at 2007-7-12 2:26:34 > top of Java-index,Desktop,Core GUI APIs...