This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.
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.
There are no new questions, but there may be new answers.
Joined: Feb 13, 2010
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!