How to structurre the GUI for this Metronomo  
Author Message
Etantonio





PostPosted: 2006-11-13 22:46:00 Top

java-programmer, How to structurre the GUI for this Metronomo Hello,
I have necessity to realize a metronomo in java,
it is also an occasion in order to understand something of user
interfaces considering that until now I just be occupied in J2EE.
I have to use use java.swing.Timer in order to color one of N circles,
the problem is that N it is defined from the user and unlimited so I
don't know how to arrange this in a modular project.
My idea is the following:
Frame with:
BorderLayout South a JPanel with the inputs for metronomo
BorderLayout Center a JScrollPane in which to design all the circles
but I don't know if it is best to design every circle in a different
Jpanel, I do not have clear ideas, someone can give me an help on
structuring this application?
Thanks

Antonio
www.etantonio.it/en

 
Josh Falter





PostPosted: 2006-11-15 3:40:00 Top

java-programmer >> How to structurre the GUI for this Metronomo When you say metronome, I am picturing one of these
http://images.google.com/images?q=tbn:hGq_5JEg4i9LgM:http://www.createdigitalmusic.com/gallery/d/1820-4/metronome.jpg

Are you trying to use circles instead of the little hand to show where
they are at in the tempo? If that is the case, why not just go with a
standard number of circles (say 16) and use the timer to update those
based on the selected tempo, rather than trying to draw some
potentially very large number of circles.

For doing the animation on your center panel, I personally think it
would be best to have a single JPanel there and override the
paintComponent() method to do the custom drawing. You could probably
do a simple loop that would draw either an empty or a colored circle
depending on some value at each iteration.

Going with that structure, you would have a main JFrame with
BorderLayout that will house your other components, a JPanel in the
South region with something like GridLayout or Box Layout, that will
contain your metronome inputs. You'll need a data class to update with
the data from the metronome components. Finally I would imagine that
you would construct a new custom JPanel for the center each time there
is new Metronome data. The custom JPanel would contain the
paintComponent() function and a Timer based on the selected tempo.

HTH,
Josh


Etantonio wrote:
> Hello,
> I have necessity to realize a metronomo in java,
> it is also an occasion in order to understand something of user
> interfaces considering that until now I just be occupied in J2EE.
> I have to use use java.swing.Timer in order to color one of N circles,
> the problem is that N it is defined from the user and unlimited so I
> don't know how to arrange this in a modular project.
> My idea is the following:
> Frame with:
> BorderLayout South a JPanel with the inputs for metronomo
> BorderLayout Center a JScrollPane in which to design all the circles
> but I don't know if it is best to design every circle in a different
> Jpanel, I do not have clear ideas, someone can give me an help on
> structuring this application?
> Thanks
>
> Antonio
> www.etantonio.it/en