I want to draw something over the JPanel. Suppose the jpanel have the size 500,500 width and height respectively and added to a jscrollpane.
now if I add 40 buttons to the jpanel, then the scrollbar appears.
But now my problem is, if I draw something over the jpanel, that would be capture more space or size than jpanel(suppose 700,700), then scrollbar not appearing, and the drawing shows only the portion, that cover within jpanel's size, and rest part of the drawing hides.
So what should I do?
Scrollbars are based on the preferred size of the panel added to the scrollpane.
If you are doing custom painting of the panel, then you need to override the getPreferredSize() method of the panel to return the preferred size of the custom painting.
Thank for your information.
but how can I override the getPreferredSize() method?
can u give me sample code plz?