[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
JavaFAQ_FormLayout
--------------------- FOR ALL THOSE THAT HATE USING LAYOUTS AND LIKE TO DO THINGS THE HARD LONG PIXEL WAY --------------------- Most AWT graphics GUI stuf need layouts to handle stuff inside them! liek if i made a dialog box and wanted 3 fields and some buttons and labels, i would have to obey the rules that the LoayoutManagers set out, BUT most of the time there anoying and way to dificult to undesratand, specialy for begiiners! i had this problem and heres a good way to solve it!
import java.awt;
class SomeClass extends Frame
{
	Something()
	{
		this.setLayout(null);
		...
	}
	...
}


It works with any AWT Window; ie. Frame, Window, Container, Applet... the list goes on.

Then adding compnonets to this is easy without having to obey layout rules! say you want to isert a button:
Button newButton = new Button("A COOL BUTTON");
newButton.setBounds(10,10,200,40); //This says that the buttun has to be
                                   //placed at coordinates 10,10 wherever
                                   //it is inserted, and has to be 200 by 40
                                   //pixels in size
newPannel.add(newButton);//thats it you have inserted the button


USING the setBounds(xpos, ypos, width, height) method you can easily arange how things look and wher ethey go with out having to us elayout managers!

Be careful though, because any new windows opened will have a size of zero by zero, unless they are told otherwise.

last edited (December 30, 2002) by Circuitboy, Number of views: 2178, Current Rev: 2 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.