Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / March 2004

Tip: Looking for answers? Try searching our database.

absolute positioning

Thread view: 
Qu?bec - 17 Mar 2004 13:46 GMT
Hi,

                   Should not this put the label at an absolute position?
init(){
.................
  Label emboss = new Label("F??rie 'emboss' !");
   emboss.setFont(f);
   emboss.setEnabled(false);
GridBagLayout gridbag = new GridBagLayout();
   GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx=0;
gbc.gridy=absheight-30;
gridbag.setConstraints(emboss, gbc);
setLayout(gridbag);
   add(emboss);
...........

Jean
Chris Smith - 17 Mar 2004 15:56 GMT
Québec wrote:
>                     Should not this put the label at an absolute position?

No.  GridBagConstraints' gridx and gridy fields are not pixel offsets;
they are positions within the grid.  It makes little sense for you to
put your label in column number 'absheight - 30'.

Signature

www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Qu?bec - 17 Mar 2004 17:48 GMT
Well,

How can I put the label at an absolute position?

Don Quichotte

Qu?bec wrote:
>                     Should not this put the label at an absolute position?

No.  GridBagConstraints' gridx and gridy fields are not pixel offsets;
they are positions within the grid.  It makes little sense for you to
put your label in column number 'absheight - 30'.

Signature

www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Andrew Thompson - 17 Mar 2004 18:35 GMT
On Wed, 17 Mar 2004 11:48:01 -0500, Québec wrote:

> How can I put the label at an absolute position?

I think you should understand first,
why you should generally _not_ do that..
<http://groups.google.com/groups?th=e12ea8c6daf7eb65>

Note particularly Q 3. of the top 5.

Signature

Andrew Thompson
* http://www.PhySci.org/ Open-source software suite
* http://www.PhySci.org/codes/ Web & IT Help
* http://www.1point1C.org/ Science & Technology

Chris Smith - 17 Mar 2004 19:13 GMT
Québec wrote:
> How can I put the label at an absolute position?

There are two ways to control the placement of your components.

The best way to control the positioning of your components is to write a
LayoutManager class.  See the API docs on that class for more details.  
The LayoutManager gets called whenever the positioning of components
needs to change (for example, the window was resized or some component
has asked to redo the layout because its preferred or minimum size has
changed).  Once you've got your layout manager, set it on the container
using "setLayout(myLayout)", and you're all set.

As for writing the layout manager itself, you just need to pay attention
to factors such as:

   1. How big does each component want to be?  ("getPreferredSize()")
   2. How big does each component need to be?  ("getMinimumSize()")
   3. How big is the container? ("getWidth()" and "getHeight()")
   4. Of course, how you want to lay them out.

This gives you precise control over things like the relative positions
of components that is often elusive when using standard layout managers.  
Fully absolute positioning is possible too, of course, but since it
ignores three of the four factors above, it creates very sloppy
interfaces that look rather unprofessional when used anywhere except
where you developed them.

Signature

www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.