• Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable to add Labels with Image to Panel thru KeyListener.  RSS feed

 
Sadak Hussain
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could any one help me. When I add an image to Label and That label to Panel Its working fine. When I do the same in Event Listener method, Its passing thru it but images are not displaying. the code is as follows,

addLabel("a"); // working fine.......

txt.addKeyListener(new KeyListener()

{

public void keyReleased(KeyEvent ke)

{}

public void keyTyped(KeyEvent ke)

{

}

public void keyPressed(KeyEvent ke)

{
char key = ke.getKeyChar();
System.out.println("--before "+key);
addLabel(st);

System.out.println("--after "+st);
}

})

Thanks.
 
Vlado Zajac
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After you add the Label try calling validate for the panel.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!