Reputation: 540
I've seen in many threads it's not recommended to mix awt and swing components. However I've seen examples in which they add the Canvas to a JFrame (No other swing components are involved). Canvas is an awt component and JFrame is a swing component, so is it ok to do so? and if not, how exactly to use the Canvas?
Upvotes: 4
Views: 965
Reputation: 18435
You could get some unusual display problems with older JDKs, but mixing swing and AWT is fine nowadays. See this article: http://www.oracle.com/technetwork/articles/java/mixing-components-433992.html
I've written a game which used swing components for most of the UI/controls but a canvas for drawing the main game area (see https://github.com/qwerky/Towers/blob/master/src/main/java/lineup/ui/UI.java). It worked fine with no problems.
Upvotes: 2