• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Layout problem

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,
I'm facing a layout problem and I have to make the applet ready and give it to my boss urgently. So help me out !!! Following is the code. I have created three panels(all with GridLayout) and my applet also have GridLayout. I have added the panels on the applet and they are ok. The problem is with two buttons. I wanna add them below the three panels, in the center. Thats the problem and I'm not able to solve it since I'm not very proficient with layout managers. Help me out!!
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Rest extends Applet {
Checkbox c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12;
Panel p1,p2,p3,p4;
Label l1,l2,l3;
Button b1,b2;
Label l4,l5,l6;
public void init()
{
setLayout(new GridLayout(1,3));
l1=new Label("PIZZAS");
l2=new Label("FAST FOOD");
l3=new Label("BURGERS");
l4=new Label("");
l5=new Label("");
l6=new Label("");
b1=new Button("SUBMIT");
b2=new Button("CANCEL");
c1=new Checkbox("1");
c2=new Checkbox("2");
c3=new Checkbox("3");
c4=new Checkbox("4");
c5=new Checkbox();
c6=new Checkbox();
c7=new Checkbox();
c8=new Checkbox();
c9=new Checkbox();
c10=new Checkbox();
c11=new Checkbox();
c12=new Checkbox();
p1=new Panel();
p2=new Panel();
p3=new Panel();
p4=new Panel();
pp=new Panel();
p1.setLayout(new GridLayout(5,0));
p1.add(l1);
p1.add(c1);
p1.add(c2);
p1.add(c3);
p1.add(c4);
p2.setLayout(new GridLayout(5,0));
p2.add(l2);
p2.add(c5);
p2.add(c6);
p2.add(c7);
p2.add(c8);
p3.setLayout(new GridLayout(5,0));
p3.add(l3);
p3.add(c9);
p3.add(c10);
p3.add(c11);
p3.add(c12);
p4.setLayout(new GridLayout(1,5));
p4.add(l4);
p4.add(l5);
p4.add(b1);
p4.add(l6);
p4.add(b2);
add(p1);
add(p2);
add(p3);
setLayout(new FlowLayout());
add(p4);
}
}
Thanks in advance
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try changing the number of columns in your panel, as so:
p4.setLayout(new GridLayout(0,9));
p4.add(new Label(""));
p4.add(l4);
p4.add(l5);
p4.add(b1);
p4.add(l6);
p4.add(b2);
p4.add(new Label(""));
p4.add(new Label(""));
p4.add(new Label(""));
 
Sam
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx Rob, The job has been done.
Thanx once again!!!
Cheers ,
 
She said she got a brazillian. I think owning people is wrong. That is how I learned ... tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic