-
Notifications
You must be signed in to change notification settings - Fork 47
How to override paint() method from subclass of frame? #171
-
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
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.
All reactions
-
👍 1
-
Note that (not just in Scala Swing, but in Swing generally) every JFrame
has a "content pane"; doing things with a JFrame
often involves interacting with the content pane, rather than with the frame itself.
Beta Was this translation helpful? Give feedback.