Results 1 to 2 of 2
  1. #1
    marodia is offline Member
    Join Date
    Aug 2009
    Posts
    9
    Rep Power
    0

    Exclamation how to add two image to two different jframes

    hi guys,
    i have been trying to add images to jpanel but one image is shadowing the other.they are not placing at different places in a jframe.
    this i have tried.....

    public Frame() {
    setSize(800,800);
    jPanel1=new javax.swing.JPanel();
    jPanel2=new javax.swing.JPanel();
    jPanel1.setBackground(Color.RED);
    jPanel2.setBackground(Color.CYAN);
    ImageIcon icon1 = new ImageIcon("C:/Documents and Settings/Desktop/WeSellMoreTicketsBannerAd.jpg");
    ImageIcon icon2= new ImageIcon("C:/Documents and Settings/Desktop/redcowel2.jpg");
    JLabel label1 = new JLabel();
    JLabel label2= new JLabel();
    label1.setIcon(icon1);
    jPanel1.add(label1,BorderLayout.PAGE_START);
    label2.setIcon(icon2);
    jPanel2.add(label2,BorderLayout.PAGE_END);

    this.getContentPane().add(jPanel1);
    setVisible(true);

    this.getContentPane().add(jPanel2);
    setVisible(true);
    }

    i am really confused with this code please if anyone can help.
    Last edited by marodia; 08-20-2009 at 10:41 AM.

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

    Default

    Currently you're adding both JPanels to the contentPane BorderLayout.CENTER (the default). Please read the Sun Swing tutorial section on the different layout managers. Therein lies your answer.

Similar Threads

  1. help with jframes
    By pao09 in forum AWT / Swing
    Replies: 0
    Last Post: 04-15-2009, 03:10 PM
  2. jframes
    By ddj in forum AWT / Swing
    Replies: 0
    Last Post: 03-24-2009, 04:15 PM
  3. problem with jframes
    By Robert in forum AWT / Swing
    Replies: 1
    Last Post: 01-16-2009, 04:05 AM
  4. two JFrames
    By kirtesh4u in forum New To Java
    Replies: 0
    Last Post: 11-17-2008, 09:26 PM
  5. problem with getting new JFrames
    By geork in forum New To Java
    Replies: 0
    Last Post: 02-09-2008, 01:46 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
  •