Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JFrame

 
Sabber bhatia
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • 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
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
thanks mark
but i am not asking this for an exam
i just want to understand the statement
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • 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.
 
Today you are you, that is turer than true. There is no one alive who is youer than you! - Seuss. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!