Results 1 to 4 of 4
- 05-31-2012, 05:21 PM #1
Senior Member
- Join Date
- Apr 2012
- Posts
- 199
- Rep Power
- 0
How to change image layer property
Hello,
I created a puzzle in gimp with each of the pieces contained on a different layer. I exported the pieces to individual files and wrote a java program to assemble and move those pieces. When I move the puzzle pieces, I notice that some of the pieces move on top of other pieces while other pieces move behind. I think the reason for this is because I created the pieces on different layers.
How can I make it so that all pieces move on top of each other.
Thanks,
StephenLast edited by shall; 05-31-2012 at 05:26 PM.
- 05-31-2012, 06:13 PM #2
Re: How to change image layer property
Haven't a clue. You haven't so much as indicated which GUI toolkit is involved.
To get better help sooner, post a SSCCE (Short, Self Contained, Correct (Compilable), Example) that demonstrates the problem.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 05-31-2012, 06:51 PM #3
Re: How to change image layer property
Are you saying that when a piece is moved its layer should be changed to be on top of all the others?
If you don't understand my response, don't ignore it, ask a question.
- 05-31-2012, 06:56 PM #4
Senior Member
- Join Date
- Apr 2012
- Posts
- 199
- Rep Power
- 0
Re: How to change image layer property
Yes,
See the code below for a SSCCE.
puzzlePieceImage2 overlaps puzzlePieceImage1. How can I make it so puzzlePieceImage1 overlaps puzzlePieceImage2.
I wasn't able to attached a zip file which contains the code and images. I clicked on manage attachments and a blank window appeared. Is there something wrong with the forum's attachment functionality?
Java Code:package imagelayerex; import java.awt.Dimension; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.logging.Level; import java.util.logging.Logger; import javax.imageio.ImageIO; import javax.swing.JFrame; import javax.swing.JPanel; public class ImageLayerEx { private void createGUI() throws URISyntaxException, IOException { JFrame puzzleFrame = new JFrame(); puzzleFrame.setPreferredSize(new Dimension(800, 800)); PuzzlePanel puzzlePanel = new PuzzlePanel(); puzzlePanel.setPreferredSize(new Dimension(800, 800)); puzzleFrame.add(puzzlePanel); puzzleFrame.pack(); puzzleFrame.setVisible(true); } /** * @param args the command line arguments */ public static void main(String[] args) throws URISyntaxException, IOException { final ImageLayerEx imgLayerEx = new ImageLayerEx(); javax.swing.SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { imgLayerEx.createGUI(); } catch (URISyntaxException ex) { Logger.getLogger(ImageLayerEx.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ImageLayerEx.class.getName()).log(Level.SEVERE, null, ex); } } }); } } class PuzzlePanel extends JPanel { private BufferedImage puzzlePieceImage1; private BufferedImage puzzlePieceImage2; public PuzzlePanel() throws URISyntaxException, IOException { loadPuzzlePieces(); } private void loadPuzzlePieces() throws URISyntaxException, IOException { URL imageURL = this.getClass().getResource("PuzzlePieces"); URI imageURI = imageURL.toURI(); File puzzelPiecesImageDirectory = new File(imageURI); File[] listOfFiles = puzzelPiecesImageDirectory.listFiles(); puzzlePieceImage1 = ImageIO.read(listOfFiles[0]); puzzlePieceImage2 = ImageIO.read(listOfFiles[1]); } @Override public void paintComponent(Graphics g) { g.drawImage(puzzlePieceImage1, 400, 400, this); g.drawImage(puzzlePieceImage2, 450, 450, this); } }
Similar Threads
-
Layer customizing
By atrodeyo in forum New To JavaReplies: 4Last Post: 04-24-2012, 05:02 AM -
Geomajas WMS layer 1.9.0
By java software in forum Java SoftwareReplies: 0Last Post: 02-05-2012, 06:21 PM -
SWT Commbobox in which I can change Font property for some items
By rajsanu in forum SWT / JFaceReplies: 0Last Post: 09-23-2010, 06:47 PM -
Transparent layer
By disabled in forum SWT / JFaceReplies: 0Last Post: 03-20-2010, 04:04 PM -
Be Elite Join Property Elite , Property Realtor Needed , Career With Us -
By mindyyong in forum Jobs OfferedReplies: 0Last Post: 06-25-2009, 05:28 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks