• 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 does not display

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm having problems getting my program to display a JLabel.

The program draws shapes of random size and color across a panel. I have this part working. (There is more code for the drawing of shapes, I left it out for easier reading)

When I try to add a JLabel in the main method, it does not display, I can't figure out why. Please help

 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried to compile that, but it failed because of a long list of classes that we don't see the code for. Perhaps you could generate an SSCCE (<== follow that link) which doesn't have that problem?
 
S Connor
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the code working now... I could swear I haven't changed anything.
 
S Connor
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I have stumbled into another problem - I have googled tutorials and not come across a solution.
My JLabel is displayed now, but I can't get it to display formatted text.
I have tried to format a string that accesses a 'get' function to find out how many randomly generated shapes are made by a DrawPanel Class.
This string is then entered into the JLabel. The number of shapes should be displayed at the bottom of the frame.

The code below should be compilable if the classes are opened separately:

 
S Connor
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I have solved this problem. I had set up the strings incorrectly. Apologies for any inconvenience. Please let me know if the code compiled ok.
 
reply
    Bookmark Topic Watch Topic
  • New Topic