Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JLabel does not display  RSS feed

 
S Connor
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • 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

 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the code working now... I could swear I haven't changed anything.
 
S Connor
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • 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
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!