I really need help. I have this whole program and am getting on error.

Attachments
/*
	Chapter 6:	Programming Assignment #1
	Programmer:
	Date:
	Filename:	Buttons.java
	Purpose:	Enhancing a Frame
*/

import java.awt.*;
import java.awt.event.*;
import javax.swing.JOptionPane;
import javax.swing.*;
import javax.swing.text.*;
import java.text.DecimalFormat;
import java.io.*;
import java.lang.*;
import java.math.*;
import javax.swing.JFrame;


public class Buttons extends JFrame implements  ItemListener
{
	Choice choice = new Choice();

	public Buttons()
	{
		//set the layout
		setLayout(new BorderLayout(20,5));

		choice.add("Payroll Journal");
		choice.add("Employee info");
		choice.add("Print check and Check stubs");

		choice.addItemListener(this);


		add(choice, BorderLayout.CENTER);

		//override the windowClosing event
		addWindowListener(
			new WindowAdapter()
				{
				public void windowClosing(WindowEvent e)
					{
					   System.exit(0);
					}
				}
		);
	}

   	public static void main(String[] args)
   	{
	   	// set frame properties
		Buttons f = new Buttons();
      	f.setTitle("The Choice Box");
      	f.setBounds(200,200,300,300);
	    f.setVisible(true);
	    f.setBackground(Color.white);
   }
   public void last_try()
   			{
				public class last_try extends JFrame implements ActionListener
{
 	//construct components
 	JLabel sortPrompt = new JLabel("Sort by:");
  	JComboBox fieldCombo = new JComboBox();
	JTextPane textPane = new JTextPane();

	//initialize data in arrays
	String ID[] = {};
   	String name[] = {};
   	String Insur[] = {};
   	String strGross_Pay[] = {};
   	String strFICA[] = {};
   	String strFED[] = {};
   	String strNet_Pay[] = {};



 	//construct instance of Employee
  	public pay()
   	{//5
      	super("Widget's Incorporated");
 	}//5

	//create the menu system
	public JMenuBar createMenuBar()
	{//6
		//create an instance of the menu
		JMenuBar mnuBar = new JMenuBar();
		setJMenuBar(mnuBar);

		//construct and populate the File menu
		JMenu mnuFile = new JMenu("File", true);
 			mnuFile.setMnemonic(KeyEvent.VK_F);
			mnuFile.setDisplayedMnemonicIndex(0);
			mnuBar.add(mnuFile);

		JMenuItem mnuFileExit = new JMenuItem("Exit");
 			mnuFileExit.setMnemonic(KeyEvent.VK_X);
			mnuFileExit.setDisplayedMnemonicIndex(1);
			mnuFile.add(mnuFileExit);
			mnuFileExit.setActionCommand("Exit");
			mnuFileExit.addActionListener(this);

		//construct and populate the Edit menu
		JMenu mnuEdit = new JMenu("Edit", true);
 			mnuEdit.setMnemonic(KeyEvent.VK_E);
			mnuEdit.setDisplayedMnemonicIndex(0);
			mnuBar.add(mnuEdit);

		JMenuItem mnuEditInsert = new JMenuItem("Insert New Employee");
 			mnuEditInsert.setMnemonic(KeyEvent.VK_I);
			mnuEditInsert.setDisplayedMnemonicIndex(0);
			mnuEdit.add(mnuEditInsert);
			mnuEditInsert.setActionCommand("Insert");
			mnuEditInsert.addActionListener(this);

		JMenu mnuEditSearch = new JMenu("Search");
 			mnuEditSearch.setMnemonic(KeyEvent.VK_R);
			mnuEditSearch.setDisplayedMnemonicIndex(3);
			mnuEdit.add(mnuEditSearch);

		JMenuItem mnuEditSearchByTitle = new JMenuItem("by Title");
 			mnuEditSearchByTitle.setMnemonic(KeyEvent.VK_T);
			mnuEditSearchByTitle.setDisplayedMnemonicIndex(3);
			mnuEditSearch.add(mnuEditSearchByTitle);
			mnuEditSearchByTitle.setActionCommand("ID");
			mnuEditSearchByTitle.addActionListener(this);

		JMenuItem mnuEditSearchByStudio = new JMenuItem("by Studio");
 			mnuEditSearchByStudio.setMnemonic(KeyEvent.VK_S);
			mnuEditSearchByStudio.setDisplayedMnemonicIndex(3);
			mnuEditSearch.add(mnuEditSearchByStudio);
			mnuEditSearchByStudio.setActionCommand("name");
			mnuEditSearchByStudio.addActionListener(this);

		JMenuItem mnuEditSearchByYear = new JMenuItem("by Year");
 			mnuEditSearchByYear.setMnemonic(KeyEvent.VK_Y);
			mnuEditSearchByYear.setDisplayedMnemonicIndex(3);
			mnuEditSearch.add(mnuEditSearchByYear);
			mnuEditSearchByYear.setActionCommand("Insur");
			mnuEditSearchByYear.addActionListener(this);

		return mnuBar;
	}//6

	//create the content pane
	public Container createContentPane()
	{//7
		//populate the JComboBox
		fieldCombo.addItem("Title");
		fieldCombo.addItem("Studio");
		fieldCombo.addItem("Year");
		fieldCombo.addActionListener(this);
		fieldCombo.setToolTipText("Click the drop-down arrow to display sort fields.");

		//construct and populate the north panel
		JPanel northPanel = new JPanel();
			northPanel.setLayout(new FlowLayout());
			northPanel.add(sortPrompt);
			northPanel.add(fieldCombo);

		//create the JTextPane and center panel
		JPanel centerPanel = new JPanel();
			setTabsAndStyles(textPane);
			textPane = addTextToTextPane();
			JScrollPane scrollPane = new JScrollPane(textPane);
				scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
				scrollPane.setPreferredSize(new Dimension(800, 400));
			centerPanel.add(scrollPane);

		//create Container and set attributes
		Container c = getContentPane();
			c.setLayout(new BorderLayout(10,10));
			c.add(northPanel,BorderLayout.NORTH);
			c.add(centerPanel,BorderLayout.CENTER);

		return c;
	}//7

	//method to create tab stops and set font styles
	protected void setTabsAndStyles(JTextPane textPane)
	{//8
		//create Tab Stops
		TabStop[] tabs = new TabStop[7];
			tabs[0] = new TabStop(100, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
			tabs[1] = new TabStop(200, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
			tabs[2] = new TabStop(350, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
			tabs[3] = new TabStop(450, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
			tabs[4] = new TabStop(475, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
			tabs[5] = new TabStop(550, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
			tabs[6] = new TabStop(625, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
		TabSet tabset = new TabSet(tabs);

		//set Tab Style
		StyleContext tabStyle = StyleContext.getDefaultStyleContext();
		AttributeSet aset =
			tabStyle.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.TabSet, tabset);
		textPane.setParagraphAttributes(aset, false);

		//set Font Style
		Style fontStyle =
			StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);

		Style regular = textPane.addStyle("regular", fontStyle);
		StyleConstants.setFontFamily(fontStyle, "SansSerif");

		Style s = textPane.addStyle("italic", regular);
		StyleConstants.setItalic(s, true);

		s = textPane.addStyle("bold", regular);
		StyleConstants.setBold(s, true);

		s = textPane.addStyle("large", regular);
		StyleConstants.setFontSize(s, 16);
	}//8

	//method to add new text to the JTextPane
   	public JTextPane addTextToTextPane()
   	{//9
   		Document doc = textPane.getDocument();

   		DecimalFormat twoDigits=new DecimalFormat("$#,000.00");

   		try
   		{//10
			//clear previous text
			doc.remove(0, doc.getLength());

			//insert ID
			doc.insertString(0,"ID\tName\tGross_Pay\tFICA\tFED\tInsur\tNet Pay\n",textPane.getStyle("large"));

			//insert detail
   		  	for (int j = 0; j<ID.length; j++)
   		  	{//11
   				doc.insertString(doc.getLength(), ID[j] + "\t", textPane.getStyle("regular"));
   				doc.insertString(doc.getLength(), name[j] + "\t", textPane.getStyle("regular"));
   				doc.insertString(doc.getLength(), strGross_Pay[j] + "\t", textPane.getStyle("regular"));
   				doc.insertString(doc.getLength(), strFICA[j] + "\t", textPane.getStyle("regular"));
   				doc.insertString(doc.getLength(), strFED[j] + "\t", textPane.getStyle("regular"));
   				doc.insertString(doc.getLength(), Insur[j] + "\t", textPane.getStyle("regular"));
   				doc.insertString(doc.getLength(), strNet_Pay[j] + "\n", textPane.getStyle("regular"));
   			}//11
   		}//10
   		catch (BadLocationException ble)
   		{//12
   			System.err.println("Couldn't insert text.");
   		}//12

   		return textPane;
   	}//9

	//event to process user clicks
   	public void actionPerformed(ActionEvent e)
   	{//13
		String arg = e.getActionCommand();

		//user clicks the sort by combo box
		if (e.getSource() == fieldCombo)
		{//14
			switch (fieldCombo.getSelectedIndex())
			{//15
				case 0:
					sort(ID);
					break;
				case 1:
					sort(name);
					break;
				case 2:
					sort(Insur);
					break;
			}//15
		}//14

		//user clicks Exit on the File menu
		if (arg == "Exit")
			System.exit(0);

		//user clicks Insert New Employee on the Edit menu
		if (arg == "Insert") // this code should be in another method called here
		{//16
			//accept new data
			String newID = JOptionPane.showInputDialog(null, "Please enter the new employee's ID");
			String newName = JOptionPane.showInputDialog(null, "Please enter their name " );
			String newInsur = JOptionPane.showInputDialog(null, "Please enter the Insurance amount " );
			String newROP = JOptionPane.showInputDialog(null, "Please enter the rate of pay " );
			String newHW = JOptionPane.showInputDialog(null, "Please enter the amount of hours worked " );
			String newDependents = JOptionPane.showInputDialog(null, "How many dependents do they claim " );

			Double HW = Double.parseDouble(newHW);
			Double RP = Double.parseDouble(newROP);
			Double Depend = Double.parseDouble(newDependents);
			Double dblInsure = Double.parseDouble(newInsur);

			Double GP = HW * RP;
			Long FICA = Math.round(GP * .0765) ;
			Double FED = Math.round(GP * Depend) * 0.15;
			Double Net_Pay = (GP - FICA - FED - dblInsure);

			String sGP = String.valueOf(GP);
			String sFICA = String.valueOf(FICA);
			String sFED = String.valueOf(FED);
			String sInsure = String.valueOf(dblInsure);
			String sNet_Pay = String.valueOf(Net_Pay);



			//enlarge arrays
			ID = enlargeArray(ID);
			name = enlargeArray(name);
			Insur = enlargeArray(Insur);
			strGross_Pay = enlargeArray(strGross_Pay);
			strFICA = enlargeArray(strFICA);
			strFED = enlargeArray(strFED);
			strNet_Pay = enlargeArray(strNet_Pay);

			//add new data to arrays
			ID[ID.length-1] = newID;
			name[name.length-1] = newName;
			Insur[Insur.length-1] = newInsur;
			strGross_Pay[strGross_Pay.length-1] = sGP;
			strFICA[str

Post the code in CODE tags, the exact error, and what about it you don't understand.

Edited 3 Years Ago by happygeek: fixed formatting

Just put [code] before and [/code] after your code - or highlight it and click the code tag button at the top of the editor (the advaced editor, not the little quick reply one at the bottom of the thread)

How do I load a JFrame that I made in one program when I click an option in another program. If payroll is clicked in the buttons program I want the frame from the last_try program. I really need help. I am running out of time

Attachments
/*
	Chapter 6:	Programming Assignment #1
	Programmer:
	Date:
	Filename:	Buttons.java
	Purpose:	Enhancing a Frame
*/

import java.awt.*;
import java.awt.event.*;
import javax.swing.JOptionPane;
import javax.swing.*;
import javax.swing.text.*;
import java.text.DecimalFormat;
import java.io.*;
import java.lang.*;
import java.math.*;
import javax.swing.JFrame;


public class Buttons extends JFrame implements  ItemListener
{//1
	Choice choice = new Choice();

	public Buttons()
	{//2
		//set the layout
		setLayout(new BorderLayout(20,5));

		choice.add("Payroll Journal");
		choice.add("Employee info");
		choice.add("Print check and Check stubs");

		choice.addItemListener(this);


		add(choice, BorderLayout.CENTER);

		//override the windowClosing event
		addWindowListener(
			new WindowAdapter()
				{//3
				public void windowClosing(WindowEvent e)
					{//4
					   System.exit(0);
					}//4
				}//3
		);

}//2
   	public static void main(String[] args)
   	{//4
	   	// set frame properties
		Buttons f = new Buttons();
      	f.setTitle("The Choice Box");
      	f.setBounds(200,200,300,300);
	    f.setVisible(true);
	    f.setBackground(Color.white);
   }//4
   public void last_try()
{//5
public class pay[] getDeclaredMethods();
}
   public void popUp()
   				{
   					   JFrame frame = new JFrame("popUp");
   					  frame.setSize(500, 500);
   					   frame.setVisible(true);



			}

 public void orange()
   				{
   					   JFrame frame = new JFrame("orange");
   					  frame.setSize(500, 500);
   					   frame.setVisible(true);

			}






   	public void itemStateChanged(ItemEvent ie)
   	{
   		String arg = choice.getSelectedItem();

		if (arg == "Payroll Journal")
			{
				last_try();
			}


		if (arg == "Employee info")
			{
				popUp();
			}

		if (arg == "Print check and Check stubs")
			{
				orange();
			}

}//1
}
/*
	Chapter 7:	Classics on Employee
	Programmer:	J. Starks
	Date:		November 12, 2004
	Filename:	Employee.java
	Purpose:	This program creates a Swing interface for sorting a Employee collection.
*/

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import java.text.DecimalFormat;
import java.io.*;
import javax.swing.JOptionPane;
import java.lang.*;
import java.math.*;

public class last_try implements ActionListener
{//1

public static void main(String[] args)
{//2

JFrame f = new JFrame("What would you like to do");
f.setSize(400, 150);
Container content = f.getContentPane();
content.setBackground(Color.white);
content.setLayout(new FlowLayout());

JButton button1 = new JButton("Button 1");
button1.setActionCommand("button_1");

JButton button2 = new JButton("Button 2");
JButton button3 = new JButton("Button 3");

Container contentPane = f.getContentPane();
contentPane.setLayout(new FlowLayout());
contentPane.add(button1);
contentPane.add(button2);
contentPane.add(button3);

f.addWindowListener(new ExitListener());
f.setVisible(true);
}//2



public void popUp()
{//3
JFrame frame = new JFrame("aName");
frame.setSize(500, 500);
frame.setVisible(true);

}//3

public void actionPerformed(ActionEvent event)
{//4
	button1=event.getActionCommand();
if (button1.equals("Button1"))
{//5

JOptionPane.showMessageDialog(null, "Your entry was not in the proper format.");
}}}








/*
 	//construct components
 	JLabel sortPrompt = new JLabel("Sort by:");
  	JComboBox fieldCombo = new JComboBox();
	JTextPane textPane = new JTextPane();

	//initialize data in arrays
	String ID[] = {};
   	String name[] = {};
   	String Insur[] = {};
   	String strGross_Pay[] = {};
   	String strFICA[] = {};
   	String strFED[] = {};
   	String strNet_Pay[] = {};



 	//construct instance of Employee
  	public last_try()
   	{//5
      	super("Widget's Incorporated");
 	}//5

	//create the menu system
	public JMenuBar createMenuBar()
	{//6
		//create an instance of the menu
		JMenuBar mnuBar = new JMenuBar();
		setJMenuBar(mnuBar);

		//construct and populate the File menu
		JMenu mnuFile = new JMenu("File", true);
 			mnuFile.setMnemonic(KeyEvent.VK_F);
			mnuFile.setDisplayedMnemonicIndex(0);
			mnuBar.add(mnuFile);

		JMenuItem mnuFileExit = new JMenuItem("Exit");
 			mnuFileExit.setMnemonic(KeyEvent.VK_X);
			mnuFileExit.setDisplayedMnemonicIndex(1);
			mnuFile.add(mnuFileExit);
			mnuFileExit.setActionCommand("Exit");
			mnuFileExit.addActionListener(this);

		//construct and populate the Edit menu
		JMenu mnuEdit = new JMenu("Edit", true);
 			mnuEdit.setMnemonic(KeyEvent.VK_E);
			mnuEdit.setDisplayedMnemonicIndex(0);
			mnuBar.add(mnuEdit);

		JMenuItem mnuEditInsert = new JMenuItem("Insert New Employee");
 			mnuEditInsert.setMnemonic(KeyEvent.VK_I);
			mnuEditInsert.setDisplayedMnemonicIndex(0);
			mnuEdit.add(mnuEditInsert);
			mnuEditInsert.setActionCommand("Insert");
			mnuEditInsert.addActionListener(this);

		JMenu mnuEditSearch = new JMenu("Search");
 			mnuEditSearch.setMnemonic(KeyEvent.VK_R);
			mnuEditSearch.setDisplayedMnemonicIndex(3);
			mnuEdit.add(mnuEditSearch);

		JMenuItem mnuEditSearchByTitle = new JMenuItem("by Title");
 			mnuEditSearchByTitle.setMnemonic(KeyEvent.VK_T);
			mnuEditSearchByTitle.setDisplayedMnemonicIndex(3);
			mnuEditSearch.add(mnuEditSearchByTitle);
			mnuEditSearchByTitle.setActionCommand("ID");
			mnuEditSearchByTitle.addActionListener(this);

		JMenuItem mnuEditSearchByStudio = new JMenuItem("by Studio");
 			mnuEditSearchByStudio.setMnemonic(KeyEvent.VK_S);
			mnuEditSearchByStudio.setDisplayedMnemonicIndex(3);
			mnuEditSearch.add(mnuEditSearchByStudio);
			mnuEditSearchByStudio.setActionCommand("name");
			mnuEditSearchByStudio.addActionListener(this);

		JMenuItem mnuEditSearchByYear = new JMenuItem("by Year");
 			mnuEditSearchByYear.setMnemonic(KeyEvent.VK_Y);
			mnuEditSearchByYear.setDisplayedMnemonicIndex(3);
			mnuEditSearch.add(mnuEditSearchByYear);
			mnuEditSearchByYear.setActionCommand("Insur");
			mnuEditSearchByYear.addActionListener(this);

		return mnuBar;
	}//6

	//create the content pane
	public Container createContentPane()
	{//7
		//populate the JComboBox
		fieldCombo.addItem("Title");
		fieldCombo.addItem("Studio");
		fieldCombo.addItem("Year");
		fieldCombo.addActionListener(this);
		fieldCombo.setToolTipText("Click the drop-down arrow to display sort fields.");

		//construct and populate the north panel
		JPanel northPanel = new JPanel();
			northPanel.setLayout(new FlowLayout());
			northPanel.add(sortPrompt);
			northPanel.add(fieldCombo);

		//create the JTextPane and center panel
		JPanel centerPanel = new JPanel();
			setTabsAndStyles(textPane);
			textPane = addTextToTextPane();
			JScrollPane scrollPane = new JScrollPane(textPane);
				scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
				scrollPane.setPreferredSize(new Dimension(800, 400));
			centerPanel.add(scrollPane);

		//create Container and set attributes
		Container c = getContentPane();
			c.setLayout(new BorderLayout(10,10));
			c.add(northPanel,BorderLayout.NORTH);
			c.add(centerPanel,BorderLayout.CENTER);

		return c;
	}//7

	//method to create tab stops and set font styles
	protected void setTabsAndStyles(JTextPane textPane)
	{//8
		//create Tab Stops
		TabStop[] tabs = new TabStop[7];
			tabs[0] = new TabStop(100, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
			tabs[1] = new TabStop(200, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
			tabs[2] = new TabStop(350, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
			tabs[3] = new TabStop(450, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
			tabs[4] = new TabStop(475, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
			tabs[5] = new TabStop(550, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
			tabs[6] = new TabStop(625, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
		TabSet tabset = new TabSet(tabs);

		//set Tab Style
		StyleContext tabStyle = StyleContext.getDefaultStyleContext();
		AttributeSet aset =
			tabStyle.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.TabSet, tabset);
		textPane.setParagraphAttributes(aset, false);

		//set Font Style
		Style fontStyle =
			StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);

		Style regular = textPane.addStyle("regular", fontStyle);
		StyleConstants.setFontFamily(fontStyle, "SansSerif");

		Style s = textPane.addStyle("italic", regular);
		StyleConstants.setItalic(s, true);

		s = textPane.addStyle("bold", regular);
		StyleConstants.setBold(s, true);

		s = textPane.addStyle("large", regular);
		StyleConstants.setFontSize(s, 16);
	}//8

	//method to add new text to the JTextPane
   	public JTextPane addTextToTextPane()
   	{//9
   		Document doc = textPane.getDocument();

   		DecimalFormat twoDigits=new DecimalFormat("$#,000.00");

   		try
   		{//10
			//clear previous text
			doc.remove(0, doc.getLength());

			//insert ID
			doc.insertString(0,"ID\tName\tGross_Pay\tFICA\tFED\tInsur\tNet Pay\n",textPane.getStyle("large"));

			//insert detail
   		  	for (int j = 0; j<ID.length; j++)
   		  	{//11
   				doc.insertString(doc.getLength(), ID[j] + "\t", textPane.getStyle("regular"));
   				doc.insertString(doc.getLength(), name[j] + "\t", textPane.getStyle("regular"));
   				doc.insertString(doc.getLength(), strGross_Pay[j] + "\t", textPane.getStyle("regular"));
   				doc.insertString(doc.getLength(), strFICA[j] + "\t", textPane.getStyle("regular"));
   				doc.insertString(doc.getLength(), strFED[j] + "\t", textPane.getStyle("regular"));
   				doc.insertString(doc.getLength(), Insur[j] + "\t", textPane.getStyle("regular"));
   				doc.insertString(doc.getLength(), strNet_Pay[j] + "\n", textPane.getStyle("regular"));
   			}//11
   		}//10
   		catch (BadLocationException ble)
   		{//12
   			System.err.println("Couldn't insert text.");
   		}//12

   		return textPane;
   	}//9

	//event to process user clicks
   	public void actionPerformed(ActionEvent e)
   	{//13
		String arg = e.getActionCommand();

		//user clicks the sort by combo box
		if (e.getSource() == fieldCombo)
		{//14
			switch (fieldCombo.getSelectedIndex())
			{//15
				case 0:
					sort(ID);
					break;
				case 1:
					sort(name);
					break;
				case 2:
					sort(Insur);
					break;
			}//15
		}//14

		//user clicks Exit on the File menu
		if (arg == "Exit")
			System.exit(0);

		//user clicks Insert New Employee on the Edit menu
		if (arg == "Insert") // this code should be in another method called here
		{//16
			//accept new data
			String newID = JOptionPane.showInputDialog(null, "Please enter the new employee's ID");
			String newName = JOptionPane.showInputDialog(null, "Please enter their name " );
			String newInsur = JOptionPane.showInputDialog(null, "Please enter the Insurance amount " );
			String newROP = JOptionPane.showInputDialog(null, "Please enter the rate of pay " );
			String newHW = JOptionPane.showInputDialog(null, "Please enter the amount of hours worked " );
			String newDependents = JOptionPane.showInputDialog(null, "How many dependents do they claim " );

			Double HW = Double.parseDouble(newHW);
			Double RP = Double.parseDouble(newROP);
			Double Depend = Double.parseDouble(newDependents);
			Double dblInsure = Double.parseDouble(newInsur);

			Double GP = HW * RP;
			Long FICA = Math.round(GP * .0765) ;
			Double FED = Math.round(GP * Depend) * 0.15;
			Double Net_Pay = (GP - FICA - FED - dblInsure);

			String sGP = String.valueOf(GP);
			String sFICA = String.valueOf(FICA);
			String sFED = String.valueOf(FED);
			String sInsure = String.valueOf(dblInsure);
			String sNet_Pay = String.valueOf(Net_Pay);



			//enlarge arrays
			ID = enlargeArray(ID);
			name = enlargeArray(name);
			Insur = enlargeArray(Insur);
			strGross_Pay = enlargeArray(strGross_Pay);
			strFICA = enlargeArray(strFICA);
			strFED = enlargeArray(strFED);
			strNet_Pay = enlargeArray(str

Sorry wrong file


How do I load a JFrame that I made in one program when I click an option in another program. If payroll is clicked in the buttons program I want the frame from the payprogram. I really need help. I am running out of time

Attachments
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import java.text.DecimalFormat;
import java.io.*;
import javax.swing.JOptionPane;
import java.lang.*;
import java.math.*;


public class pay extends JFrame implements ActionListener
{
 	//construct components
 	JLabel sortPrompt = new JLabel("Sort by:");
  	JComboBox fieldCombo = new JComboBox();
	JTextPane textPane = new JTextPane();

	//initialize data in arrays
	String ID[] = {};
   	String name[] = {};
   	String Insur[] = {};
   	String strGross_Pay[] = {};
   	String strFICA[] = {};
   	String strFED[] = {};
   	String strNet_Pay[] = {};



 	//construct instance of Employee
  	public pay()
   	{//5
      	super("Widget's Incorporated");
 	}//5

	//create the menu system
	public JMenuBar createMenuBar()
	{//6
		//create an instance of the menu
		JMenuBar mnuBar = new JMenuBar();
		setJMenuBar(mnuBar);

		//construct and populate the File menu
		JMenu mnuFile = new JMenu("File", true);
 			mnuFile.setMnemonic(KeyEvent.VK_F);
			mnuFile.setDisplayedMnemonicIndex(0);
			mnuBar.add(mnuFile);

		JMenuItem mnuFileExit = new JMenuItem("Exit");
 			mnuFileExit.setMnemonic(KeyEvent.VK_X);
			mnuFileExit.setDisplayedMnemonicIndex(1);
			mnuFile.add(mnuFileExit);
			mnuFileExit.setActionCommand("Exit");
			mnuFileExit.addActionListener(this);

		//construct and populate the Edit menu
		JMenu mnuEdit = new JMenu("Edit", true);
 			mnuEdit.setMnemonic(KeyEvent.VK_E);
			mnuEdit.setDisplayedMnemonicIndex(0);
			mnuBar.add(mnuEdit);

		JMenuItem mnuEditInsert = new JMenuItem("Insert New Employee");
 			mnuEditInsert.setMnemonic(KeyEvent.VK_I);
			mnuEditInsert.setDisplayedMnemonicIndex(0);
			mnuEdit.add(mnuEditInsert);
			mnuEditInsert.setActionCommand("Insert");
			mnuEditInsert.addActionListener(this);

		JMenu mnuEditSearch = new JMenu("Search");
 			mnuEditSearch.setMnemonic(KeyEvent.VK_R);
			mnuEditSearch.setDisplayedMnemonicIndex(3);
			mnuEdit.add(mnuEditSearch);

		JMenuItem mnuEditSearchByTitle = new JMenuItem("by Title");
 			mnuEditSearchByTitle.setMnemonic(KeyEvent.VK_T);
			mnuEditSearchByTitle.setDisplayedMnemonicIndex(3);
			mnuEditSearch.add(mnuEditSearchByTitle);
			mnuEditSearchByTitle.setActionCommand("ID");
			mnuEditSearchByTitle.addActionListener(this);

		JMenuItem mnuEditSearchByStudio = new JMenuItem("by Studio");
 			mnuEditSearchByStudio.setMnemonic(KeyEvent.VK_S);
			mnuEditSearchByStudio.setDisplayedMnemonicIndex(3);
			mnuEditSearch.add(mnuEditSearchByStudio);
			mnuEditSearchByStudio.setActionCommand("name");
			mnuEditSearchByStudio.addActionListener(this);

		JMenuItem mnuEditSearchByYear = new JMenuItem("by Year");
 			mnuEditSearchByYear.setMnemonic(KeyEvent.VK_Y);
			mnuEditSearchByYear.setDisplayedMnemonicIndex(3);
			mnuEditSearch.add(mnuEditSearchByYear);
			mnuEditSearchByYear.setActionCommand("Insur");
			mnuEditSearchByYear.addActionListener(this);

		return mnuBar;
	}//6

	//create the content pane
	public Container createContentPane()
	{//7
		//populate the JComboBox
		fieldCombo.addItem("Title");
		fieldCombo.addItem("Studio");
		fieldCombo.addItem("Year");
		fieldCombo.addActionListener(this);
		fieldCombo.setToolTipText("Click the drop-down arrow to display sort fields.");

		//construct and populate the north panel
		JPanel northPanel = new JPanel();
			northPanel.setLayout(new FlowLayout());
			northPanel.add(sortPrompt);
			northPanel.add(fieldCombo);

		//create the JTextPane and center panel
		JPanel centerPanel = new JPanel();
			setTabsAndStyles(textPane);
			textPane = addTextToTextPane();
			JScrollPane scrollPane = new JScrollPane(textPane);
				scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
				scrollPane.setPreferredSize(new Dimension(800, 400));
			centerPanel.add(scrollPane);

		//create Container and set attributes
		Container c = getContentPane();
			c.setLayout(new BorderLayout(10,10));
			c.add(northPanel,BorderLayout.NORTH);
			c.add(centerPanel,BorderLayout.CENTER);

		return c;
	}//7

	//method to create tab stops and set font styles
	protected void setTabsAndStyles(JTextPane textPane)
	{//8
		//create Tab Stops
		TabStop[] tabs = new TabStop[7];
			tabs[0] = new TabStop(100, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
			tabs[1] = new TabStop(200, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
			tabs[2] = new TabStop(350, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
			tabs[3] = new TabStop(450, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
			tabs[4] = new TabStop(475, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
			tabs[5] = new TabStop(550, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
			tabs[6] = new TabStop(625, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
		TabSet tabset = new TabSet(tabs);

		//set Tab Style
		StyleContext tabStyle = StyleContext.getDefaultStyleContext();
		AttributeSet aset =
			tabStyle.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.TabSet, tabset);
		textPane.setParagraphAttributes(aset, false);

		//set Font Style
		Style fontStyle =
			StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);

		Style regular = textPane.addStyle("regular", fontStyle);
		StyleConstants.setFontFamily(fontStyle, "SansSerif");

		Style s = textPane.addStyle("italic", regular);
		StyleConstants.setItalic(s, true);

		s = textPane.addStyle("bold", regular);
		StyleConstants.setBold(s, true);

		s = textPane.addStyle("large", regular);
		StyleConstants.setFontSize(s, 16);
	}//8

	//method to add new text to the JTextPane
   	public JTextPane addTextToTextPane()
   	{//9
   		Document doc = textPane.getDocument();

   		DecimalFormat twoDigits=new DecimalFormat("$#,000.00");

   		try
   		{//10
			//clear previous text
			doc.remove(0, doc.getLength());

			//insert ID
			doc.insertString(0,"ID\tName\tGross_Pay\tFICA\tFED\tInsur\tNet Pay\n",textPane.getStyle("large"));

			//insert detail
   		  	for (int j = 0; j<ID.length; j++)
   		  	{//11
   				doc.insertString(doc.getLength(), ID[j] + "\t", textPane.getStyle("regular"));
   				doc.insertString(doc.getLength(), name[j] + "\t", textPane.getStyle("regular"));
   				doc.insertString(doc.getLength(), strGross_Pay[j] + "\t", textPane.getStyle("regular"));
   				doc.insertString(doc.getLength(), strFICA[j] + "\t", textPane.getStyle("regular"));
   				doc.insertString(doc.getLength(), strFED[j] + "\t", textPane.getStyle("regular"));
   				doc.insertString(doc.getLength(), Insur[j] + "\t", textPane.getStyle("regular"));
   				doc.insertString(doc.getLength(), strNet_Pay[j] + "\n", textPane.getStyle("regular"));
   			}//11
   		}//10
   		catch (BadLocationException ble)
   		{//12
   			System.err.println("Couldn't insert text.");
   		}//12

   		return textPane;
   	}//9

	//event to process user clicks
   	public void actionPerformed(ActionEvent e)
   	{//13
		String arg = e.getActionCommand();

		//user clicks the sort by combo box
		if (e.getSource() == fieldCombo)
		{//14
			switch (fieldCombo.getSelectedIndex())
			{//15
				case 0:
					sort(ID);
					break;
				case 1:
					sort(name);
					break;
				case 2:
					sort(Insur);
					break;
			}//15
		}//14

		//user clicks Exit on the File menu
		if (arg == "Exit")
			System.exit(0);

		//user clicks Insert New Employee on the Edit menu
		if (arg == "Insert") // this code should be in another method called here
		{//16
			//accept new data
			String newID = JOptionPane.showInputDialog(null, "Please enter the new employee's ID");
			String newName = JOptionPane.showInputDialog(null, "Please enter their name " );
			String newInsur = JOptionPane.showInputDialog(null, "Please enter the Insurance amount " );
			String newROP = JOptionPane.showInputDialog(null, "Please enter the rate of pay " );
			String newHW = JOptionPane.showInputDialog(null, "Please enter the amount of hours worked " );
			String newDependents = JOptionPane.showInputDialog(null, "How many dependents do they claim " );

			Double HW = Double.parseDouble(newHW);
			Double RP = Double.parseDouble(newROP);
			Double Depend = Double.parseDouble(newDependents);
			Double dblInsure = Double.parseDouble(newInsur);

			Double GP = HW * RP;
			Long FICA = Math.round(GP * .0765) ;
			Double FED = Math.round(GP * Depend) * 0.15;
			Double Net_Pay = (GP - FICA - FED - dblInsure);

			String sGP = String.valueOf(GP);
			String sFICA = String.valueOf(FICA);
			String sFED = String.valueOf(FED);
			String sInsure = String.valueOf(dblInsure);
			String sNet_Pay = String.valueOf(Net_Pay);



			//enlarge arrays
			ID = enlargeArray(ID);
			name = enlargeArray(name);
			Insur = enlargeArray(Insur);
			strGross_Pay = enlargeArray(strGross_Pay);
			strFICA = enlargeArray(strFICA);
			strFED = enlargeArray(strFED);
			strNet_Pay = enlargeArray(strNet_Pay);

			//add new data to arrays
			ID[ID.length-1] = newID;
			name[name.length-1] = newName;
			Insur[Insur.length-1] = newInsur;
			strGross_Pay[strGross_Pay.length-1] = sGP;
			strFICA[strFICA.length-1] = sFICA;
			strFED[strFED.length-1] = sFED;
			strNet_Pay[strNet_Pay.length-1] = sNet_Pay;

			//call sort method
			sort(ID);
			fieldCombo.setSelectedIndex(0);
		}//16

		//user clicks Title on the Search submenu
		if (arg == "ID")
			search(arg, ID);

		//user clicks Studio on the Search submenu
		if (arg == "name")
			search(arg, name);

		//user clicks Year on the Search submenu
		if (arg == "Insur")
			search(arg, Insur);
	}//13

	//method to enlarge an array by 1
	public String[] enlargeArray(String[] currentArray)
	{//17
		String[] newArray = new String[currentArray.length + 1];
		for(int i = 0; i<currentArray.length; i++)
			newArray[i] = currentArray[i];
		return newArray;
	}//17

	//method to sort arrays
	public void sort(String tempArray[])
	{//18
		// loop to control number of passes
		for (int pass = 1; pass < tempArray.length; pass++)
		{//19
			for (int element = 0; element < tempArray.length - 1; element++)
				if (tempArray[element].comp

These are some pretty long files. Don't have time to look at them right now, but will have time later today. Consider copying and pasting them (preferably an abridged version) into a post. To use code tags, do this:

[code=JAVA] // paste your code here

[/code]

This will highlight the JAVA syntax and give line numbers to refer to. If you can refer to specific parts of the program and what you are trying to do that is not working, that will help and you'll get more people viewing it. I will check back in later today.

I could have sworn I posted within the last half hour. Must have just hit the preview or left the page before giving the system a chance to register the new post. Okay, I just want to make sure that we're talking about Buttons.java and pay.java and that last_try.java is irrelevant to this thread. And are you still having the problem and are the files still the same?

This article has been dead for over six months. Start a new discussion instead.