0

I'm in a group assignment at university doing a swing GUI course and need some hints.

I have to develop and implement a user interface that represents the following below, knobs tuner slider and all.

but I have no idea where to start, note this image wasn't supplied by the lecturer but by other students in the group and are quite inflexible with the way it looks.

My 2 biggest problems are, the knobs, and the tuner.

Any idea's would be much appreciated.

enter image description here

Jonas
  • 121,568
  • 97
  • 310
  • 388
Ryan Leach
  • 4,262
  • 5
  • 34
  • 71
  • Perhaps use some kind of canvas (override drawing methods on standard panels) and draw the display. Same with knobs. – emesx Oct 27 '12 at 15:27
  • 1
    Personally I would go for a digital display ;-) . Not really sure what this has to do with learning Swing. Looks more like custom painting to me as you can hardly re-use any of the existing Swing components – Robin Oct 27 '12 at 15:29
  • "Not really sure what this has to do with learning Swing." you and me both, but they designed it so I have to implement it. I know its not really a stackoverflow type question, but this place is great when you need help and have no where else to turn. – Ryan Leach Oct 27 '12 at 15:53
  • Round dials don't work well in mouse controlled GUIs, use a `JSlider` instead. – Andrew Thompson Oct 28 '12 at 04:41

1 Answers1

3

You have to write your own Knob class to work this out. You can start with a custom drawn component that's based on JButton. The tuner however must be drawn on a JPanel separately. There will be a lot of custom-code that will be implemented. Good luck :-)

You will have to look into :

  1. JPanel and its paintComponent(Graphics g) method
  2. JButton and its paintComponent(Graphics g) method
  3. Graphics2D class.

For the knob, you can start with a custom drawn, image based JButton, implement actionPerformed() method for it, and Graphics2D.rotate() it. Design it with MVC pattern, where you set the angle of rotation and rotate it with the paintComponent(). That will set the necessary calibration for the model.

For the tuner, however, you can start with a .png based background, and a rectangle that can move around using methods from Graphics2D. This will be tied to the Radio-tuner model.

Its hard to explain in words. But I think you get the point.

Good luck.

Aniket Inge
  • 25,375
  • 5
  • 50
  • 78