AYUDA CON MI SIMULADOR HECHO EN JAVA

#1
Bien es mi 2da vez Q posteo. bn estoy haciendo un simulador de automatas en lenguaje JAVA en netbeans 6.7 y aqui esta mi codigo y le mostrare mi error. pero antes una breve explicacion. tengo una clase llamada STATES extends JLABEL la cual seran mis nodos por decirlo asi en mi automata bien mi error es al momento de agregarlo al panel donde quiero que se muestren espero Q me ayuden.....
:::CLASE STATES:::
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package automata;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import javax.swing.*;
import javax.swing.ImageIcon;
import javax.swing.Timer;
import javax.swing.border.Border;
/**
*
* @author Douglas Cifuentes
*/
public class States extends JLabel implements MouseListener, MouseMotionListener, AutomataComponents{
/*INFORMACION ESTATICA*/
private static int statesNO;
private static int currentStateSize;
public static boolean transitioning = false;
/*IMAGENES A PINTAR*/
public ImageIcon stateImage = new ImageIcon(getClass().getResource("util/automataIcons/state.gif"));
public ImageIcon startImage = new ImageIcon(getClass().getResource("util/automataIcons/startState.gif"));
public ImageIcon acceptImage = new ImageIcon(getClass().getResource("util/automataIcons/acceptState.gif"));
public ImageIcon startAcceptImage = new ImageIcon(getClass().getResource("util/automataIcons/startAccept.gif"));
/*VARIABLE DE CONTROL Y OPCIONES*/
private boolean isAccept;
public String myName; //nombre del estado
private Point loadPoint;
private Border myBorder;
private Border destinationBorder;//segun transicion
private Border selectBorder;
private boolean deleted;
private boolean immutable;
private Point clicPoint;
private Timer botonTimer;
public long timeCount;
private boolean moved;
private boolean botonStatusLEFT;
private boolean botonStatusRIGHT;
private boolean botonStatusNONE;
public static AutomataMain mainFrame = null;
public States(){
this("Q" + statesNO);
}

public States(String name){
super();
myName = name;
statesNO++;
myBorder = BorderFactory.createLineBorder(Color.WHITE,2);
selectBorder = BorderFactory.createLineBorder(Color.BLUE, 2);
destinationBorder = BorderFactory.createLineBorder(Color.BLACK, 2);
Color temp = new Color(Color.BLUE.getAlpha(), Color.BLUE.getRed(), Color.BLUE.getGreen());
this.setVerticalTextPosition(JLabel.BOTTOM);
this.setHorizontalTextPosition(JLabel.CENTER);
this.setText(myName);
this.setFont(new Font("SanSerif", Font.PLAIN, 9));
this.setBackground(temp);
this.setBorder(myBorder);
this.setOpaque(false);
this.addMouseListener(this);
this.addMouseMotionListener(this);
botonTimer = new Timer(150, new TimerListener());
deleted = false;
moved = false;
immutable = false;
this.update();
}
/*CONSTRUCTOR DE STATES DESDE UNA INFO GUARDADA
* @param name String
* @param x int
* @param y int
* @param aM AutomataMain
*/
public static States constructor(String name, int x, int y){
States _States = new States(name);
_States.setLoadLocation(x, y);
_States.update();
return _States;
}
public AutomataMain getMainFrame()
{
return mainFrame;
}
public void setLoadLocation(int _x, int _y){
loadPoint = new Point(_x, _y);
}
public boolean deleteded(){
return deleted;
}
public void mouseClicked(MouseEvent e) {
if(!immutable){
if(mainFrame.transition == true){
if(!transitioning){
//TODO
}
else{
//TODO
}
}
else{
if(e.getButton() == MouseEvent.BUTTON3){
//TODO
}
else if(e.getButton() == MouseEvent.BUTTON1){
//mainFrame.getCurrentHighlight(null,this);
}
}
}
else{
//TODO
}
}
public void mousePressed(MouseEvent e) {
if(!immutable){
switch(e.getButton()){
case MouseEvent.BUTTON1:
botonStatusLEFT=true;
botonStatusRIGHT=false;
botonStatusNONE=false;
clicPoint = e.getPoint();
break;
case MouseEvent.BUTTON2:
botonStatusRIGHT=true;
botonStatusLEFT=false;
botonStatusNONE=false;
break;
default:
botonStatusRIGHT=false;
botonStatusLEFT=false;
botonStatusNONE=true;
break;
}
botonTimer.start();
}
}
public void mouseReleased(MouseEvent e) {
if(!immutable){
botonTimer.stop();
timeCount = 0;
//TODO
}
}
public void mouseEntered(MouseEvent e) {
if(!immutable)
this.select();
}
public void mouseExited(MouseEvent e) {
if(!immutable)
this.deselect();
}
public void mouseDragged(MouseEvent e) {
if(botonStatusLEFT == true && timeCount > 0){
e.translatePoint((int)(this.getX() - clicPoint.getX()),(int)(this.getY() - clicPoint.getY()) );
}
}
public void mouseMoved(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void select() {
this.setBorder(selectBorder);
}
public void deselect() {
this.setBorder(myBorder);
}
public void deleted() {
throw new UnsupportedOperationException("Not supported yet.");
}
public void update() {
if(mainFrame.state == true){
this.setIcon(stateImage);
}
else if(mainFrame.start == true){
this.setIcon(startImage);
}
else if(mainFrame.accept == true){
this.setIcon(acceptImage);
}
else if(mainFrame.startAccept == true){
this.setIcon(startAcceptImage);
}
Dimension resize = this.getMaximumSize();
resize.height += 2;
resize.width *= 2;
this.setText(myName);
this.setPreferredSize(resize);
this.setBounds(new Rectangle(this.getLocation(), resize));
this.repaint();
}
@Override
public Point getLocation() {
return loadPoint;
}
@Override
public Border getBorder() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Component add(Component toAdd) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setBorder(Border border) {
}
@Override
public String getName() {
return myName;
}
public void selectDestination() {
this.setBorder(destinationBorder);
}
private class TimerListener implements ActionListener{
public void actionPerformed(ActionEvent e) {
timeCount++;
}
}
}
::AL INSERTARLO::
private void showAutomataPanelMouseClicked(java.awt.event.MouseEvent evt) {
if(state == true){ //boolean Q me indica Q tipo de Stado desea
States myStates = new States();
Point tempPoint = evt.getPoint();
insets = getInsets();
myStates.setLocation(tempPoint.x + insets.left, tempPoint.y + insets.top);
this.add(myStates);
}
}
::ERROR DE OUTPUT::
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at automata.States.update(States.java:193)
at automata.States.<init>(States.java:76)
at automata.States.<init>(States.java:52)
at automata.AutomataMain.showAutomataPanelMouseClicked(AutomataMain.java:429)
at automata.AutomataMain.access$1000(AutomataMain.java:24)
at automata.AutomataMain$11.mouseClicked(AutomataMain.java:270)
at java.awt.Component.processMouseEvent(Component.java:6137)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5899)
at java.awt.Container.processEvent(Container.java:2023)
at java.awt.Component.dispatchEventImpl(Component.java:4501)
at java.awt.Container.dispatchEventImpl(Container.java:2081)
at java.awt.Component.dispatchEvent(Component.java:4331)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4301)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3974)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3895)
at java.awt.Container.dispatchEventImpl(Container.java:2067)
at java.awt.Window.dispatchEventImpl(Window.java:2458)
at java.awt.Component.dispatchEvent(Component.java:4331)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

ESPERO ME AYUDEN:chommy:
 
Arriba