• 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

uncleared panel topic

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
date:20/11/2001
from asif ali<prexml@yahoo.com>
subject :uncleared panel topic
sir
please help me undestand awt.
i would like to put panel object in Frame object.
how can i create it in Awt?

import java.awt.*;
class DemoPanel extends Frame{
DemoPanel(){
super("This is second bid");
Panel p = new Panel();// erroe why?
add(p); //error
p.setBounds(100,100,50,50);
p.setVisible(true);
}
public static void main(String arg []){
DemoPanel dd = new DemoPanel();
}
}
asif ali
<prexml@yahoo.com>
Q2. the following statement is hazy .please explain it.
statement1.
"PANEL: Panel is genric container for holding component"
statement2.
"Panel is concrete subclass of container."
thanks for givig time.
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to add:
show();
after the p.setVisible(true); statement.
Also you should add some code to close the window when the user closes it.
This should get you started...
 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ali,
I added a setVisible(true) statement to main.
I didn't get any compiler errors at the lines you specify
I don't think that your setBounds statement will work. It will be overridden by the default layout manager for frames (BorderLayout).
Your add statement will by default place the panel in the centre region of the frame, filling all of the available area.
Your questions...
1.) From the API - "Panel is the simplest container class. A panel provides space in which an application can attach any other component, including other panels. "
2.) From the API for container - "A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT components."
So, a panel is a type of a container. It can hold other components. It's a simple subclass of container.
I hope this is of assistance
(Modified code follows)
cheerio
rowan

import java.awt.*;
class DemoPanel extends Frame{
DemoPanel(){
super("This is second bid");
Panel p = new Panel();// erroe why?
add(p); //error
p.setBounds(100,100,50,50);
//p.setVisible(true);//commented out by rowan


}
public static void main(String arg []){
DemoPanel dd = new DemoPanel();
dd.setVisible(true); //added by rowan
}
}
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic