Hi
I am not able to set the position of Jpanel, having a tough time.

Code is attached.
1. How can I reduce the gap between
To and textbox
Cc and textbox
etc
2. How can I reduce the vertical space between Send/Contact/Spell/.... and the row containing To with textbox
I read tutorial like
http://www.leepoint.net/notes-java/GUI/layouts/30gridlayout.html
but no avail
Someone please help me
Thanks

the JVM determines component spacing and sizing at runtime. It's pretty much out of your hands.

You mean to say I have no control over the display
Then how do I do this?

You mean to say I have no control over the display
Then how do I do this?

Jwenting just said "It's pretty much out of your hands."
:confused:


I don't see what the problem is, how it looks is just pointless fluff. If it works it works. What more do you want.

you have absolute control over the way the components are displayed in relation to each other.
You have very little control over how (what size and visual style) they're displayed at.

This is deliberate to enable the JVM to make it look decent on different operating systems that have different ways of doing things.
If you go and set that an input control is X pixels by Y pixels with a border of Z pixels that may look great on your Windows machine but completely crappy on a Mac or X terminal.
It may even be impossible to render there at all at that size.

Greetings:
You could try with GridBagLayout, it allows you to control a little more the appereance by using weights for the spaces that the components use, something like this:

GridBagLayout gridbag = new GridBagLayout();
this.getContentPane().setLayout(gridbag);
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
//to add components you just asign a grid position and a weight
g.gridx=0;c.gridy=0;c.weightx=2;c.weighty=0;this.getContentPane().add(component,c);

Here is the description of GridbagLayout from java.sun, http://java.sun.com/docs/books/tutorial/uiswing/layout/gridbag.html

You could always set the layout to null and set the bounds, but I don't know if that's a good idea or not...... That is, if you are talking about positioning components.

NullLayout is never recommended except on platforms where there is no other layout manager available (maybe some mobile platforms).