Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    Apr 2011
    Thanked 0 Times in 0 Posts

    Simple Game: JLabels vs JPanels

    Hello all,
    I'm attempting to make a simple RPG game, but I don't want to get too far if I have the wrong idea for graphics. So far, I've been using JLabels as objects in the game. For example, to make a rock, I'll overlap a couple of different size JLabels to make more than just a rectangle. I can't just use an image of a rock because the collision checking would be limited to the bounds of the images rectangle, not necessarily the image content itself. But my worry with this is that eventually, having all these JLabels will take up too much memory. For rocks, it isnt that many jlabels; but for an apple I'll use nearly 50 jlabels in order to make an octagon. (I'll try to include a pic). Im using the JLabels really just as rectangles with a width of 1 and a height varying in order to make a certain picture. I feel as if this is very inefficient, and I want to sort this issue out now. Also, would using a JPanel be any different? The only thing I couldnt do is insert a picture, but for simple shapes would using a JPanel yield any benefits? This was definitely a long post and I'm sorry if its really annoying, but any input would be appreciated, whether it be about the way I'm making my graphics now or about a better way to do it.
    Attached Thumbnails Attached Thumbnails Simple Game: JLabels vs JPanels-forumpic.jpg  


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts