Meaningless Drivel is fun!*
The moose likes Swing / AWT / SWT and the fly likes Adding Components to Internal Frames ???? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Adding Components to Internal Frames ????" Watch "Adding Components to Internal Frames ????" New topic
Author

Adding Components to Internal Frames ????

suhail sarwar
Greenhorn

Joined: Mar 15, 2003
Posts: 4
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

Joined: Jan 09, 2001
Posts: 1492
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

Joined: Jun 03, 2000
Posts: 5040

"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

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adding Components to Internal Frames ????
 
Similar Threads
JComponent Subclass
Add Enter Key Value in Input Box
help arranging layout of TextField
MIDP: Difference between textfield and textbox
trying to do a loop