Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

GridLayout  RSS feed

 
Mohd Zaki Mohd Salikon
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi...

Can anybody show me how to arrange all(textField,Label,button) in one main frame? I got a problem using GridLayout(_,_). The GridLayout was difficult to arraged. Thanks...
 
Steven Bell
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at JGoodies Forms. It makes doing layouts much easier.
 
Garry Meax
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi zaki

here is an example of gridlayout. hope this will help you.




import java.awt.*;

public class GridExample
{
private Frame f;
private Button b1, b2;
private TextField txt1;
private Label lbl1;

public GridExample()
{
f = new Frame("Grid Example");
b1 = new Button("Button 1");
b2 = new Button("Button 2");
txt1= new TextField(18);
lbl1=new Label("This is a label: ");
}

public void launchFrame()
{
f.setLayout(new GridLayout(2,2));

f.add(lbl1);
f.add(txt1);
f.add(b1);
f.add(b2);

f.pack();
f.setVisible(true);
}

public static void main(String args[])
{
GridExample grid = new GridExample();
grid.launchFrame();
}
}



grid layout arranges all componants in rows and columns like a spread sheet.
[ February 19, 2005: Message edited by: Garry Meax ]
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Swing...
 
Pat Hays
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Zaki,

Here is a example of gridlayout arranging all(textField,Label,button) in one main frame.UsingGridLayout.java
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!