Ask Experts Questions for FREE Help !
Ask
    NerdyBoy9's Avatar
    NerdyBoy9 Posts: 1, Reputation: 1
    New Member
     
    #1

    Apr 22, 2012, 09:35 AM
    HELP - placing picture on top of another picture in Java - JLayerPane
    Hi..

    I am trying to place a picture on top of another one in java..

    I have a Tshirt picture which I am going to place it in the center of my GUI
    Also I have a logo I want to put it on top of that picture

    I used JLayerPane but I guess I made mistake which I couldn't notes and solve.

    This is part of my code.


    Code:
    static JComboBox colours, sizes, logos;   							// Variables for drop box 
    static JLabel picture, logo; 			
     
    private static String[] fileName = {"src/white.gif", "src/green.gif", // array of the file names will 
    					     "src/blue.gif", "src/brown.gif",  //
        					     "src/black.gif", "src/red.gif",   //
    					   "src/gray.gif"}; 	           // store the T-shirt pics.                      
     
    private static String[] logosList = {"src/likeMe.gif", "src/followMe.gif",
    	 							   "src/youtube.gif"};
     
     
    private Icon[] pics = { new ImageIcon(fileName[0]), new ImageIcon(fileName[1]),                     // array of images will store 
              new ImageIcon(fileName[2]), new ImageIcon(fileName[3]), new ImageIcon(fileName[4]),  // the the all images.
    		 			new ImageIcon(fileName[5]), new ImageIcon(fileName[5]), new ImageIcon(fileName[6])};
     
    private Icon[] logs = { new ImageIcon(logosList[0]), new ImageIcon(logosList[1]),  //To hold logos for T-shirts.
    				 new ImageIcon(logosList[2])};
     
     
    inside my constructor
     
    			pnlNorth = new JPanel ( new GridLayout ( 3, 3));
     
     pnlNorth.add(colours = new JComboBox (fileName));                      // put the colours list in the ( fileName array ) in list for us.
    			pnlNorth.add(sizes = new JComboBox ( sizeList )); // put the sizes list in the ( sizeList array ) in list for us.
    			pnlNorth.add(logos = new JComboBox ( logosList ));// put the logos list in the ( logoList array ) in list for us.
    			pnlNorth.add(lblCustomizeYourOrder);
     
    			// Then add it to the container. 
    			add(pnlNorth, BorderLayout.NORTH);
     
     
     
     
    	// JLayerPane to put 2ed layer "logo" on top of the picture.
    			jlayerPane = new JLayeredPane();
    			jlayerPane.setPreferredSize(new Dimension (300,300));
    			jlayerPane.setLayout(new FlowLayout());
     
    			picture = new JLabel (pics[0]);
    			logo = new JLabel (logs [0]);
     
    			// Manually set layout the components, and add it.
    			jlayerPane.add(picture, new Integer (50));
    			jlayerPane.add(logo, new Integer (49)); 
    			// Add the JLayerPane to the container.
    			add(jlayerPane);
     
    			// Manually set layout the components.
    			picture.setBounds(600, 100, picture.getWidth(), picture.getHeight()); 
    			logo.setBounds(600, 100, logo.getWidth(), logo.getHeight());


    Everything perfect except placing the logo on the top of the tshirt
    How can I fix my code to place the logo on the tshirt.
    The output it attached as picture..

    Thanks guys..
    Attached Images
     

Check out some similar questions!

My picture from my camera has lines through it and a red or pink tint to the picture [ 1 Answers ]

When I take a picture from my camera it shows up with lines through it and blurry and it has a red or pink tint to the picture. But when I focus on what I want to take the picture of it looks fine until I go back to look at the picture.

The picture on my Tv screen is in the top right corner, can someone help? [ 0 Answers ]

I recently moved my Sony Flatscreen TV, and now the picture is in the top right corner of the screen. Any suggestions on how to fix this?

Finishing a picture top table [ 1 Answers ]

We used to have a large picture top coffee table in the family that had family pictures covered by a thick coating of poly. I'm re-creating the same table and have questions on how to get the poly so thick. I've googled the question and have found special compounds that are more toward bar tops,...


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.