File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Adding Components to Internal Frames ????

suhail sarwar

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
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 );
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

your name doesn't agree with the javaranch guidelines.
please take a moment and re-regiester after reviewing the
guidelines at
thanks for your cooperation.
- satya

Take a Minute, Donate an Hour, Change a Life
I agree. Here's the link:
subject: Adding Components to Internal Frames ????
It's not a secret anymore!