944,121 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 6433
  • Java RSS
Feb 8th, 2006
0

No able to set the jpanel positions

Expand Post »
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/G...ridlayout.html
but no avail
Someone please help me
Thanks
Attached Files
File Type: java EmailWindow2.java (10.3 KB, 22 views)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
javafan is offline Offline
10 posts
since Feb 2006
Feb 9th, 2006
0

Re: No able to set the jpanel positions

the JVM determines component spacing and sizing at runtime. It's pretty much out of your hands.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Feb 9th, 2006
0

Re: No able to set the jpanel positions

You mean to say I have no control over the display
Then how do I do this?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
javafan is offline Offline
10 posts
since Feb 2006
Feb 9th, 2006
0

Re: No able to set the jpanel positions

Quote originally posted by javafan ...
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."



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.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Feb 9th, 2006
0

Re: No able to set the jpanel positions

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.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Feb 9th, 2006
0

Re: No able to set the jpanel positions

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:
Java Syntax (Toggle Plain Text)
  1. GridBagLayout gridbag = new GridBagLayout();
  2. this.getContentPane().setLayout(gridbag);
  3. GridBagConstraints c = new GridBagConstraints();
  4. c.fill = GridBagConstraints.BOTH;
  5. //to add components you just asign a grid position and a weight
  6. 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/tutor...t/gridbag.html
Reputation Points: 11
Solved Threads: 0
Newbie Poster
ROGENATOR is offline Offline
17 posts
since Sep 2005
Feb 9th, 2006
0

Re: No able to set the jpanel positions

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.
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004
Feb 10th, 2006
0

Re: No able to set the jpanel positions

NullLayout is never recommended except on platforms where there is no other layout manager available (maybe some mobile platforms).
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Execute Java app question
Next Thread in Java Forum Timeline: java help for newbie





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC