Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Overlap JLabels

843807Mar 6 2010 — edited Mar 8 2010
Hi,
I have written this piece of code for my Project:
myFrame = new JFrame("MY FRAME");
myFrame.setVisible(true);
myFrame.setSize(800,600);
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myFrame.setLocationRelativeTo(null);

lp = myFrame.getLayeredPane();

Font myFont1 = new Font("Times New Roman",10,200);
Font myFont2 = new Font("Times New Roman",20,450);

myLabel1 = new JLabel("O");	
//myLabel1.setFont(myFont1);	
myLabel1.setBounds(20,20,50,50);
lp.add(myLabel1,new Integer(2));

myLabel2 = new JLabel("T");	
//myLabel2.setFont(null);	
myLabel2.setBounds(25,20,50,50);		
lp.add(myLabel2,new Integer(1));
This overlapping of the JLabels works fine Until I uncomment the setFont() for the Labels.
As soon as I uncomment, I dont see anything in my Frame.
I want to increase the text sizes in JLabels sizes as per myFont1 and myFont2 and still overlap them.
Am I missing something?
Please help.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 5 2010
Added on Mar 6 2010
12 comments
887 views