2

I would like to place one gridpanel containing a moving background and on top if it I would like to display an other grid panel as the main content. How do I do this?

enter image description here

package o1.game
import scala.swing._
import scala.swing.event._
import java.awt.Color
import java.awt.event._
import java.awt.{geom}

object Problem extends SimpleSwingApplication {


  val myGrid = new GridPanel(rows0=200,cols0=200){

    override def paintComponent(g:Graphics2D){

    }

    contents += new GridPanel(rows0=200,cols0=200){

    }
  }

  def top = new Frame{
    contents = myGrid

  }

}
Leero11
  • 365
  • 2
  • 4
  • 17
  • 1
    Hint: turn here [help] and have a good look on how/what to ask. The point is: this is not a free "we write code for you service". You show us the code you have written so far, and make it more clear where you are stuck. And please update your question instead of putting code into comments! – GhostCat Jan 10 '17 at 17:20
  • Ok, now just delete the comments that are no longer required ... i think your question is now "good enough" ... now you just have to wait for some scala expert. As my knowledge of syntax and operators (wondering what += for content does?) aint sufficient here ;-( – GhostCat Jan 10 '17 at 17:36
  • contents+=new GridPanel(rows0=x,cols0=y) adds a new element to the list named contents – Leero11 Jan 10 '17 at 17:38
  • The thing that I would check ... what exactly does a GridPanel do when you dont add content into it?! – GhostCat Jan 10 '17 at 17:49
  • If you're trying to make a game here, having panels moving around is an inappropriate use of them in nearly any context I can think of. If you want a moving background, just draw things on the panel in a way that makes it look like they're moving. Panels are containers for laying out components in a window, and nothing more. – John Jan 10 '17 at 21:03
  • The other panel would not be moving, but it would just contain a background that is moving – Leero11 Jan 11 '17 at 16:47

0 Answers0