and then i use this panel to my JFrame
i wanted to add a JLabel and JButton to this panel. i have added both of them. there is no error in the code but when i run the program it doesn't show the Jbutton and JLabel

You are adding all sorts of things to the frame's content pane in this order:

panel (with the image)
username
ok
panel (again)

Notice that t has a BorderLayout (that's the default for a frame's content pane) and the effect of add() is to place the component being added into the middle of the pane replacing whatever was there. So adding four things the way you do will mean that only the last remains added.

---------

Adding panel twice betrays a little desparation. You might find it useful to have a read of the Swing section of Oracle's tutorial or some other textbook to see how layouts work and what options are available.

You can nest JPanels, each one of them having its own layout. So create JPanel, add your username and ok button on it, and then add the JPanel to another JPanel (or the contentPane) that uses BorderLayout in the BorderLayout.NORTH position. But most important -- please read the Oracle Swing tutorial on use of layout managers.

Other points:
-- Why do you construct an ImageIcon only to retrieve its image? Load the image using ImageIO#read(...) instead.
-- As Fubarable said, learn to use layout managers. Don't set a null layout to ImagePanel.

There is no need to create a custom class for this. The only time you need to do custom painting is when you want to scale the image or manipulate it in some other way.

To display an image at its actual size just use a JLabel and add an Icon to it. YOu can then set the layout manager of the label and add other components to it the same way you add components to a panel.

thank you guys for your posts. but stile i didnt sort out my problem
i dont want to use the layouts. i wanted to set the layout to null and i want to place the component (JButtons, JLabels) where i wants

thank you guys for your posts. but stile i didnt sort out my problem
i dont want to use the layouts. i wanted to set the layout to null and i want to place the component (JButtons, JLabels) where i wants

Well good luck with that then. But I do have to wonder why you are asking for our help if you choose to ignore it. You want to add components to the top of a container, and the best way, the easiest way to do this is by using appropriate layout managers.

Well good luck with that then. But I do have to wonder why you are asking for our help if you choose to ignore it. You want to add components to the top of a container, and the best way, the easiest way to do this is by using appropriate layout managers.

i am sorry. i am not intend to ignore any one of your help. well i red layout manager from swing website . i tried spring layout. it did work well. thank you so much guys.