Need help with "load file" in GUI

My program compiles correctly, and the GUI is displayed with all the right data. My problem is when I hit the "load file" button on the GUI nothing happens and then I receive a handfull of runtime errors.

Please look at my code as see if you can see what I am doing wrong.

if (btnClicked.equals("Load File"))

{

isRecordLoadedFromFile =true;

if (GetRecordCount() == 0)

{

JOptionPane.showMessageDialog(null,"No Records Found in the File");

}

else

{

showInventory(0);

}

}

if (btnClicked.equals("Cancel"))

{

EnableFields(false);

cmdbutton[4].setText("Search");

cmdbutton[2].setText("Modify");

cmdbutton[1].setText("Add");

if(isRecordLoadedFromFile)

showInventory(navItem);

else

ShowInventory(navItem);

}

Here are my errors that pop up on NetBeans when I hit the "load file" button on my GUI:

init:

deps-jar:

Compiling 1 source file to C:\Inventory\build\classes

compile:

run:

Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "Massacre"

at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)

at java.lang.Integer.parseInt(Integer.java:447)

at java.lang.Integer.parseInt(Integer.java:497)

at inventorymain.DVD.showInventory(DVD.java:378)

at inventorymain.DVD.actionPerformed(DVD.java:521)

at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)

at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)

at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)

at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)

at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)

at java.awt.Component.processMouseEvent(Component.java:6038)

at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)

at java.awt.Component.processEvent(Component.java:5803)

at java.awt.Container.processEvent(Container.java:2058)

at java.awt.Component.dispatchEventImpl(Component.java:4410)

at java.awt.Container.dispatchEventImpl(Container.java:2116)

at java.awt.Component.dispatchEvent(Component.java:4240)

at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)

at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)

at java.awt.Container.dispatchEventImpl(Container.java:2102)

at java.awt.Window.dispatchEventImpl(Window.java:2429)

at java.awt.Component.dispatchEvent(Component.java:4240)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)

at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)

at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

If anyone could offer any help or guidance it would be appreciated. Thank you!!

[4064 byte] By [bill456a] at [2007-11-27 10:38:10]
# 1

Can you post the rest of the code you have?

Somewhere along the line you are trying to pass a String to some code which is expecting a numeric value. You have "Massacre" somewhere and you maybe are trying to parse it as a numeric value which obviously will not work.

_helloWorld_a at 2007-7-28 18:52:47 > top of Java-index,Java Essentials,Java Programming...
# 2

I sure can; it is a long file, but here it is. If you need my InventoryMain.java or Inventory.java please let me know. This is the complete DVD.java

package inventorymain;//file assigned to package

import javax.swing.JFrame;

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

import java.io.*;

import java.text.NumberFormat;

import javax.swing.border.*;

import java.net.*;

import java.util.StringTokenizer;

class DVD extends Inventory implements ActionListener

