O'Reilly logo

Getting Started With JUCE by Martin Robinson

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

Responding to user interaction and changes

Create a new Introjucer project named Chapter02_02 with a basic window; this time retain all of the auto-generated files. We will now split the code from the previous section into the MainComponent.h and MainComponent.cpp files. The MainComponent.h file should look as follows:

#ifndef __MAINCOMPONENT_H__
#define __MAINCOMPONENT_H__

#include "../JuceLibraryCode/JuceHeader.h"

class MainContentComponent : public Component
{
public:
  MainContentComponent();
  void resized();
  
private:
  TextButton button1;
  Slider slider1;
  Label label1;
};
#endif 

The MainComponent.cpp file should look as follows:

#include "MainComponent.h" MainContentComponent::MainContentComponent() : button1 ("Click") { slider1.setRange (0.0, 100.0); ...

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