Results 1 to 2 of 2
- 08-20-2009, 09:37 AM #1
Member
- Join Date
- Aug 2009
- Posts
- 9
- Rep Power
- 0
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 09:41 AM.
-
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
-
help with jframes
By pao09 in forum AWT / SwingReplies: 0Last Post: 04-15-2009, 02:10 PM -
jframes
By ddj in forum AWT / SwingReplies: 0Last Post: 03-24-2009, 03:15 PM -
problem with jframes
By Robert in forum AWT / SwingReplies: 1Last Post: 01-16-2009, 03:05 AM -
two JFrames
By kirtesh4u in forum New To JavaReplies: 0Last Post: 11-17-2008, 08:26 PM -
problem with getting new JFrames
By geork in forum New To JavaReplies: 0Last Post: 02-09-2008, 12:46 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks