[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!
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:
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.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
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.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
