1 /*
2 * PaintableEditor.java
3 *
4 * Created on 19 February 2001, 18:07
5 */
6
7 package org.johndavidtaylor.beans.beanpeeler;
8 import java.awt.BorderLayout;
9 import java.awt.Canvas;
10 import java.awt.Dialog;
11 import java.awt.Dimension;
12 import java.awt.Frame;
13 import java.awt.Graphics;
14 import java.awt.Rectangle;
15 import java.beans.PropertyEditor;
16 /***
17 *
18 * @author JTAYLOR3
19 */
20 public class PaintableEditor extends java.awt.Panel implements GEditor {
21 private PropertyEditor pe;
22 private BeanPeeler bd;
23 static private Rectangle paintArea = new Rectangle(0,0,10,10);
24 private Frame parent;
25 /*** Creates new form PaintableEditor */
26 public PaintableEditor(PropertyEditor pe, BeanPeeler bd) {
27 initComponents ();
28 this.pe = pe;
29 this.parent = bd;
30 this.bd = bd;
31 }
32
33 /*** This method is called from within the constructor to
34 * initialize the form.
35 * WARNING: Do NOT modify this code. The content of this method is
36 * always regenerated by the FormEditor.
37 */
38 private void initComponents() {//GEN-BEGIN:initComponents
39 pa = new PaintArea();
40 add(pa);
41 button1 = new java.awt.Button();
42 setLayout(new java.awt.GridLayout(1, 2));
43
44 button1.setFont(new java.awt.Font ("Dialog", 0, 11));
45 button1.setLabel("...");
46 button1.setBackground(java.awt.Color.lightGray);
47 button1.setForeground(java.awt.Color.black);
48 button1.addActionListener(new java.awt.event.ActionListener() {
49 public void actionPerformed(java.awt.event.ActionEvent evt) {
50 button1ActionPerformed(evt);
51 }
52 }
53 );
54
55 add(button1);
56
57 }//GEN-END:initComponents
58
59 private void button1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button1ActionPerformed
60 Dialog d = new CustomEditorDialog(parent, true);
61 d.add(pe.getCustomEditor(), BorderLayout.CENTER);
62 d.pack();
63 d.show();
64
65 pa.repaint();
66 }//GEN-LAST:event_button1ActionPerformed
67
68 /*** Getter for property paintArea.
69 * @return Value of property paintArea.
70 */
71 static public Dimension getPaintArea() {
72 return new Dimension(paintArea.width,paintArea.height);
73 }
74
75 /*** Setter for property paintArea.
76 * @param paintArea New value of property paintArea.
77 */
78 static public void setPaintArea(Dimension paintArea1) {
79 paintArea.width = paintArea1.width;
80 paintArea.height = paintArea1.height;
81 }
82
83 public void refresh() {
84 pa.repaint();
85 }
86
87 // Variables declaration - do not modify//GEN-BEGIN:variables
88 private java.awt.Button button1;
89 // End of variables declaration//GEN-END:variables
90
91 private PaintArea pa;
92
93 public class PaintArea extends Canvas {
94 public PaintArea() {
95 super();
96 setSize(paintArea.width, paintArea.height);
97 }
98 public void paint (Graphics g) {
99 //super.paint(g);
100 if (pe.isPaintable()) {
101 pe.paintValue(g, paintArea);
102 //System.out.println("painting");
103 }
104 }
105 }
106 }
This page was automatically generated by Maven