• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Jlabel creation problem. Do guide

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


"Id" overlaps the "name"
what is the reason and y we need to add Contentpane()??

output required:
name
id

But is dispalys only id
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't you need to set the layout?
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem here is that default content pane of a JFrame uses BorderLayout.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jelle is right. That means that if you just call add without any constraints, the component will be put in the center (as if BorderLayout.CENTER was used). However, BorderLayout only supports one component at each location. You'll need to add the components with explicit constraints, like BorderLayout.NORTH for the first and BorderLayout.CENTER for the second.


veena joshi wrote:y we need to add Contentpane()??


1) Please UseRealWords: "why", not "y".
2) That was necessary in Java 1.4 and before. Since Java 5.0 you can simply add to the JFrame; it delegates the calls to add, remove, removeAll and setLayout to its content pane.
 
veena bijur
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


ITS WORKING!!! thank you all!!





its working fine. is there any better option to modularize the code??
Kindly suggest.
Thanks to all.
 
reply
    Bookmark Topic Watch Topic
  • New Topic