diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js
index 83c90fcc9d322159af97ed053974c563b21006bd..4590cb4777c3be41bc94d485b14f31fe42a13c22 100644
--- a/pd/nw/pdgui.js
+++ b/pd/nw/pdgui.js
@@ -2293,8 +2293,11 @@ function gui_bng_new(cid, tag, cx, cy, radius) {
 }
 
 function gui_bng_button_color(cid, tag, color) {
-    var button = get_item(cid, tag + "button");
-    configure_item(button, { fill: color });
+    var button;
+    if (patchwin[cid]) {
+        button = get_item(cid, tag + "button");
+        configure_item(button, { fill: color });
+    }
 }
 
 function gui_bng_configure(cid, tag, color, cx, cy, r) {