BookmarkSubscribeRSS Feed



Mar 21, 2013

Choose Language Hide Translation Bar

Custom Button Icons


You need special purpose icons on buttons.


Make your own pictures and specify them as the icon for a button. First, an easy example, where you might use ms-paint to make a bitmap

New Window( "hello", Button Box( "optional text", <<setIcon( "$desktop/hi.jpg" ) ) )


Capture1.PNGHuge button icon without transparency

You might want to have an empty string for the optional text, and you'll probably want a much smaller picture. That picture is more than 100x100. Typical icons are 16x16 or 32x32. You'll also want a drawing program that can create .png files with transparent backgrounds. The button above has a white background that clashes with the button's gray background (which might not be gray, depending on the theme).

Here's an example that takes pictures of the JMP markers to make icons from them.

// You'll need to restart JMP to see changes you make to the icon files
// because JMP caches them on first load and will not notice changes.
// (Or you can just make new names while testing, but that isn't a
// good idea for production code)

iconsize=16; // balance this with markersize, below
gridsize=200; // more than big enough for markers.
gridcenterX=gridsize/2+1; // may need +/- 1 or 2 for centering
gridcenterY=gridsize/2+2; // may need +/- 1 or 2 for centering

For( icon = 0, icon <= 31, icon++,
    // make a graph of just this marker, centered
    gb = Graph Box(
        FrameSize( gridsize, gridsize ), //
        Y Scale( 0, 2 ),
        X Scale( 0, 2 ),
        suppressaxes( 1 ),
        Marker( icon, {1, 1} ),<<backgroundcolor("white"),<<markersize(3)
    // gray scale. the red channel is the same as blue and green.
    {r} = (gb[framebox(1)] << getpicture)<<getpixels("r");
    r = r[(gridcenterY-iconhalf)::(gridcenterY+iconhalf-1),(gridcenterX-iconhalf)::(gridcenterX+iconhalf-1)]; // crop border away
    img = newimage("rgba",{r,r,r,1-r}); // add transparency



updategraph = function({n},

newwindow("icons", LB, gb=borderbox(textbox("choose a symbol")));

Capture.PNGButtons with custom icons


This discussion started this idea. JMP may cache the icon bitmaps for performance; restart JMP if you are wondering why your bitmap changes are not showing up. The longer example also demonstrates how JMP's alpha channel (the "a" in "rgba") can create bitmaps with transparency. The long example saves the icons in $temp. If more than one JMP script might be doing this, they could get in each other's way. You could also create icons and embed the .png files into an add-in.

See Also

Builtin Icons


Article Labels
Article Tags