• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

GridLayout

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take a look at JGoodies Forms. It makes doing layouts much easier.
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to Swing...
 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Zaki,

Here is a example of gridlayout arranging all(textField,Label,button) in one main frame.UsingGridLayout.java
 
Sometimes you feel like a nut. Sometimes you feel like a tiny ad.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic