| Author |
How to add components from the top of the JPanel using GridBagLayout?
|
Kannan Somaiah
Ranch Hand
Joined: Jun 06, 2006
Posts: 33
|
|
Hi ALl, How to add components from the top of the JPanel using GridBagLayout? I hope by default it starts from the centre. Here is my code. JPanel panel = new JPanel(); GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); panel.setLayout(gbl); priceButton = new JButton(); panel.add(priceButton); I tried diff options but it didnt work. Thanks in advance. Regards, Kannan Somaiah
|
 |
satishkumar janakiraman
Ranch Hand
Joined: May 03, 2004
Posts: 334
|
|
Can you explain your question further? Do you want to add your components in North side or do you want to pile up your components one by one ?
|
 |
Kannan Somaiah
Ranch Hand
Joined: Jun 06, 2006
Posts: 33
|
|
I want to add my components in the North side. Thanks, Kannan Somaiah
|
 |
satishkumar janakiraman
Ranch Hand
Joined: May 03, 2004
Posts: 334
|
|
. Did you try the above in your code?
|
 |
Kannan Somaiah
Ranch Hand
Joined: Jun 06, 2006
Posts: 33
|
|
Hi, Thanks for your erply. I am adding components to a JPanel. I don't have frame here. Is there any similar method which can be applied to JPanel and get the same things done on a JPanel? Thanks, Kannan Somaiah
|
 |
Kannan Somaiah
Ranch Hand
Joined: Jun 06, 2006
Posts: 33
|
|
I tried the code snippet you had sent. But I couldn't crack it. Regards, Kannan Somaiah
|
 |
satishkumar janakiraman
Ranch Hand
Joined: May 03, 2004
Posts: 334
|
|
In your code why do you use GridBagLayout? Use borderlayout
|
 |
Kannan Somaiah
Ranch Hand
Joined: Jun 06, 2006
Posts: 33
|
|
Hi, I started with gridBagLayout as I have to add many more components to the same panel. So can I solve this problem using GridBagLayout itself? Please advice. Regards, Kannan Somaiah
|
 |
satishkumar janakiraman
Ranch Hand
Joined: May 03, 2004
Posts: 334
|
|
|
You would get better solution if you give us the clear requirement.
|
 |
 |
|
|
subject: How to add components from the top of the JPanel using GridBagLayout?
|
|
|