From a7e7618fb914f8b919a17daf6c020b860c5d11c9 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Tue, 10 Sep 2019 00:32:18 -0400
Subject: [PATCH] Lazy icons.

---
 cButton.java |   32 ++++++++++++++++++++++++++++----
 1 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/cButton.java b/cButton.java
index 0a15961..701e0cf 100644
--- a/cButton.java
+++ b/cButton.java
@@ -1,5 +1,8 @@
 public class cButton extends javax.swing.JButton
 {
+    String iconname;
+    boolean fit;
+    
     cButton(String name)
     {
         super(name);
@@ -22,16 +25,20 @@
         }
     }
     
-    cButton(javax.swing.ImageIcon icon, boolean border, boolean fit)
+    cButton(//javax.swing.ImageIcon icon,
+            String iconname,
+            boolean border, boolean fit)
     {
-        super(icon);
+        //super(icon);
+        this.iconname = iconname;
+        this.fit = fit;
         
         assert(border);
         
         //setMargin(new java.awt.Insets(1, 10, 1, 10)); // ??
         
-        if (icon != null && fit)
-            this.image = icon.getImage();
+//        if (icon != null && fit)
+//            this.image = icon.getImage();
         
 //result = new JButton( icon );
 //result.setBorderPainted( false );
@@ -53,6 +60,23 @@
     //@Override
     protected void paintComponent(java.awt.Graphics g)
     {
+        if (iconname != null)
+        {
+            javax.swing.ImageIcon icon = ObjEditor.GetIcon(iconname);
+
+            if (icon == null)
+                setName(iconname);
+            else
+            {
+                if (fit)
+                    this.image = icon.getImage();
+                else
+                    setIcon(icon);
+            }
+            
+            iconname = null;
+        }
+        
         if (image != null)
         {
             //if (getWidth() > image.getWidth(null) + 8)

--
Gitblit v1.6.2