Basic help with expanding JBuilder book skills 12 and 17
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   gwydion_jones
Posted On:   Tuesday, March 4, 2003 02:03 PM

I need some help merging JBuilder book skills 12 and 17 so I can demonstrate bound properties with a menu driven app. I'm having trouble with my component file that has the bound properties in it though, code follows:- import java.awt.*; import javax.swing.JPanel; import java.beans.*; import java.awt.font.*; import java.awt.geom.*; public class GreenBox extends JPanel { public GreenBox() { setBackground(Color.white); setForeground(Color.black); setText("Help meeeeeeee!"); }    More>>

I need some help merging JBuilder book skills 12 and 17 so I can demonstrate bound properties with a menu driven app.


I'm having trouble with my component file that has the bound properties in it though, code follows:-

			
import java.awt.*;


import javax.swing.JPanel;


import java.beans.*;


import java.awt.font.*;


import java.awt.geom.*;



public class GreenBox extends JPanel {



public GreenBox() {


setBackground(Color.white);


setForeground(Color.black);


setText("Help meeeeeeee!");


}



private String text;


private java.awt.Font font;


private java.awt.Color foreground;



private transient PropertyChangeSupport propertyChangeListeners =
new PropertyChangeSupport(this);


public void setText(String text) {


String oldText = this.text;


this.text = text;


propertyChangeListeners.firePropertyChange("text", oldText, text);


repaint();


}


public String getText() {


return text;


}



public void setFont(java.awt.Font font) {


java.awt.Font oldFont = this.font;


this.font = font;


propertyChangeListeners.firePropertyChange("font", oldFont, font);


repaint();


}


public java.awt.Font getFont() {


return font;


}



public void setForeground(java.awt.Color foreground) {


java.awt.Color oldForeground = this.foreground;


this.foreground = foreground;


propertyChangeListeners.firePropertyChange("foreground", oldForeground, foreground);


repaint();


}


public java.awt.Color getForeground() {


return foreground;


}



public synchronized void addPropertyChangeListener(PropertyChangeListener l) {


super.addPropertyChangeListener(l);


propertyChangeListeners.addPropertyChangeListener(l);


}


public synchronized void removePropertyChangeListener(PropertyChangeListener
l) {


super.removePropertyChangeListener(l);


propertyChangeListeners.removePropertyChangeListener(l);


}


}




this produces "java.lang.NullPointerException new GreenBox()"


and ""MenuTester.java": Error #: 300 : method setForeground(java.lang.String) not found in class exercise1.GreenBox at line 198, column 17.



Any ideas?



Thanks

   <<Less
About | Sitemap | Contact