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

grid back behaviour

 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
/*I want to know why is btn1, button not added at the specified grid position???i.e x position 8
and y position 0???
*/import java.awt.*;
public class Testgridbag3 extends Frame{
public static void main(String argv[]){
Testgridbag3 tbj = new Testgridbag3();
tbj.setSize(300,400);
tbj.setVisible(true);

}
public Testgridbag3(){
Button btn;
GridBagLayout gridbag = new GridBagLayout();
setLayout(gridbag);
GridBagConstraints constraints = new GridBagConstraints();
constraints.gridx = 0;
constraints.gridy = 0;

btn = new Button("hello ");
add(btn);
gridbag.setConstraints(btn, constraints);

//add another button
Button btn1 = new Button("howdy");
add(btn1);
constraints.gridx=8;
constraints.gridy=0;
gridbag.setConstraints(btn1,constraints);
/*//add another button
Button btn2 = new Button("zain");
add(btn2);
constraints.gridy=GridBagConstraints.RELATIVE;
constraints.gridx=2;
gridbag.setConstraints(btn2,constraints);
*/
}

}

 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry about that. Wasnt my fault. Browser is acting funny. We just had an upgrade from IE4 to IE5. Was a traumatic experience. I am enjoying watching the network engineers pull their hair out by the handfulls.
Here it is.
<pre>
public class Testgridbag3 extends Frame
{
public Testgridbag3()
{
Button btn;
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints constraints = new GridBagConstraints();
btn = new Button("hello ");
constraints.gridx = 0;
constraints.gridy = 0;
gridbag.setConstraints(btn, constraints);
add(btn);
Button btn1 = new Button("howdy");
constraints.gridx = 8;
constraints.gridy = 1;
gridbag.setConstraints(btn1, constraints);
add(btn1);
setLayout(gridbag);
}
public static void main(String argv[])
{
Testgridbag3 tbj = new Testgridbag3();
tbj.setSize(200, 200);
tbj.setVisible(true);
}

}
</pre>
You have two gridbag posts here. I hope I havent posted the wrong one here.
Sahir

[This message has been edited by Sahir Shah (edited December 10, 2000).]
 
faiza haris
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no change in the code???Maybe Sahir you forgot to mark what you wanted to show me???
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic