• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

extends Frame help

 
kieran pattni
Ranch Hand
Posts: 47
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.awt.*;
import java.awt.event.*;
public class CheckgroupApp extends Frame
implements ItemListener

private CheckboxGroup nn = new CheckboxGroup();
public showGui()
{
setLayout(new GridLaout(4,1);
add()//
seVisible();//without using instance of Frame class..i dont understand..


///some code

my question is why i have to use an instane of Frame class to add components directly..
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> my question is why i have to use an instane of Frame class to add components directly..

you need on instance of a Frame/JFrame to work with - it is a top level container

either

 
kieran pattni
Ranch Hand
Posts: 47
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry my error..Q? was why i dont have to use a instance of the Frame class..
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> sorry my error..Q? was why i dont have to use a instance of the Frame class..

by extending Frame, the class is a Frame, and inherits all the methods of Frame
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic