Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown


Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class StateCity extends Applet
BorderLayout bLayout = new BorderLayout();
Panel p1Panel = new Panel(new FlowLayout(FlowLayout.LEFT));
Panel p2Panel = new Panel(new FlowLayout(FlowLayout.CENTER));
Panel p3Panel = new Panel(new GridLayout(2,1));
Image img = null;
Image imgCal = this.getImage(this.getCodeBase(),"Californ.gif");
public void init()
this.add(bLayout.NORTH, p1Panel);
this.add(bLayout.CENTER, p2Panel);
public void itemStateChanged(ItemEvent e)
// i am handling event here
this.img = imgCal;
public void paint(Graphics g)
if (this.img != null)
g.drawImage(this.img, 100, 100, this.p2panel);//Err
I am trying to draw image on the p2panel(which is FlowLayout). And p2panel is part of the bLayout(which is BorderLayout).
Why I am getting compilation error saying 'undefined p2.panel' in paint() method or what cud be the solution for my drawing ?
Cud be nice task for good layout managers....Help me out please...
[This message has been edited by Umesh (edited February 13, 2000).]
Posts: 23216
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure about the error message, but I am pretty sure that that won't make the image appear on that panel. You'll need to override the paint for that panel to do what you want.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic