• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Q#12, Marcus Green MockEXam

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Q#12, Marcus Green MockEXam
can a button be added to Frame instead of panel?
thanks
tg
following code compile and run fine:
import java.awt.*;
public class FlowAp extends Frame{
public static void main(String argv[]){
FlowAp fa=new FlowAp();
fa.setSize(400,300);
fa.setVisible(true);
}
FlowAp(){
add(new Button("One"));
add(new Button("Two"));
add(new Button("Three"));
add(new Button("Four"));
}//End of constructor
}//End of Application

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tom,
Button can very well be added to the Frame. In this case no Layout is set, so the Layout is considered to be Border Layout as it is the default layout. When u run this program u can see only the Button named "Four".
Hope this helps.
Aruna
 
Aru
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tom,
Button can very well be added to the Frame. In this case no Layout is set, so the Layout is considered to be Border Layout as it is the default layout. When u run this program u can see only the Button named "Four".
Hope this helps.
Aruna
 
Aru
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tom,
Button can very well be added to the Frame. In this case no Layout is set, so the Layout is considered to be Border Layout as it is the default layout. When u run this program u can see only the Button named "Four".
Hope this helps.
Aruna
 
Aru
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tom,
Button can very well be added to the Frame. In this case no Layout is set, so the Layout is considered to be Border Layout as it is the default layout. When u run this program u can see only the Button named "Four".
Hope this helps.
Aruna
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Both frame and panel are subclasses of type 'Container' which has the method 'add' for adding components.
So you can add components like buttons to any container type object.
 
tom gong
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if a button be added to Frame instead of panel, why we always use following statement?
getContentpanel().add(buttonA);
thank fro reply,
tg
 
Tongue wrestling. It's not what you think. And here, take this tiny ad. You'll need it.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic