This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Measurement ruler in Swing  RSS feed

 
Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created a small application where a webuser can draw rectangles and fill color, resize them etc.

I want to have a Ruler for the x and y axis to show where the mouse is located in mm. When a user has selected a rectangle I want to show the width and height in mm for the rectangle. How is this done? I want to show a rule every millimeter but since one millimeter is 2.54 pixels or whatever there isn't any accuracy!

I there anyone who can help me with this. Users should altso be able to show 50% and 150% but I'm tearing my hair. Can't get the ruler to work.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One way to do it is use JSliders. When you say 50% 150% I am presuming you mean magnification. In that case you would have to reset the range model for the JSlider.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!