Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rotating the JLabel

 
Thomas Smets
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 ]
 
Dirk Schreckmann
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic