// file: GotoFrame.java
//

// import java libraries
//
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

/**
 * Go to Frame class, extension of JFrame
 */
public class GotoFrame extends JFrame {

    JLabel bugNumber = null;
    JTextField bugEntry = null;
    JButton submitButton = null;
    JPanel mainPanel = null;
    JComboBox dbase = null;
    JLabel dbSelect = null;

    /**
     * default constructor
     * @param varmint VarmintPanel used for initialization
     */
    public GotoFrame(VarmintPanel varmint) {
	
	mainPanel = new JPanel();
	mainPanel.setLayout(new GridLayout(3,2));
	mainPanel.setFont(varmint.newFont);

	bugNumber = new JLabel("Bug Number");
	bugNumber.setFont(varmint.newFont);

	dbSelect = new JLabel("Database");
	bugNumber.setFont(varmint.newFont);

	bugEntry = new JTextField("", 6);
	bugEntry.setDocument(new IntDocument());
	bugEntry.setFont(varmint.newFont);


	Vector configVector = varmint.database.getConfig();
	Vector titles = new Vector(12, 2);
	Vector strings = new Vector(12, 2);
	Vector enum_item = new Vector(5,5);
	String values = new String(""); 

	for(int i=0; i < configVector.size(); i++) {
	    titles.add(((Vector)configVector.get(i)).get(0));
	    strings.add(((Vector)configVector.get(i)).get(1));
	}
			
	values = (String)strings.get(titles.indexOf("DBase"));
		    
	// create a blanks value to be the default value
	//
	enum_item.add("");
	
	// tokenize the string containing the values with comma as the
	// delimiter
	//
	StringTokenizer tokenizer = new StringTokenizer(values, ",");
	
	// run through and add each token to the enum_items vector
	//
	while (tokenizer.hasMoreTokens()) {
		
	    String line = (String)tokenizer.nextToken();
	    enum_item.add(line.trim());
	}
	
        dbase = new JComboBox(enum_item);
    
	submitButton = new JButton("Submit");
	submitButton.addActionListener(varmint);
	submitButton.setFont(varmint.newFont);

	//	System.out.println("Joe... please add in code that will check and make sure that the number they entered is a good number");
	
	mainPanel.add(bugNumber);
	mainPanel.add(bugEntry);
	mainPanel.add(dbSelect);
	mainPanel.add(dbase);
	mainPanel.add(new JLabel(""));
	mainPanel.add(submitButton, BorderLayout.SOUTH);
	this.getContentPane().add(mainPanel);
	

    } 

}
