hi friends..i want to divide a frame into different parts...

how can i do that.....plz help me

A Frame is a component, and can accept other components.

Think of components as chunks of data that can store data of each other...

Here's the extension of JFrame

java.lang.Object
extended by java.awt.Component
extended by java.awt.Container
extended by java.awt.Window
extended by java.awt.Frame
extended by javax.swing.JFrame

JFrame IS-A component and IS-A container, and accepts containers. Containers also accept containers too!

Unfortunately you can't add another JFrame to your current JFrame contentpane since accessing windows without proper accessing rights is prohibited.

You can however create something like a Canvas, or GCanvas or even a seperate component/container to add to your JFrame. The way your component will be added to it will depend on your JFrame's LayoutManager.

There are several types of LayoutManagers, the most typical ones are--

GridLayout
FlowLayout
BorderLayout
GridBagLayout

--and the way you use them is nothing special. In your constructor for the JFrame object you're using you can simple make a statement like this--

this.setLayout(new GridLayout(2, 1)); //for a GridLayout
//or
this.setLayout(new FlowLayout()); //for the initial FlowLayout

the types of components you want to add to your JFrame can vary. If you want to divide your JFrame such that you are working with two different components you need to add onto the already-presented contentPane if there is one.

If there isn't then that's fine too. You can simply add to the opaque contentpane by sizing your component/container/canvas before calling the add() method then adding them to the pane.

This article has been dead for over six months. Start a new discussion instead.