File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes A couple of questions about images Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "A couple of questions about images" Watch "A couple of questions about images" New topic
Author

A couple of questions about images

Neil Cartmell
Ranch Hand

Joined: Feb 13, 2010
Posts: 150
Hello, i'm finally starting to try and make my applications look a bit better. I have a couple of questions.

I was wondering if it's considered best to work out how big you want your icons or images to be before using them in your program rather than altering their size in the program?

At the moment my program draws a chord box and all these little black circles with numbers in it for the finger positions. It has to use font metrics to center the number and antialiasing to smooth out the circle. Would it be
better to just use images instead?

Oh and when I say better/ best, I mean what's considered to be to be the best programming practice, that a professional would most likely do.


Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4529
    
    5

Neil Cartmell wrote:At the moment my program draws a chord box and all these little black circles with numbers in it for the finger positions. It has to use font metrics to center the number and antialiasing to smooth out the circle. Would it be better to just use images instead?


Just use a JLabel and set appropriate horizontal and vertical alignments and text positions. Also, it's easy to write an Icon implementation that draws filled black circle (with a line through to represent the guitar string, if you so desire). Set the foreground to whatever color you want the number to be.

A GridLayout might be the best way to lay out the chord box.


luck, db
There are no new questions, but there may be new answers.
Neil Cartmell
Ranch Hand

Joined: Feb 13, 2010
Posts: 150
Thanks.

Your answer kind of surprises me. I never really thought about using layout managers and such for this application. I thought it would be just easier to paint it all in a JPanel. I have individual view classes but they are all just painted on the JPanel. I've posted a thumbnail below. It's pretty simple looking at the moment. The guitar strings are just lines!


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A couple of questions about images