//  Attributes.java

import javax.swing.*;
import java.awt.event.*;

/** Obtain attributes of a state from the user (start, final).
 *  Starting state, and final state are attributes.
 *  Use a JPanel containing two checkBoxes.
 *
 *  @author <a href="mailto:bergmann@rowan.edu"> Seth Bergmann </a>
 *  @author <a href="mailto:gspyo@jersey.net"> Greg Safko </a>
 */
public class Attributes extends JPanel
	implements ItemListener, ActionListener
{  JCheckBox startBox, finalBox;
   State state;			// the selected state
   
/** Set up the JPanel containing two checkboxes
 * @param st The state whose attributes are being modified.
 */
public Attributes(State st)
{  
   startBox = new JCheckBox ("Start state");
   finalBox = new JCheckBox ("Final (accepting) state");
   startBox.setContentAreaFilled (false);	
   finalBox.setContentAreaFilled (false);	
   startBox.addActionListener(this);
   finalBox.addActionListener(this);
   startBox.setSelected (st.isStart);
   finalBox.setSelected (st.isFinal);
   add (startBox);
   add (finalBox);
   state = st;
   setVisible (true);
}

/** This method is invoked when a box is checked (?)
 */
public void actionPerformed (ActionEvent evt)
{  
   state.isStart = startBox.isSelected();
   if (state.isStart) state.nfa.start = state;
   state.isFinal = finalBox.isSelected();
}

public void itemStateChanged (ItemEvent evt)
{
}

}
