From 3966454055db8e04700e881a091c2d33dcfda232 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Mon, 30 Sep 2019 19:22:19 -0400 Subject: [PATCH] tab index --- cButton.java | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 49 insertions(+), 4 deletions(-) diff --git a/cButton.java b/cButton.java index faeb185..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); @@ -12,7 +15,7 @@ { super(name); - setMargin(new java.awt.Insets(1, -8, 1, -8)); + setMargin(new java.awt.Insets(1, -1, 1, -1)); if (border) setBorder(new javax.swing.border.EtchedBorder()); @@ -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, -8, -1, -8)); + 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