• 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

JFrame

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
explain me the meaning of this line
Jframe frame=new JFrame();//understood
frame.getContentPane().add(button);//means getContentpane method is in JFrame class but where add(button)

thanks
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JFrame's getContentPane() method returns a reference to a java.awt.Container. The add(Component) method is defined there.

I don't think you will see any Swing/AWT questions on the exam.
 
Sabber bhatia
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks mark
but i am not asking this for an exam
i just want to understand the statement
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The best way to get this understanding on your own (because you surely will have more questions as you study more), is to refer to the API. If you look up JFrame.getContentPane on the API, you'll see that it returns a Container. If you hypertext link over to Container, you'll see that it has an add method. Using the API is like exercising a muscle. The more you do it, the better you get at it. Good luck.
reply
    Bookmark Topic Watch Topic
  • New Topic