Hi,
I am sending simple code.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ContainerDemo {
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("using component");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create the menu bar.
JMenuBar menuBar = new JMenuBar();
menuBar.setOpaque(true);
menuBar.setBackground(new Color(154, 165, 127));
menuBar.setPreferredSize(new Dimension(200, 20));
//Create a yellow label to put in the content pane.
JLabel yellowLabel = new JLabel();
yellowLabel.setOpaque(true);
yellowLabel.setBackground(new Color(248, 213, 131));
yellowLabel.setPreferredSize(new Dimension(200, 180));
//Set the menu bar and add the label to the content pane.
frame.setJMenuBar(greenMenuBar);
frame.getContentPane().add(yellowLabel, BorderLayout.CENTER);
frame.setSize(300,200);
frame.setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
---------------------------
if you have any problem then send me code in detail.
---------------------------------
Read for more information.
http://www.roseindia.net/java/example/java/swing/Thanks.