• 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

Displaying string text from top to bottom

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

I would like to set my text so that it is displayed from top to bottom. Right now it is in its default (from left to right). The result should be:
R
E
L
O
A
D

instead of R E L O A D.

Currently I am using paintComponent to draw a String because this does not mess up my other elements in the JFrame.

Is there a way to align or set the direction of the text in a way that it is displayed from top to bottom.

Note: I do not want the text to be just displayed vertically (so you have to tilt your head sideways to read). It should be displayed as the "Reload" above.

Thanks upfront!


 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you been through the methods of Graphics or Graphics2D? Look for drawString. I didn't find any options for vertical text, not even clicking on the links, so maybe you will have to write a VerticalText class. Have you searched anywhere, because this problem has doubtless occurred before.
 
Bart Boersma
Ranch Hand
Posts: 79
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have searched online but all of which I found explain it making it vertical text. Besides that I have looked into different methods but none of them doing what I am asking ..

Thanks for your comment though.
 
Bart Boersma
Ranch Hand
Posts: 79
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I solved this issue.

Its kind of devious but it works. It creates an array of Chars. For each char in the array you define the position:
For i = 0 --> y = 0.
For i = 1 --> y = 10.
For i = 2 --> y = 20.
etc. etc.

 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well done Have a cow.
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could use the Text Icon.

It supports text displayed either horizontally or vertically and can be used in any Swing components that supports an Icon, like a JLabel.
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nice Thank you for making that available: have a cow too.
 
Bart Boersma
Ranch Hand
Posts: 79
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cheers!!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic