Search code examples
scalascala-swing

Scala Swing: Changing BorderPanel central component new Component not visible


I'm changing the centre area on a Scala Swing Border Panel. The old component disappears, but the new component does not appear, until I resize the window manually with the mouse. I've tried using different components and repainting, but nothing makes the new component appear except manually resizing the window with the mouse.

def splitDisp(mapCanv: VistaIn): Unit =
{
  val canv2 = newMapCanv         
  panel.layout(canv2) = BorderPanel.Position.Center
  canv2.repaint         
  thisScn.repaint //ref to the Frame instance
  panel.repaint 
  thisScn.repaint
  canv2.repaint
}

I'm using 2.10.0M5 in Windows 7.


Solution

  • Try calling revalidate() and then repaint().