Forums.Sureshkumar.net : A Perfect Place to Share Knowledge         Blogs     Games    Magazines    

"Sharing knowledge does not lessen your store, often it gets you more. Sharing plays a key role in relationships and bonding, happens in small steps and is assisted through community membership."

Go Back   SURESHKUMAR.NET FORUMS > TECHNICAL DISCUSSIONS > JAVA Technologies
Register FAQ Members List Calendar Games Blogs Search Today's Posts Mark Forums Read

   

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
Old 27-07-07, 03:14 PM   #1 (permalink)
Member
 
ananthkolli's Avatar
 
Join Date: Apr 2007
Location: Right now in Chennai
Posts: 30
Thanks: 5
Thanked 5 Times in 3 Posts
Thanks: 5
Thanked 5 Times in 3 Posts
Rep Power: 2 ananthkolli is on a distinguished road
How can I possibly right align a text using drawString method

Hello,

How can I possibly right align a text using drawString method with the given length of a text to display?

Thanks in advance.
ananthkolli is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 27-07-07, 03:36 PM   #2 (permalink)
Member
 
live_wire's Avatar
 
Join Date: Feb 2007
Location: 255.255.255.255
Posts: 86
Thanks: 0
Thanked 6 Times in 6 Posts
Thanks: 0
Thanked 6 Times in 6 Posts
Rep Power: 3 live_wire will become famous soon enough live_wire will become famous soon enough
Re: How can I possibly right align a text using drawString method

To use alignments etc. you would have to use the LayoutManagers.

But you are using drawString() method which paints on the cordinates that are specified. All you are doing is painting to a screen, there is no alignment for painting...
live_wire is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following User Says Thank You to live_wire For This Useful Post:
ananthkolli (31-07-07)
Old 27-07-07, 03:43 PM   #3 (permalink)
Super Moderator
 
sk_kireeti's Avatar
 
Join Date: Feb 2006
Location: Hyderabad
Posts: 2,355
Thanks: 117
Thanked 241 Times in 198 Posts
Thanks: 117
Thanked 241 Times in 198 Posts
Blog Entries: 4
Rep Power: 51 sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute
Re: How can I possibly right align a text using drawString method

I agree with live_wire. But we can come up with a work around for this problem.

First calculate the length of the string and how many pixels each character will take. Based on this, arrange your string position. i.e., if L is the total available length, and X is number of pixels for each character and if you have N characters to be placed or painted, formula to find the starting point looks like this.

Startpoint = L - (N*X)

Hope it helps you to some extent. If you find any other solution, please let us know.

Here, I am not handling the case where starting point goes negative. But solving it is not an issue.

Thanks,
Krishna
__________________
Give 1 cup rice to a hungry Indian just by a mouse click. No money, no form filling, no hassle... Click here for the donation.
sk_kireeti is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following User Says Thank You to sk_kireeti For This Useful Post:
ananthkolli (31-07-07)
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
ejb bujjimadhu JAVA Technologies 4 10-09-06 10:15 PM
java JSP naga JAVA Technologies 4 21-08-06 05:03 PM
CA vista Other Queries 2 14-04-06 02:49 AM
JAVA collection naga JAVA Technologies 0 21-02-06 06:01 AM
JAVA PART3 naga JAVA Technologies 0 18-02-06 07:48 AM


All times are GMT +6.5. The time now is 02:54 AM.





Search Engine Optimization by vBSEO 3.1.0