• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Panel vs Frame

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wrote the following code for practice. The problem is when I substitute "Frame" for "Panel" nothing is displayed. I know that Panel doesn't extend Window so I also comment out the WindowListener, but I can't figure out why I can't create this as a Panel. As always, any guidance would be greatly appreciated.
import java.awt.*;
import java.awt.event.*;
public class license extends Frame{
public static void main(String [] args)
{
Frame p=new Frame();
p.setSize(500,200);
p.setLayout(new BorderLayout());
WindowListener wl=new WindowAdapter(){
public void WindowClosing(WindowEvent e){System.exit(0);}
};
p.addWindowListener(wl);
Button OK=new Button("OK");
TextArea t=new TextArea("By clicking OK, blah, blah, blah, blah, blah,\nblah, blah, blah, blah, blah, blah, blah,\nblah, blah, blah, blah, blah, blah, blah, blah,\nblah, blah, blah, blah, blah\n, blah, blah, blah, blah, blah, blah, blah, blah,\nblah, blah, blah, blah, blah, blah,",5,250);
p.add(BorderLayout.CENTER,t);
p.add(BorderLayout.SOUTH,OK);
p.validate();
p.setVisible(true);
}
}
 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I know, using only AWT, if you want a window to appear you have to use a Frame. Because of this, you didn�t see nothing when you switched Frame by Panel, because you have to attach the panel to something.
hope it helps,
Francisco
 
Santosh Bapat
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, The book I have implies that they are interchangeable. Thanks for the help.
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Panels and Frames are not interchangeable.
 
what if we put solar panels on top of the semi truck trailer? That could power this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic