O'Reilly logo

Head First Programming by Paul Barry, David Griffiths

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 11. Custom Widgets and Classes: With an object in mind

image with no caption

Requirements can be complex, but programs don’t have to be.

By using object orientation, you can give your programs great power without writing lots of extra code. Keep reading, and you’ll create custom widgets that do exactly what you want and give you the power to take your programming skills to the next level.

The DJ wants to play more than one track

The World Music Mixing Expo is only a few weeks away. Your DJ friend is thrilled with the work you’ve done, but now he has a few extra requirements.

Just playing one track isn’t enough. To be useful, the program needs to be able to mix several tracks together at the same time. Each track needs its own graphical interface elements (or widgets).

How will you create the widgets for each track?

To play and control a single track, you created two widgets on the GUI: a check button to start and stop the track and a scale to change the volume. Then you added event-handling code to hook those widgets up to the sound system.

image with no caption
image with no caption

To play multiple tracks together, you just need more of the same. Each track will need its own set of widgets and its own event handlers to connect the widgets and the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required