how many layout manager can i use in a single JPanel ..?
One.
Wow I changed my sig!
Haha, one of the shortest answers around hereOne.
It's indeed 1, if you want another one, you must put a JPanel in a JPanel where both have the layout you want.
if(provided_answer == shortest_answer)
{
easy to understand ;
}
else
{
head bursting;
haha;
}
what do u mean by putting a JPanel inside a JPanel ..?
using add method in JPanel to include another JPanel..?
Yes if you would like a gridlayout in the SOUTH of a borderlayout for example you have no other choice than using 2 JPanels:
[highlight=Java]
JPanel borderPanel;
JPanel gridPanel;
borderPanel = new JPanel();
gridPanel = new JPanel();
borderPanel.setLayout(new BorderLayout());
gridPanel.setLayout(new GridLayout(x,y));
borderPanel.add(gridPanel, BorderLayout.SOUTH);
[/highlight]
where x and y are numbers. Only 1 of them may be a number above 0, the other one must be set to 0 (zero)
You can make it shorter by doing:
[highlight=Java]
borderPanel = new JPanel(new BorderLayout());
[/highlight]
@oxano: Why not combine the declaration and the definition of the JPanel objects and use the Layout Manager constructor?
Code:JPanel borderPanel = new JPanel(new BorderLayout()); JPanel gridPanel = new JPanel(new GridLayout(x, y));
Wow I changed my sig!
To make it clear. I did mention that you can do it shorter by doing so at the end of my post.
I was more referring to combining the declaration and constructor into one statement, I did notice what you said.
But yeah, making sure it's clearer is a good objective, I 'spose. Just wanted to make sure that if you use it in production code you do it the short, easier way.
Wow I changed my sig!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks