How to override paint() method from subclass of frame? #171
Unanswered
jingkaimori
asked this question in
Q&A
Replies: 2 comments
-
Is it important that it is the frame itself? I think this is a rather low level scenario that was probably not covered for Scala-Swing. You could always install a single component that does the drawing: import scala.swing._
import java.awt.Color
new Frame {
contents = new Component {
preferredSize = new Dimension(400, 400)
override def paintComponent(g: Graphics2D): Unit = {
g.setColor(Color.red)
g.drawLine(0, 0, peer.getWidth, peer.getHeight)
}
}
pack().centerOnScreen()
open()
} would this be suitable in your case? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Note that (not just in Scala Swing, but in Swing generally) every |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
docs/SIP-8.md describes how to override paint method in subclass of Component, but this method cannot apply to subclass of Frame.
Beta Was this translation helpful? Give feedback.
All reactions