Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

about JComponent and his children

Status
Not open for further replies.

afe

Programmer
Mar 24, 2001
12
US
I tried to create a custom component extending JComponent. But
I found out that when I override paint(), update() and so on my
component is still invisible. What is the matter? The main question
is that even JButton doesn't paint itself properly in appletviewer!
I tried to find the answer in src.jar, but I just cannot understand
how all these JComponent's children draw themselves!!! Help, I need somebody!
 

hello

make sure you use a LayoutManager object (there are many, use setLayout(...) method),

because if you use one, your components will have a predefined size when added to a container like Panel or Applet, otherwise you should set the size and position of your components with setSize(), setLocation(), setBounds() methods...

if you create your own component don't forget to implement the following methods :
doLayout() : set location and size of your component
paint(Graphics) : draw your component
getPreferedSize(), getMinimumSize(), getMaximumSize() : used by LayoutManager objects to size your component...

with those methods you can begin to create... :)

manu0
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top