You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importswing.{Component, LayoutContainer, Panel}
importjava.awt.CardLayoutclassCardPanelextendsPanelwithLayoutContainer {
typeConstraints=StringdeflayoutManager= peer.getLayout.asInstanceOf[CardLayout]
overridelazyvalpeer=new javax.swing.JPanel(newCardLayout) withSuperMixinprivatevarcards:Map[String, Component] =Map.empty
protecteddefareValid(c: Constraints) = (true, "")
protecteddefadd(comp: Component, l: Constraints) = {
// we need to remove previous components with the same constraints as the new one,// otherwise the layout manager loses track of the old one
cards.get(l).foreach { old => cards -= l; peer.remove(old.peer) }
cards += (l -> comp)
peer.add(comp.peer, l)
}
defshow(l : Constraints) = layoutManager.show(peer, l)
protecteddefconstraintsFor(comp: Component) = cards.iterator.find { case (_, c) => c eq comp}.map(_._1).orNull
}
The text was updated successfully, but these errors were encountered:
Here is a simple implementation:
The text was updated successfully, but these errors were encountered: