简体   繁体   中英

Force repaint after button click

consider this piece of scala swing code

detail.reactions += {
  case ButtonClicked(but) =>
    detail.contents += new Label(but.text)
    detail.background = new java.awt.Color(0,255,0)
}

the detail is of FlowPanel type. When the button is clicked, the color is instantly repainted, but the Label is not. It gets visible as I click the area. How can I force the detail to repaint its contents after a click?

In Java, the answer would normally be to call repaint() . Did you try detail.repaint() ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM