From cb37a129d1adb403019c96e798e86e2da9667f15 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sun, 17 Nov 2019 17:56:04 -0500 Subject: [PATCH] Maze --- cButton.java | 51 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 48 insertions(+), 3 deletions(-) diff --git a/cButton.java b/cButton.java index 2022871..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,11 +25,20 @@ } } - cButton(javax.swing.ImageIcon icon, boolean border) + cButton(//javax.swing.ImageIcon icon, + String iconname, + boolean border, boolean fit) { - super(icon); + //super(icon); + this.iconname = iconname; + this.fit = fit; - setMargin(new java.awt.Insets(-1, -1, -1, -1)); + assert(border); + + //setMargin(new java.awt.Insets(1, 10, 1, 10)); // ?? + +// if (icon != null && fit) +// this.image = icon.getImage(); //result = new JButton( icon ); //result.setBorderPainted( false ); @@ -42,4 +54,37 @@ //setBorder(null); //new javax.swing.border.EmptyBorder(0,0,0,0)); } } + + private java.awt.Image image; + + //@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) + { + g.drawImage(image, 0,0, this.getWidth()-1, this.getHeight()-1, this); + } + } + else + super.paintComponent(g); + } } -- Gitblit v1.6.2