Rob Camick wrote:You would never add code like that to the paintComponent() method.
But I want to open a new window as user click on the list item of Paint Area .Is is possible or not ?
Actually your approach is complicated since you want to detect the string drown on the panel by using a mouse click.
You can do that with the following approach ( not recommended; the recommended is to use a list on the panel)
for each String draw a rectangular boundary ( g.drawRect..) and over the rectangle location put you string ( g.drawString(...))
you add a mouse Listener to the panel
if mouse is being clicked, you get the X, and Y location of the mouse and determine if it is in the boundary of your String ( actually you define your boundary
for each string ), then you retrieve it from the definition store ( some kind of data structure which maps you String literal to location on the screen, this defintion store is build relatively w.r.t panel size; so any panel resizing, will re-map the String literal to new location so that you can draw them again)