{ // Begin DVD Class

static String genre[] = new String[100];// Subclass to add to DVD Movie

static String dvdRating[] = new String[100];

static double restockingFee[] = new double[100];// Restock fee to add to inventory value

static int i;

static double TotalVal;

static int navItem;

static Boolean isRecordLoadedFromFile = false;

private Container cp = getContentPane();

GridBagConstraints c;

GridBagConstraints cconstraint ;

Border titledborder;

JPanel pan;

String labels[] ={"Index:","Genre:", "Item Number:", "Name:","Rating:", "Units in Stock:",

"Price: $",

"Restocking Fee (5%):$",

"Inventory value (with 5% fee) for this DVD: $",

"Value (with 5% fee) for all DVDs):$" };

int len1 = labels.length;

JLabel lbl[] = new JLabel[len1];

JTextField txtfield1[] = new JTextField[len1];

String blabels[] ={ "First", "Previous", "Next", "Last" };

int blen = blabels.length;

JButton navigate[] = new JButton[blen];

String cmdlabels[] ={"Load File", "Add", "Modify", "Delete", "Search", "Save","Cancel" };

int cmdlen = cmdlabels.length;

JButton cmdbutton[] = new JButton[cmdlen];

JLabel lblImg;

File file;

public String FileName;

public DVD(String Genre,String rating, double restockingFee, int Item_Number, String Item_Name, int Items_in_Stock,

double Item_Price)

{

super(Item_Number, Item_Name, Items_in_Stock, Item_Price);

this.genre[i] = Genre;

this.dvdRating[i] = rating;

this.restockingFee[i] = restockingFee;

i = i + 1;

}

public String toString()

{

StringBuffer sb = new StringBuffer("\nGenre: ").append(genre).append("\n");

sb.append(super.toString());

return sb.toString();

}

public static double getRestockFee(int val)

{

return restockingFee[val];

}

public static void setRating(int k,String value)

{

dvdRating[k] = value;

}

public static void DeleteDVDItem(int k)

{

for(int j=k;j<getCount()-1;j++)

{

setRating(j,dvdRating[j+1]);

}

i=i-1;

}

public void ShowInvent()

{

setLayout(new FlowLayout());

GridBagLayout contlayout = new GridBagLayout();//Layout for container

GridBagConstraints cconstraint = new GridBagConstraints();//constraint for container

GridBagLayout gblayout = new GridBagLayout();//Layout for panel

GridBagConstraints gbconstraint = new GridBagConstraints();

FileName = "C:/data/inventory.dat";

try

{

String strDirectoy = "C:/data";

boolean success = (new File(strDirectoy)).mkdir();

file = new File(FileName);

success = file.createNewFile();

//ADD SAVE CANCEL DELETE EXIT

pan = new JPanel();

gblayout = new GridBagLayout();

gbconstraint = new GridBagConstraints();

pan.setLayout(gblayout);

gbconstraint.gridwidth = 1;

gbconstraint.gridheight = 1;

gbconstraint.gridy = 0;

for (int i = 0; i >< cmdlen; i++)

{

cmdbutton[i] = new JButton(cmdlabels[i]);

cmdbutton[i].addActionListener(this);

gbconstraint.gridx = i;

pan.add(cmdbutton[i], gbconstraint);

}

titledborder = BorderFactory.createTitledBorder("Modifications");

pan.setBorder(titledborder);

//ADD PANEL TO CONTAINER

cconstraint.gridwidth = 4;

cconstraint.gridheight = 1;

cconstraint.gridx = 0;

cconstraint.gridy = 2;

cp.add(pan, cconstraint);

//ADDITION COMPLETE

//CREATE First PANEL

pan = new JPanel();

gblayout = new GridBagLayout();

gbconstraint = new GridBagConstraints();

pan.setLayout(gblayout);

for (int i = 0; i < 2; i++)

{

for (int j = 0; j < len1; j++)

{

int x = i;

int y = j;

if (x == 0)

{

lbl[j] = new JLabel(labels[j]);

lbl[j].setHorizontalAlignment(JLabel.LEFT);

lbl[j].setPreferredSize(new Dimension(250, 15));

gbconstraint.insets = new Insets(10, 0, 0, 0);

gbconstraint.gridx = x;

gbconstraint.gridy = y;

pan.add(lbl[j], gbconstraint);

}

else

{

txtfield1[j] = new JTextField(15);

//txtfield1[j].setPreferredSize(new Dimension(300, 15));

txtfield1[j].setHorizontalAlignment(JLabel.LEFT);

txtfield1[j].setEnabled(false);

lbl[j].setLabelFor(txtfield1[j]);

gbconstraint.gridx = x;

gbconstraint.gridy = y;

pan.add(txtfield1[j], gbconstraint);

}

}

}

Border titledborder = BorderFactory.createTitledBorder("Current DVD Inventory");

pan.setBorder(titledborder);

//ADD PANEL TO CONTAINER

cconstraint.gridwidth = 1;

cconstraint.gridheight = 1;

cconstraint.gridx = 0;

cconstraint.gridy = 0;

cp.add(pan, cconstraint);

//FIRST PANEL ADDED.

//ADDING IMAGE TO THE PANEL

pan = new JPanel();

gblayout = new GridBagLayout();

gbconstraint = new GridBagConstraints();

pan.setLayout(gblayout);

gbconstraint.gridwidth = 1; gbconstraint.gridheight = 1;

gbconstraint.gridy = 0;

lblImg = new JLabel((new ImageIcon(getClass().getResource("logo.jpg"))));

lblImg.setPreferredSize(new Dimension(70 , 70));

pan.add(lblImg);

cconstraint.gridwidth = 1;

cconstraint.gridheight = 1;

cconstraint.gridx = 0;

cconstraint.gridy = 1;

cp.add(pan, cconstraint);

//IMAGE ADDED

//CREATE NAVIGATION PANEL

pan = new JPanel();

gblayout = new GridBagLayout();

gbconstraint = new GridBagConstraints();

pan.setLayout(gblayout);

gbconstraint.gridwidth = 1; gbconstraint.gridheight = 1;

gbconstraint.gridy = 0;

for (int i = 0; i < blen; i++)

{

navigate[i] = new JButton(blabels[i]);

gbconstraint.gridx = i;

pan.add(navigate[i], gbconstraint);

navigate[i].addActionListener(this);

}

titledborder = BorderFactory.createTitledBorder("Navigation");

pan.setBorder(titledborder);

//ADD PANEL TO CONTAINER

cconstraint.gridwidth = 4;

cconstraint.gridheight = 1;

cconstraint.gridx = 1;

cconstraint.gridy = 1;

cp.add(pan, cconstraint);

//ADDITION COMPLETE

}

catch (Exception e)

{

e.printStackTrace();

}

}

public void setContents(File aFile, String aContents)

{

BufferedWriter output = null;

try

{

//use buffering

//FileWriter always assumes default encoding is OK!

output = new BufferedWriter(new FileWriter(aFile, true));

output.write(aContents);

String newLine = System.getProperty("line.separator");

output.write(newLine);

}

catch (Exception ex)

{

ex.printStackTrace();

}

finally

{

try

{

//flush and close both "output" and its underlying FileWriter

if (output != null) output.close();

}

catch (java.io.IOException e)

{

e.printStackTrace();

}

}

}

public void AddModifyInventory(String Mode)

{

if (Mode.equals("Insert"))

{

String Content = txtfield1[1].getText() + "\t" + txtfield1[2].getText() + "\t" + txtfield1[3].getText() + "\t" + txtfield1[4].getText() + "\t" + txtfield1[5].getText() + "\t" + txtfield1[6].getText();

setContents(file, Content);

JOptionPane.showMessageDialog(null, "Record Successfully Inserted");

}

}

public void ShowInventory(int ItemNo)

{

txtfield1[0].setText(Integer.toString(ItemNo));

txtfield1[1].setText(genre[ItemNo]);

txtfield1[2].setText(Integer.toString(Inventory.getItemNum(ItemNo)));

txtfield1[3].setText(Inventory.getItemName(ItemNo));

txtfield1[4].setText(dvdRating[ItemNo]);

txtfield1[5].setText(Integer.toString(Inventory.getItemUnits(ItemNo)));

txtfield1[6].setText(Double.toString(Inventory.getItemPrice(ItemNo)));

txtfield1[7].setText(String.format("%3.2f", Products.valueOfRestockFee(Inventory.getItemPrice(ItemNo), getRestockFee(ItemNo))));

txtfield1[8].setText(String.format("%3.2f", Products.valueOfInventory(Inventory.getItemPrice(ItemNo), Inventory.getItemUnits(ItemNo), getRestockFee(ItemNo))));

txtfield1[9].setText(String.format("%3.2f",GetTotalInvVal()));

}

public void EnableFields(boolean bflag)

{

//txtfield1[0].setEnabled(bflag);

txtfield1[1].setEnabled(bflag);

txtfield1[2].setEnabled(bflag);

txtfield1[3].setEnabled(bflag);

txtfield1[4].setEnabled(bflag);

txtfield1[5].setEnabled(bflag);

txtfield1[6].setEnabled(bflag);

}

public double GetTotalInvVal()

{

TotalVal = 0;

for (int j = 0; j < Inventory.getCount(); j++)

{

TotalVal += Products.valueOfInventory(Inventory.getItemPrice(j), Inventory.getItemUnits(j), getRestockFee(j));

}

return TotalVal;

}

public Integer GetRecordCount()

{

FileReader fr;

BufferedReader br;

LineNumberReader lnr;

String line;

int lno = 0;

try

{

lnr = new LineNumberReader(new BufferedReader(new FileReader(FileName)));

while ((line = lnr.readLine()) != null)

{

lno = lnr.getLineNumber();

}

lnr.close();

}

catch (IOException ioErr)

{

System.out.println(ioErr.toString());

System.exit(100);

}

return lno;

}

public void showInventory(int itemNo)

{

int i;

FileReader fr;

BufferedReader br;

LineNumberReader lnr;

StringTokenizer st;

String line;

int item = itemNo + 1;

int ItemNo = 0;

int Units = 0;

String ItemGenre = "";

String ItemName = "";

String ItemRating = "";

double UnitPrice = 0;

double Total = 0;

Integer rFee = 0;

int lno;

try

{

lnr = new LineNumberReader(new BufferedReader(new FileReader(FileName)));

while ((line = lnr.readLine()) != null)

{

lno = lnr.getLineNumber();

String s1[];

if (item == lno)

{

s1 = new String[lno];

s1[0] = line;

st = new StringTokenizer(s1[0]);

//ItemNo = lno;

ItemGenre = st.nextToken();

ItemNo = Integer.parseInt(st.nextToken());

ItemName = st.nextToken();

ItemRating = st.nextToken();

Units = Integer.parseInt(st.nextToken());

UnitPrice = Double.parseDouble(st.nextToken());

//rFee = Integer.parseInt(st.nextToken());

}

s1 = new String[lno];

s1[0] = line;

st = new StringTokenizer(s1[0]);

st.nextToken();

st.nextToken();

st.nextToken();

st.nextToken();

Integer units = Integer.parseInt(st.nextToken());

Double price = Double.parseDouble(st.nextToken());

Total += Products.valueOfInventory(price, units, 0.05);

}

lnr.close();

}

catch (IOException ioErr)

{

System.out.println(ioErr.toString());

System.exit(100);

}

txtfield1[0].setText(Integer.toString(itemNo));

txtfield1[1].setText(ItemGenre);

txtfield1[2].setText(Integer.toString(ItemNo));

txtfield1[3].setText(ItemName);

txtfield1[4].setText(ItemRating);

txtfield1[5].setText(Integer.toString(Units));

txtfield1[6].setText(Double.toString(UnitPrice));

txtfield1[7].setText(String.format("%3.2f", Products.valueOfRestockFee(UnitPrice, 0.05)));

txtfield1[8].setText(String.format("%3.2f", Products.valueOfInventory(UnitPrice, Units, 0.05)));

txtfield1[9].setText(String.format("%3.2f", Total));

}

public void actionPerformed(ActionEvent e) // button navigation

{

String btnClicked = ((JButton)e.getSource()).getText();

if(btnClicked.equals("First"))

{

EnableFields(false);

if (isRecordLoadedFromFile)

{

navItem = 0;

showInventory(navItem);

}

else

{

navItem = 0;

ShowInventory(navItem);

}

}

if (btnClicked.equals("Next"))

{

EnableFields(false);

if (isRecordLoadedFromFile)

{

if (navItem == GetRecordCount() - 1)

{

navItem = 0;

}

else

{

navItem += 1;

}

if ((GetRecordCount() - 1) >= navItem)

showInventory(navItem);

else

showInventory(GetRecordCount() - 1);

}

else

{

if (navItem == getCount() - 1)

{

navItem = 0;

}

else

{

navItem += 1;

}

ShowInventory(navItem);

}

}

if (btnClicked.equals("Previous"))

{

EnableFields(false);

if (isRecordLoadedFromFile)

{

if (navItem == 0)

{

navItem = GetRecordCount() - 1;

}

else

{

navItem = navItem - 1;

}

showInventory(navItem);

}

else

{

if (navItem == 0)

{

navItem = getCount() - 1;

}

else

{

navItem = navItem - 1;

}

ShowInventory(navItem);

}

}

if (btnClicked.equals("Last"))

{

EnableFields(false);

if (isRecordLoadedFromFile)

{

navItem = GetRecordCount() - 1;

showInventory(navItem);

}

else

{

navItem = getCount() - 1;

ShowInventory(navItem);

}

}

if (btnClicked.equals("Save"))

{

AddModifyInventory("Insert");

}

if (btnClicked.equals("Load File"))

{

isRecordLoadedFromFile = true;

if (GetRecordCount() == 0)

{

JOptionPane.showMessageDialog(null, "No Records Found in the File");

}

else

{

showInventory(0);

}

}

if (btnClicked.equals("Cancel"))

{

EnableFields(false);

cmdbutton[4].setText("Search");

cmdbutton[2].setText("Modify");

cmdbutton[1].setText("Add");

if(isRecordLoadedFromFile)

showInventory(navItem);

else

ShowInventory(navItem);

}

if(btnClicked.equals("Delete"))

{

Inventory.DeleteItem(Integer.parseInt(txtfield1[0].getText()));

navItem = getCount() -1;

JOptionPane.showMessageDialog(null, "Record Successfully deleted");

ShowInventory(navItem);

}

if(btnClicked.equals("Search"))

{

cmdbutton[4].setText("GO!");

txtfield1[3].setEnabled(true);

}

if(btnClicked.equals("GO!"))

{

boolean valid = true;

if (txtfield1[3].getText().trim().length() == 0)

{

JOptionPane.showMessageDialog(null, "Product Name Required");

valid = false;

}

if(valid)

{

int k = Inventory.SearchItem(txtfield1[3].getText().trim());

if(k>=0)

{

txtfield1[0].setText(Integer.toString(k));

txtfield1[1].setText(genre[k]);

txtfield1[2].setText(Integer.toString(Inventory.getItemNum(k)));

txtfield1[3].setText(Inventory.getItemName(k));

txtfield1[4].setText(dvdRating[k]);

txtfield1[5].setText(Integer.toString(Inventory.getItemUnits(k)));

txtfield1[6].setText(Double.toString(Inventory.getItemPrice(k)));

txtfield1[7].setText(String.format("%3.2f", Products.valueOfRestockFee(Inventory.getItemPrice(k), getRestockFee(k))));

txtfield1[8].setText(String.format("%3.2f", Products.valueOfInventory(Inventory.getItemPrice(k ), Inventory.getItemUnits(k), getRestockFee(k))));

txtfield1[9].setText(String.format("%3.2f",GetTotalInvVal()));

EnableFields(false);

cmdbutton[4].setText("Search");

}

else

{

JOptionPane.showMessageDialog(null, "No Matches found");

cmdbutton[4].setText("Search");

EnableFields(false);

}

}

}

if(btnClicked.equals("Modify"))

{

EnableFields(true);

cmdbutton[2].setText("Click to Modify!");

}

if(btnClicked.equals("Click to Modify!"))

{

Boolean valid = true;

if (txtfield1[1].getText().trim().length() == 0)

{

JOptionPane.showMessageDialog(null, "Genre Required");

valid = false;

}

try

{

Integer.parseInt(txtfield1[2].getText());

}

catch (Exception ex)

{

JOptionPane.showMessageDialog(null, "Invalid Item Number (use numbers only)");

txtfield1[3].setText("");

valid = false;

}

if (txtfield1[3].getText().trim().length() == 0)

{

JOptionPane.showMessageDialog(null, "Product Name Required");

valid = false;

}

if (txtfield1[4].getText().trim().length() == 0)

{

JOptionPane.showMessageDialog(null, "Rating Required");

valid = false;

}

try

{

Integer.parseInt(txtfield1[5].getText());

}

catch (Exception ex)

{

JOptionPane.showMessageDialog(null, "Invalid Units in Stock (use numbers only)");

txtfield1[4].setText("");

valid = false;

}

try

{

Double.parseDouble(txtfield1[6].getText());

}

catch (Exception ex)

{

JOptionPane.showMessageDialog(null, "Invalid Price (use numbers only)");

txtfield1[5].setText("");

valid = false;

}

if (valid)

{

//setItemNum,setItemName,setItemUnits,setItemPrice

Inventory.setItemNum(navItem,Integer.parseInt(txtfield1[1].getText()));

Inventory.setItemName(navItem,txtfield1[2].getText());

DVD.setRating(navItem,txtfield1[3].getText());

Inventory.setItemUnits(navItem,Integer.parseInt(txtfield1[4].getText()));

Inventory.setItemPrice(navItem,Double.parseDouble(txtfield1[5].getText()));

txtfield1[6].setText(String.format("%3.2f", Products.valueOfRestockFee(Inventory.getItemPrice(navItem), getRestockFee(navItem))));

txtfield1[7].setText(String.format("%3.2f", Products.valueOfInventory(Inventory.getItemPrice(navItem ), Inventory.getItemUnits(navItem), getRestockFee(navItem))));

txtfield1[8].setText(String.format("%3.2f",GetTotalInvVal()));

EnableFields(false);

cmdbutton[2].setText("Modify");

}

}

if (btnClicked.equals("Add"))

{

EnableFields(true);

txtfield1[0].setText(Integer.toString(getCount()));

txtfield1[1].requestFocus();

txtfield1[1].setText("");

txtfield1[2].setText("");

txtfield1[3].setText("");

txtfield1[4].setText("");

txtfield1[5].setText("0");

txtfield1[6].setText("0.00");

cmdbutton[1].setText("Click to Add!");

}

if (btnClicked.equals("Click to Add!"))

{

Boolean valid = true;

if (txtfield1[1].getText().trim().length() == 0)

{

JOptionPane.showMessageDialog(null, "Genre Required");

valid = false;

}

try

{

Integer.parseInt(txtfield1[2].getText());

}

catch (Exception ex)

{

JOptionPane.showMessageDialog(null, "Invalid Item Number (Only Numbers allowed)");

txtfield1[3].setText("");

valid = false;

}

if (txtfield1[3].getText().trim().length() == 0)

{

JOptionPane.showMessageDialog(null, "Product Name Required");

valid = false;

}

if (txtfield1[4].getText().trim().length() == 0)

{

JOptionPane.showMessageDialog(null, "Rating Required");

valid = false;

}

try

{

Integer.parseInt(txtfield1[5].getText());

}

catch (Exception ex)

{

JOptionPane.showMessageDialog(null, "Invalid Units in Stock (Only Numbers allowed)");

txtfield1[4].setText("");

valid = false;

}

try

{

Double.parseDouble(txtfield1[6].getText());

}

catch (Exception ex)

{

JOptionPane.showMessageDialog(null, "Invalid Price (Only Numbers allowed)");

txtfield1[5].setText("");

valid = false;

}

if (valid)

{

DVD r = new DVD(txtfield1[1].getText(),txtfield1[4].getText(), 0.05, Integer.parseInt(txtfield1[2].getText()), txtfield1[3].getText(), Integer.parseInt(txtfield1[5].getText()),

Double.parseDouble(txtfield1[6].getText()));

txtfield1[7].setText(String.format("%3.2f", Products.valueOfRestockFee(Inventory.getItemPrice(getCount() - 1), getRestockFee(getCount() - 1))));

txtfield1[8].setText(String.format("%3.2f", Products.valueOfInventory(Inventory.getItemPrice(getCount() -1 ), Inventory.getItemUnits(getCount() -1), getRestockFee(getCount() - 1))));

txtfield1[9].setText(String.format("%3.2f",GetTotalInvVal()));

navItem = getCount() - 1;

EnableFields(false);

cmdbutton[1].setText("Add");

}

}

}

} // End DVD Class

bill456a at 2007-7-28 18:52:47 > top of Java-index,Java Essentials,Java Programming...
# 3

What I recommend you do for this problem (and for

all of your future coding actually) is to take the

problem out of the GUI and work on it in its own little

separate command-line program.

What I mean is to create a new small program, you

can call it LoadFile, and work out all the mechanics

of loading a file, and testing to see that it is loaded correctly.

This program could have its own main method that

tests all of the class's methods.

Once you have done this and it is working, then use

this newly created class in your GUI project. You'll

have to create a variable of this class, construct it,

and then call its methods to load your file in a way

that GUI can use.

This can make debugging and maintanance much

much easier. Plus if you have a problem in the

future, you can post a small fully contained app that

will demonstrate the problem rather than a portion of

a GUI app that has tons of extraneous code that

doesn't help us or you solve your problem.

Good luck!

petes1234a at 2007-7-28 18:52:47 > top of Java-index,Java Essentials,Java Programming...