Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding Components to Internal Frames ????

 
suhail sarwar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to add swing components such as textfields and buttons to an Internal frame but problem is that the compiler won't allow me to use the c.add(username) method to add a username textfield, I get a nullpointerexception. c is the Container.
Does anyone know how to add a simple textfield to a internalframe.
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Not exactly sure what you are doing. But it should look like this:
JComponent c = (JComponent) frame.getContentPane();
c.setLayout( new BorderLayout() );
c.add( new JTextField( 10 ), BorderLayout.NORTH );
Regards,
Manfred.
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

"sarwar"
your name doesn't agree with the javaranch guidelines.
please take a moment and re-regiester after reviewing the
guidelines at http://www.javaranch.com/name.jsp
thanks for your cooperation.
- satya
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic