Results 1 to 3 of 3
  1. #1
    Miwrath's Avatar
    Miwrath is offline Member
    Join Date
    Oct 2010
    Posts
    4
    Rep Power
    0

    Exclamation How to post multiple image in frame?

    can you please help me about this...i just want to post a picture inside the frame
    that looks good with a proper spacing or grid...
    thank you...

    :o

    here's the code:
    Java Code:
    import java.awt.GridLayout;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JFrame;
    import javax.swing.ImageIcon;
    
    public class irish extends JPanel {
        JLabel label1, label2, label3,label4,label5,label6,label7,label8,label9;
    
        public irish() {
        	
            ImageIcon icon = new ImageIcon("f.jpg",
                                           "");
            setLayout(new GridLayout(3,1));     //3 rows, 1 column
    
            label1 = new JLabel("f",
                                icon,
                                JLabel.CENTER);
            //Set the position of the text, relative to the icon:
            label1.setVerticalTextPosition(JLabel.BOTTOM);
            label1.setHorizontalTextPosition(JLabel.CENTER);
    
           
    
            label3 = new JLabel(icon);
    
           
            ImageIcon icons = new ImageIcon("i.jpg",
                                           "");
            setLayout(new GridLayout(3,1));     //3 rows, 1 column
    
            label2 = new JLabel("i",
                                icons,
                                JLabel.LEFT);
            //Set the position of the text, relative to the icon:
            label2.setVerticalTextPosition(JLabel.BOTTOM);
            label2.setHorizontalTextPosition(JLabel.CENTER);
    
           
    
            label3 = new JLabel(icons);
             ImageIcon iconse = new ImageIcon("5.jpg",
                                           "");
            setLayout(new GridLayout(3,1));     //3 rows, 1 column
    
            label4 = new JLabel("5",
                                iconse,
                                JLabel.CENTER);
            //Set the position of the text, relative to the icon:
            label4.setVerticalTextPosition(JLabel.BOTTOM);
            label4.setHorizontalTextPosition(JLabel.CENTER);
    
           
    
            label3 = new JLabel(iconse);
    
           ImageIcon iconsed = new ImageIcon("6.jpg",
                                           "");
            setLayout(new GridLayout(3,1));     //3 rows, 1 column
    
            label5 = new JLabel("6",
                                iconsed,
                                JLabel.CENTER);
            //Set the position of the text, relative to the icon:
            label5.setVerticalTextPosition(JLabel.BOTTOM);
            label5.setHorizontalTextPosition(JLabel.CENTER);
    
           
    
            label3 = new JLabel(iconsed);
    ImageIcon iconi = new ImageIcon("7.jpg",
                                           "");
            setLayout(new GridLayout(3,1));     //3 rows, 1 column
    
            label6 = new JLabel("7",
                                iconi,
                                JLabel.CENTER);
            //Set the position of the text, relative to the icon:
            label6.setVerticalTextPosition(JLabel.BOTTOM);
            label6.setHorizontalTextPosition(JLabel.CENTER);
    
           
    
            label3 = new JLabel(iconi);
    	ImageIcon iconic = new ImageIcon("me.jpg",
                                           "");
            setLayout(new GridLayout(3,1));     //3 rows, 1 column
    
            label7 = new JLabel("me",
                                iconic,
                                JLabel.CENTER);
            //Set the position of the text, relative to the icon:
            label7.setVerticalTextPosition(JLabel.BOTTOM);
            label7.setHorizontalTextPosition(JLabel.CENTER);
            
             ImageIcon iconico = new ImageIcon("02.jpg",
                                           "");
            setLayout(new GridLayout(3,1));     //3 rows, 1 column
    
            label8 = new JLabel("02",
                                iconico,
                                JLabel.CENTER);
            //Set the position of the text, relative to the icon:
            label8.setVerticalTextPosition(JLabel.BOTTOM);
            label8.setHorizontalTextPosition(JLabel.CENTER);
    
           
    
            label3 = new JLabel(iconico);
            
             ImageIcon iconicon = new ImageIcon("d.jpg",
                                           "");
            setLayout(new GridLayout(3,1));     //3 rows, 1 column
    
            label9 = new JLabel("d",
                                iconicon,
                                JLabel.CENTER);
            //Set the position of the text, relative to the icon:
            label9.setVerticalTextPosition(JLabel.BOTTOM);
            label9.setHorizontalTextPosition(JLabel.CENTER);
    
           
    
            label3 = new JLabel(iconicon);
    
    
    
      
            //Add labels to the JBufferedPane. 
            add(label1);
            add(label2);
            add(label3);
            add(label4);
            add(label5);
            add(label6);
            add(label7);
            add(label8);
            add(label9);
           
          
        }
    
        public static void main(String[] args) {
            /*
             * Create a window.  Use JFrame since this window will include 
             * lightweight components.
             */
            JFrame frame = new JFrame("IRISH ALBUM");
    		
            frame.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    System.exit(0);
                }
            });
    
            frame.setContentPane(new irish());
            frame.pack();
            frame.setSize(1050, 2000);
            frame.setVisible(true);
        }
    }

    im sorry for my mistake sir...
    Last edited by Miwrath; 10-15-2010 at 06:19 AM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by Miwrath View Post
    can you please help me about this...

    :o
    ????

    This "question" is so vague and general as to be completely unanswerable. Please ask specific questions regarding problems in your code. I strongly suggest you read How to Ask Smart Questions to learn how to ask an answerable question.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,252
    Rep Power
    19

    Default

    In what way is this a new question? What was the problem in continuing in your earlier thread?
    How to put multiple image in java?

    db

Similar Threads

  1. how to set an image to a frame in swing?
    By vrk in forum AWT / Swing
    Replies: 2
    Last Post: 10-20-2009, 02:52 PM
  2. Adding multiple images to frame
    By 435.mahesh in forum AWT / Swing
    Replies: 1
    Last Post: 04-24-2009, 08:31 PM
  3. how i can put image in background of frame??
    By ahmed13 in forum NetBeans
    Replies: 4
    Last Post: 01-15-2009, 05:47 PM
  4. Replies: 7
    Last Post: 07-09-2008, 12:06 AM
  5. Replies: 0
    Last Post: 01-08-2008, 05:29 PM

Posting Permissions

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