# G4P library - Is there a way to make big letters on numbers?

**URL:** <https://discourse.processing.org/t/g4p-library-is-there-a-way-to-make-big-letters-on-numbers/4350>\
**Category:** Libraries\
**Created:** [October 11, 2018, 2:02am UTC](https://discourse.processing.org/t/g4p-library-is-there-a-way-to-make-big-letters-on-numbers/4350 "2018-10-11T02:02:22Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![laptophead](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/laptophead/32/2701_2.png) [@laptophead](https://discourse.processing.org/u/laptophead)\
**Post date:** [October 11, 2018, 2:02am UTC](https://discourse.processing.org/t/g4p-library-is-there-a-way-to-make-big-letters-on-numbers/4350/1 "2018-10-11T02:02:22Z")

</div>

I am building a touch tablet interface for a robotic arm. It seems that the G4P library is the only one to respond to touch as a mouse click. That is nice, thank you author.

However the buttons have very small writing , even when bold.  
Is there a way to make bigger fonts? I would rather not load pics for each button.  
Tried that and it was a pain, no documentations or examples of how to do it?

Thanks

![15%20PM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/e/e549f08970f0d14e27c559b86a23970c01b85a11.png)

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [October 11, 2018, 10:27am UTC](https://discourse.processing.org/t/g4p-library-is-there-a-way-to-make-big-letters-on-numbers/4350/2 "2018-10-11T10:27:17Z")

</div>

Glad you like G4P 😀

The sketch below shows how you can change the font, font style and size for a GButton. Just be careful that you make the button big enough in the constructor to display the text.

```auto
import g4p_controls.*;
import java.awt.Font;

GButton btn;

void setup() {
  size(300, 200);
  btn = new GButton(this, 80, 40, 120, 40);
  btn.setText("STOP");
  btn.setFont(new Font("Arial", Font.BOLD, 30));
}

void draw() {
  background(200, 200, 255);
}

```

---

<div class="post-metadata">

**Author:** ![laptophead](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/laptophead/32/2701_2.png) [@laptophead](https://discourse.processing.org/u/laptophead)\
**Post date:** [October 11, 2018, 4:22pm UTC](https://discourse.processing.org/t/g4p-library-is-there-a-way-to-make-big-letters-on-numbers/4350/3 "2018-10-11T16:22:34Z")

</div>

> [@quark](#):
>
> btn.setFont(new Font(“Arial”, Font.BOLD, 30));

Peter  
Thanks for the reply, here is what I did in the public void createGUI() function

HOME = new GButton(this, 1520, 816, 250, 100);  
HOME.setFont(new Font(“Arial”, Font.BOLD, 70));  
HOME.setText(“HOME”);  
HOME.setTextBold();

I ran it and the fonts are big and nice.  
However the moment I move or resize the HOME button, all the text formating gets erased.  
I am planning to have about 15 buttons that I will arrange for a while on the screen.  
It will be very difficult to re-enter the text line every time.

Any ideas?

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [October 11, 2018, 5:06pm UTC](https://discourse.processing.org/t/g4p-library-is-there-a-way-to-make-big-letters-on-numbers/4350/4 "2018-10-11T17:06:55Z")

</div>

What methods are you using to move resize the button?

---

<div class="post-metadata">

**Author:** ![laptophead](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/laptophead/32/2701_2.png) [@laptophead](https://discourse.processing.org/u/laptophead)\
**Post date:** [October 11, 2018, 5:08pm UTC](https://discourse.processing.org/t/g4p-library-is-there-a-way-to-make-big-letters-on-numbers/4350/5 "2018-10-11T17:08:22Z")

</div>

> [@quark](#):
>
> ove resize

I open the GP4 Gui builder from tools.  
Then I drag and drop the buttons. Etc  
Should I try something else?

---

<div class="post-metadata">

**Author:** ![laptophead](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/laptophead/32/2701_2.png) [@laptophead](https://discourse.processing.org/u/laptophead)\
**Post date:** [October 11, 2018, 9:43pm UTC](https://discourse.processing.org/t/g4p-library-is-there-a-way-to-make-big-letters-on-numbers/4350/6 "2018-10-11T21:43:57Z")

</div>

Also is there a way to have a delay in the action of the button?  
I tried  
public void button2\_click2(GButton source, GEvent event) { //_CODE_:Send:350849:  
streamer.send(BeforeSending.toString()); ///Sent step button  
BeforeSending = “”;  
fill(o);  
textFont(font, 130);

text( “SENT”, 1250, 150);  
delay (1000);

} //_CODE_:Send:350849:

Hoping to have the word SENT linger about a sec on the screen as a confirmation…  
It flashes for a mS only

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [October 12, 2018, 1:24pm UTC](https://discourse.processing.org/t/g4p-library-is-there-a-way-to-make-big-letters-on-numbers/4350/7 "2018-10-12T13:24:10Z")

</div>

> [@laptophead](#):
>
> I open the GP4 Gui builder from tools.  
> Then I drag and drop the buttons. Etc  
> Should I try something else?

I didn’t realize you were using GUI Builder. Note that the comments in the **gui** tab, you **_must not_** alter the contents of the `createGUI()` method any additional code needed to modify the controls should be in the `custonGUI()` method. The following sketch was created with GUI Builder and shows how to do it.

**Main Tab**

```auto
// Need G4P library
import g4p_controls.*;
import java.awt.Font;

public void setup() {
  size(300, 200, JAVA2D);
  createGUI();
  customGUI();
  // Place your setup code here
}

public void draw() {
  background(230);
}

// Use this method to add additional statements
// to customise the GUI controls
public void customGUI() {
  btn.setFont(new Font("Arial", Font.BOLD | Font.ITALIC, 40));
}

```

**gui Tab**

```auto
/* =========================================================
 * ==== WARNING ===
 * =========================================================
 * The code in this tab has been generated from the GUI form
 * designer and care should be taken when editing this file.
 * Only add/edit code inside the event handlers i.e. only
 * use lines between the matching comment tags. e.g.

 void myBtnEvents(GButton button) { //_CODE_:button1:12356:
     // It is safe to enter your event code here  
 } //_CODE_:button1:12356:
 
 * Do not rename this tab!
 * =========================================================
 */

public void btn_click(GButton source, GEvent event) { //_CODE_:btn:877482:
  println("btn - GButton >> GEvent." + event + " @ " + millis());
} //_CODE_:btn:877482:

// Create all the GUI controls. 
// autogenerated do not edit
public void createGUI(){
  G4P.messagesEnabled(false);
  G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME);
  G4P.setCursor(ARROW);
  surface.setTitle("Sketch Window");
  btn = new GButton(this, 10, 10, 250, 60);
  btn.setText("Click Me!");
  btn.addEventHandler(this, "btn_click");
}

// Variable declarations 
// autogenerated do not edit
GButton btn; 

```

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [October 12, 2018, 1:50pm UTC](https://discourse.processing.org/t/g4p-library-is-there-a-way-to-make-big-letters-on-numbers/4350/8 "2018-10-12T13:50:54Z")

</div>

> [@laptophead](#):
>
> Also is there a way to have a delay in the action of the button?

OK you are not trying to _delay the action of the button_ you are trying to get the _text to stay on the screen for a short time_. These are 2 very different things!

Having said that G4P can help because it has a means for grouping controls and then fading them in an out. This sketch is a modified version of the one above when the button is clicked a message will appear for 2 seconds and fade out over the next half second. It uses the GGroup class which can hold 1 or more controls that can be faded in and out as a group.

**Main Tab**

```auto
// Need G4P library
import g4p_controls.*;
import java.awt.Font;

GGroup grp;

public void setup() {
  size(300, 200, JAVA2D);
  createGUI();
  customGUI();
  // Place your setup code here
}

public void draw() {
  background(230);
}

// Use this method to add additional statements
// to customise the GUI controls
public void customGUI() {
  // Set button font
  btn.setFont(new Font("Arial", Font.BOLD | Font.ITALIC, 40));
  // Create group
  grp = new GGroup(this);
  // Set label font
  lbl.setFont(new Font("Times New Roman", Font.PLAIN, 30));
  // Add label to group
  grp.addControl(lbl);
  // Hide the group - fade to invisible (alpha = 0)
  grp.fadeOut(0, 0);
}

```

**guiTab**

```auto
/* =========================================================
 * ==== WARNING ===
 * =========================================================
 * The code in this tab has been generated from the GUI form
 * designer and care should be taken when editing this file.
 * Only add/edit code inside the event handlers i.e. only
 * use lines between the matching comment tags. e.g.
 
 void myBtnEvents(GButton button) { //_CODE_:button1:12356:
 // It is safe to enter your event code here  
 } //_CODE_:button1:12356:
 
 * Do not rename this tab!
 * =========================================================
 */

public void btn_click(GButton source, GEvent event) { //_CODE_:btn:877482:
  println("Show message");
  grp.fadeIn(0, 10); // Fade in fast
  grp.fadeOut(2000, 500); // After 2 seconds fade out over a 0.5second period
} //_CODE_:btn:877482:

// Create all the GUI controls. 
// autogenerated do not edit
public void createGUI() {
  G4P.messagesEnabled(false);
  G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME);
  G4P.setCursor(ARROW);
  surface.setTitle("Sketch Window");
  btn = new GButton(this, 10, 10, 250, 60);
  btn.setText("Click Me!");
  btn.addEventHandler(this, "btn_click");
  lbl = new GLabel(this, 10, 90, 250, 60);
  lbl.setTextAlign(GAlign.CENTER, GAlign.MIDDLE);
  lbl.setText("STARTING");
  lbl.setOpaque(false);
}

// Variable declarations 
// autogenerated do not edit
GButton btn; 
GLabel lbl; 

```

---

<div class="post-metadata">

**Author:** ![laptophead](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/laptophead/32/2701_2.png) [@laptophead](https://discourse.processing.org/u/laptophead)\
**Post date:** [October 12, 2018, 9:59pm UTC](https://discourse.processing.org/t/g4p-library-is-there-a-way-to-make-big-letters-on-numbers/4350/9 "2018-10-12T21:59:27Z")

</div>

I am happy to just use

```auto
public void customGUI() {
  btn.setFont(new Font("Arial", Font.BOLD | Font.ITALIC, 40));
}

```

I made many entries, one for each button, and they work fine. I rather keep it simple.  
However: I wish I could change the font.  
I tried even no font  
HOME.setFont(new Font(“AgencyFB-Bold-200”, Font.BOLD, 70));  
Send.setFont(new Font("", Font.BOLD, 70));

But your standard font still shows. Size is right.

Thanks

Did not work on the delay yet… Thanks for that advice

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [October 14, 2018, 3:21pm UTC](https://discourse.processing.org/t/g4p-library-is-there-a-way-to-make-big-letters-on-numbers/4350/10 "2018-10-14T15:21:53Z")

</div>

```auto
new Font("Arial", Font.BOLD | Font.ITALIC, 40)

```

The first parameter is the font name. This only works correctly if the font is installed on your computer. If the sketch can’t find the font it will use the system default and then apply the style (second parameter) and font size (third parameter).

This is why I selected Arial because it is installed on virtually all computers. You can also try “Times New Roman” and “Courier” or “Courier New” as these should be installed on your computer.

I created this using a font called “Blood Of Dracula” bet you don’t have that on your computer. 😀  
 ![39](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/caaf9c5eba8bf536ebe67e896681110a8ec88a9c.png)

---

<div class="post-metadata">

**Author:** ![laptophead](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/laptophead/32/2701_2.png) [@laptophead](https://discourse.processing.org/u/laptophead)\
**Post date:** [November 8, 2018, 8:11pm UTC](https://discourse.processing.org/t/g4p-library-is-there-a-way-to-make-big-letters-on-numbers/4350/11 "2018-11-08T20:11:01Z")

</div>

Thanks a lot for your reply and clarifications.

Since I like the library so much , I am trying to use it further.

I am not being able to obtain any buttons in a sketch that involves video.  
I am trying to find dice (blobs of color) on the table.  
I tried to ad a slider for a treshold for instance but no buttons appear,  
Code was generated in your gui tab.

Here is the main tab,

import processing.video._;  
import java.awt.Font;  
import g4p\_controls._;  
import java.awt.Font;

PFont f;  
PFont font;  
int w= #FFFFFF; // white  
int y= #FCF442; //yellow  
int g= #A0FFA3; //green  
int b= #64E1FF; // blue  
int m= #CC15D3; // Magenta  
int o= #FF6C67; // orange  
int i= #B767FF; // indigo  
int r= #FC0B03; // red  
int bk = (#212121);

Capture video;

color trackColor;  
float threshold = 25;

int Wheel; // value from the mouse wheel  
int WheelAcc=0; // mouse wheel accoumulated

void setup() {  
size(1800, 1100, JAVA2D);  
String[] cameras = Capture.list();  
printArray(cameras);  
video = new Capture(this, “name=iSight,size=640x480,fps=15”);  
video.start();  
trackColor = color(255, 0, 0);  
font = loadFont(“AgencyFB-Bold-200.vlw”);  
frameRate (15);  
}

void captureEvent(Capture video) {  
video.read();  
}

void draw() {  
background(bk);  
video.loadPixels();  
image(video, 0, 0);

//threshold = map(mouseX, 0, width, 0, 100);  
threshold = 30+ WheelAcc;  
threshold = constrain (threshold, 0, 100);

// /\*  
float avgX = 0;  
float avgY = 0;

int count = 0; // nr of pixels found in

// Begin loop to walk through every pixel  
for (int x = 0; x \< video.width; x++ ) {  
for (int y = 0; y \< video.height; y++ ) {  
int loc = x + y \* video.width;  
// What is current color  
color currentColor = video.pixels[loc];  
float r1 = red(currentColor);  
float g1 = green(currentColor);  
float b1 = blue(currentColor);  
float r2 = red(trackColor);  
float g2 = green(trackColor);  
float b2 = blue(trackColor);

```
  float d = distSq(r1, g1, b1, r2, g2, b2); 

  if (d < threshold*threshold) {
    stroke(255);
    strokeWeight(1);
     point(x, y); // this is replacing the "Found " pixels
    avgX += x;
    avgY += y;
    count++;
  }
}

```

}

// We only consider the color found if its color distance is less than 10.  
// This threshold of 10 is arbitrary and you can adjust this number depending on how accurate you require the tracking to be.  
if (count \> 20) {  
avgX = avgX / count;  
avgY = avgY / count;  
// Draw a circle at the tracked pixel  
//println(avgX + " is avgX") ;  
//println(avgY + " is avgY") ;  
fill(255);  
strokeWeight(4.0);  
stroke(0);  
ellipse(avgX, avgY, 24, 24);  
}  
else  
{ //delay (100);

}

//fill (bk);  
//rect(0, 700, 1760, 1060, 7);  
fill (trackColor);  
rect(10, 1040, 50, 1060, 7);

textFont(font, 35);  
fill(w);  
text(“trackColor= “, 70, 1090 );  
text( trackColor, 240, 1090);  
text(“RGB= “, 380, 1090 );  
text(str(int(red(trackColor)))+”,”+str(int(green(trackColor)))+”,”+str(int(blue(trackColor))),460, 1090);

fill ®;  
text(“avgX, AvgY:”, 10, 930 );  
text( nf(avgX, 0, 1), 240, 930);  
text( nf(avgY, 0, 1), 380, 930);

} // end of draw

float distSq(float x1, float y1, float z1, float x2, float y2, float z2)  
{  
float d = (x2-x1)_(x2-x1) + (y2-y1)_(y2-y1) +(z2-z1)\*(z2-z1);  
return d;

// \*/  
}

void mousePressed() {  
if (mouseButton == LEFT) { // Save color where the mouse is clicked in trackColor variable  
int loc = mouseX + mouseY\*video.width; // definition of location by pixel number.  
trackColor = video.pixels[loc];  
println(loc + " is loc") ;  
println(trackColor + " is trackColor") ;

}

else if (mouseButton == RIGHT)  
{video.read();

}  
}

void mouseWheel(MouseEvent event) {  
Wheel = event.getCount();  
WheelAcc = WheelAcc + Wheel;  
//println(WheelAcc + “Acc”) ;  
//println(Wheel + “Wheel”) ;  
println(threshold + " is Treshold") ;  
Wheel = 0;  
}

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [November 8, 2018, 10:01pm UTC](https://discourse.processing.org/t/g4p-library-is-there-a-way-to-make-big-letters-on-numbers/4350/12 "2018-11-08T22:01:02Z")

</div>

I assume that you have used GUI Builder and you have a GUI tab. If so you are missing createGUI() in setup

---

<div class="post-metadata">

**Author:** ![laptophead](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/laptophead/32/2701_2.png) [@laptophead](https://discourse.processing.org/u/laptophead)\
**Post date:** [November 13, 2018, 1:04am UTC](https://discourse.processing.org/t/g4p-library-is-there-a-way-to-make-big-letters-on-numbers/4350/13 "2018-11-13T01:04:24Z")

</div>

Thanks a lot , That was basic. Sorry

I am implementing for the first time a slider. I build it with the G4P tool. Looks and feels great.  
How do I grab the value of the slider to use it in the sketch?

I spent a lot of time with your examples, Cool sliders, Etc…  
They were not created with the G4P tool. More than that, you pile a lot of items in an example, it makes it hard to distinguish what function controls what…  
I am not the sharpest programmer, an amateur at best…

Is there a place to find examples based on the G4P creation process?  
Thanks

---

<div class="post-metadata">

**Author:** ![laptophead](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/laptophead/32/2701_2.png) [@laptophead](https://discourse.processing.org/u/laptophead)\
**Post date:** [November 13, 2018, 1:05am UTC](https://discourse.processing.org/t/g4p-library-is-there-a-way-to-make-big-letters-on-numbers/4350/14 "2018-11-13T01:05:10Z")

</div>

By the way , here is my GUI Tab  
/\* =========================================================

- ==== WARNING ===
- =========================================================
- The code in this tab has been generated from the GUI form
- designer and care should be taken when editing this file.
- Only add/edit code inside the event handlers i.e. only
- use lines between the matching comment tags. e.g.

void myBtnEvents(GButton button) { //_CODE_:button1:12356:  
// It is safe to enter your event code here  
} //_CODE_:button1:12356:

- Do not rename this tab!
- =========================================================  
\*/

public void button2\_click1(GButton source, GEvent event) { //_CODE_:button2:586325:  
println(“button2 - GButton \>\> GEvent.” + event + " @ " + millis());  
} //_CODE_:button2:586325:

public void custom\_slider1\_change1(GCustomSlider source, GEvent event) { //_CODE_:custom\_slider1:885703:  
println(“custom\_slider1 - GCustomSlider \>\> GEvent.” + event + " @ " + millis());  
} //_CODE_:custom\_slider1:885703:

// Create all the GUI controls.  
// autogenerated do not edit  
public void createGUI(){  
G4P.messagesEnabled(false);  
G4P.setGlobalColorScheme(GCScheme.BLUE\_SCHEME);  
G4P.setCursor(ARROW);  
surface.setTitle(“Sketch Window”);  
button2 = new GButton(this, 4, 591, 80, 30);  
button2.setText(“GO GET IT”);  
button2.addEventHandler(this, “button2\_click1”);  
custom\_slider1 = new GCustomSlider(this, 7, 549, 782, 30, “grey\_blue”);  
custom\_slider1.setShowValue(true);  
custom\_slider1.setShowLimits(true);  
custom\_slider1.setLimits(30.0, 0.0, 100.0);  
custom\_slider1.setNumberFormat(G4P.DECIMAL, 2);  
custom\_slider1.setOpaque(false);  
custom\_slider1.addEventHandler(this, “custom\_slider1\_change1”);  
}

// Variable declarations  
// autogenerated do not edit  
GButton button2;  
GCustomSlider custom\_slider1;

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [November 13, 2018, 11:36am UTC](https://discourse.processing.org/t/g4p-library-is-there-a-way-to-make-big-letters-on-numbers/4350/15 "2018-11-13T11:36:06Z")

</div>

There are three functions to get the current slider position depending on the data type

```auto
slider.getValueF(); // returns the slider position as a float
slider.getValueI(); // returns the slider position as an int
slider.getValueS(); // returns the slider position as a String

```

You use the one to suit your slider. In your example you use G4P.DECIMAL so will probably want to use the first one like this

```auto
public void custom_slider1_change1(GCustomSlider source, GEvent event) { // *CODE* :custom_slider1:885703:
    x = source.getValueF(); // x is a float declared in main sketch window
} // *CODE* :custom_slider1:885703:

```

---

<div class="post-metadata">

**Author:** ![laptophead](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/laptophead/32/2701_2.png) [@laptophead](https://discourse.processing.org/u/laptophead)\
**Post date:** [November 13, 2018, 10:27pm UTC](https://discourse.processing.org/t/g4p-library-is-there-a-way-to-make-big-letters-on-numbers/4350/16 "2018-11-13T22:27:48Z")

</div>

Thanks so much, that worked.

---

<div class="post-metadata">

**Author:** ![laptophead](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/laptophead/32/2701_2.png) [@laptophead](https://discourse.processing.org/u/laptophead)\
**Post date:** [November 14, 2018, 7:11pm UTC](https://discourse.processing.org/t/g4p-library-is-there-a-way-to-make-big-letters-on-numbers/4350/17 "2018-11-14T19:11:23Z")

</div>

However now I realize that the `Sider1Output = source.getValueF();` is always defaulting to 0 when I start the sketch.  
Even if I set it to 22 in the G4P tool, `custom_slider1.setLimits(22.0, 4.0, 50.0);`

So in order to get it to 22 I have to move it a bit every time.  
Is there a way to get the 22 out by default?  
Thanks

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [November 15, 2018, 10:06am UTC](https://discourse.processing.org/t/g4p-library-is-there-a-way-to-make-big-letters-on-numbers/4350/18 "2018-11-15T10:06:19Z")

</div>

> [@laptophead](#):
>
> Sider1Output = source.getValueF(); is always defaulting to 0 when I start the sketch.

That’s not true. After the slider is created it will have the initial value you set in the GUI Builder. The method `custom_slider1_change1` is an event handler and is only executed when the slider changes value. If you have variables tracking the slider value then it should be initiallised at startup. In this sketch the variable `x` is used to track the slider value and initialised in `customGUI()`

```auto
// Need G4P library
import g4p_controls.*;

float x;

public void setup(){
  size(480, 320, JAVA2D);
  createGUI();
  customGUI();
  // Place your setup code here
  
}

public void draw(){
  background(230);
  
}

// Use this method to add additional statements
// to customise the GUI controls
public void customGUI(){
  println(x, custom_slider1.getValueF()); // Displays 0.0 22.0
  x = custom_slider1.getValueF(); // Update x which is used to track the slider value
  println(x, custom_slider1.getValueF()); // Displays 22.0 22.0
}

public void custom_slider1_change1(GCustomSlider source, GEvent event) { //_CODE_:custom_slider1:340588:
  x = custom_slider1.getValueF();
} //_CODE_:custom_slider1:340588:

// Create all the GUI controls. 
// autogenerated do not edit
public void createGUI(){
  G4P.messagesEnabled(false);
  G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME);
  G4P.setCursor(ARROW);
  surface.setTitle("Sketch Window");
  custom_slider1 = new GCustomSlider(this, 70, 50, 280, 70, "grey_blue");
  custom_slider1.setShowValue(true);
  custom_slider1.setShowLimits(true);
  custom_slider1.setLimits(22.0, 4.0, 50.0);
  custom_slider1.setNumberFormat(G4P.DECIMAL, 2);
  custom_slider1.setOpaque(false);
  custom_slider1.addEventHandler(this, "custom_slider1_change1");
}

// ====================================================================
// GUI tab code

// Variable declarations 
// autogenerated do not edit
GCustomSlider custom_slider1; 

```

---

<div class="post-metadata">

**Author:** ![laptophead](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/laptophead/32/2701_2.png) [@laptophead](https://discourse.processing.org/u/laptophead)\
**Post date:** [November 16, 2018, 8:33pm UTC](https://discourse.processing.org/t/g4p-library-is-there-a-way-to-make-big-letters-on-numbers/4350/19 "2018-11-16T20:33:44Z")

</div>

Got it, thanks. I defined it with a value in the definitions.  
Like this:

```auto
float Slider1Output=22;

```

before was just:

```auto
float Slider1Output;

```

Other folks might find this useful.

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [November 16, 2018, 10:51pm UTC](https://discourse.processing.org/t/g4p-library-is-there-a-way-to-make-big-letters-on-numbers/4350/20 "2018-11-16T22:51:43Z")

</div>

The way I showed you in the last post is best because the variable is always correct even if the slider value is changed in GUI Builder
