EDIT: this is an edited version of the original post since that was probably a bit too much at once... i'll try to keep it a bit simpler now to hopefully get an answer...
dear javaranch community,
i have found this place a valueable source of information then and when and finally signed up to discuss an issue i'm not really sure about.
i have the OpenJDK Runtime Environment (build 1.6.0_0-b11) installed, my OS is Ubuntu-Linux.
the scenario is as follows:
i want to display a number of lines and some filled rectangles on a panel. all of these objects can possibly overlap and the z-order (or stacking order) is important.
i found that when i draw onto a normal JPanel, its not entirely reliable that the last painted object is also displayed on top so i found JLayeredPane might be useful for what i am trying to achieve. since i wan't full control over where my lines and rectangles appear, i use a null-layout (no layout-manager).
it took some time until i found out, that my custom JComponents won't get painted unless i call setSize() with values > 0 before.
further, when i set my custom JComponent to lets say a size of 50x50, it seems i can only use draw commands within the area of (0,0) and (50,50), everything outside this area won't get displayed.
so unless line 29 on SimpleLine is commented in, no lines are visible and since there is no output on the console, paintComponent() is probably never called.
:?: can anybody please tell me whats happening here or confirm this behaviour?
here is a code example, the controlling class:
and my JComponent:
note that both classes are in a package called 'custJComponentDrawingSimple', so to run the code, you'd need to put the two files into a folder named like the package and call 'javac custJComponentDrawingSimple/*.java' to compile and '
java custJComponentDrawingSimple.CJCD' to run the compiled code.
thanks a lot,
alex