• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Rotating the JLabel

 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On another site forum, I met the question about rotating a JLabel & pretended I would answer the question. so here is what I wrote :
Giving you the answer for the JLabel may not be a good idea but ... that's what you asked for !
Firstly then, why is it a good idea :
With a normal Swing Component you would have to provide him a Renderer & that would do. I mean you just need to chuck a look at the various example on the internet where you could create you CustomCellRendere for a JTable ....
(...)
Back to our problem !
In the case of the JLabel, it has a very different story because the JLabel is really a different animal !
You will have to create you own class RotatableJLable extending the JLabel (There is really no other way, I think) ...
What do you have to implement in the Subclass to do the job is the method :
paintComponent (Graphics g)

I then proposed the following code but it doesn't work ... though I was pretty confident it should work :

Can someone help me to express / find why it doesn't work ?
Tx,
[ June 02, 2002: Message edited by: Thomas SMETS ]
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because you were posting on another site.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nathan Pruett devised an AngledButton that extends JButton a while back. I'd bet it could be adapted to work as a JLabel.
Good Luck.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!