• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

layout

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
import java.awt.*;
import java.io.*;
public class mframe extends Frame{
Button bn,bs,be,bw,bc;
public mframe(){
super("maha");
Button bn = new Button("North");
Button bs = new Button("South");
Button be = new Button("East");
Button bw = new Button("West");
Button bc = new Button("Center");
setLayout(new FlowLayout());
//add(bn); add(bs); add(be); add(bn); add(bn);}

try{
add("North",bn);

setSize(300,300);
setVisible(true);
System.out.println("Added north and sleepling");
Thread.sleep(2000);
add("East",be);
setSize(300,300);
setVisible(true);
System.out.println("Added East and sleepling"); Thread.sleep(2000);
add("South",bn);
setSize(300,300);
setVisible(true);
System.out.println("Added South and sleepling"); Thread.sleep(2000);
add("West",bw);
setSize(300,300);
setVisible(true);
System.out.println("Added West and sleepling"); Thread.sleep(2000);
add("Center",bc);
setSize(300,300);
setVisible(true);
System.out.println("Added Center and sleepling"); Thread.sleep(2000);}
//catch(InterruptedException e) {}
}
public static void main(String args[]){

new mframe();
} }
import java.awt.*;
import java.io.*;
public class mframe1 extends Frame{
Button bn,bs,be,bw,bc;
public mframe1(){
super("maha");
Button bn = new Button("North");
Button bs = new Button("South");
Button be = new Button("East");
Button bw = new Button("West");
Button bc = new Button("Center");
setLayout(new FlowLayout());
add(bn); add(bs); add(be); add(bn); add(bn);}


public static void main(String args[]){

new mframe1();
} }
/*
here nothing happens untill I store new mframe1() object is frame f object and call f.show().
frame f=new mframe1();
f.show();
please explain it to me.Is it due to layout as in border layout I don't have to add f.show.
*/
jaideep
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
for a frame setvisible is false unlike applet so we have to imlicity mention f.show().
 
This tiny ad will self destruct in five seconds.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic