File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

uncleared panel topic

 
khan ali
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Colin Kenworthy
Ranch Hand
Posts: 88
  • 0
  • Mark post as helpful
  • send pies
  • 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...
 
Rowan Brownlee
Ranch Hand
Posts: 97
  • 0
  • Mark post as helpful
  • send pies
  • 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
}
}
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic