• Post Reply Bookmark Topic Watch Topic
  • New Topic

panel

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<PRE>
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.setLayout(bLayout);
this.add(bLayout.NORTH, p1Panel);
this.add(bLayout.CENTER, p2Panel);
}
public void itemStateChanged(ItemEvent e)
{
// i am handling event here
this.img = imgCal;
this.repaint();
}
public void paint(Graphics g)
{
if (this.img != null)
{
g.drawImage(this.img, 100, 100, this.p2panel);//Err
}
}
}
</PRE>
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).]
 
paul wheaton
Trailboss
Posts: 22063
Firefox Browser IntelliJ IDE 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!