New to Java. I am trying to display the contents of my ArrayList. In the ArrayList are objects based off the Class PalletLocations. If I loop through the ArrayList I just get the object name/location (not sure what it is). For example "wms.PalletLocations@30fc1f".

ArrayList<PalletLocations> palletLocList = new ArrayList<PalletLocations>();

PalletLocations palLoc = new PalletLocations();
palLoc.addPalletLocation(palletText.getText(), rsPallets.getString("LOCATION"),rsPallets.getLong("QTY"), rsPallets.getString("ITEM_NO"));
palletLocList.add(palLoc);

for (int i = 0; i < palletLocList.size(); i++) {
	System.out.println(palletLocList.get(i));
}
public class PalletLocations {
	public static String palletNbr;
	public static String location;
	public static long qty;
	public static String itemNbr;
	
	public void addPalletLocation(String sPalletNbr, String sLocation, long lQty, String sItemNbr) {
		palletNbr = sPalletNbr;
		location = sLocation;
	    qty = lQty;
	    itemNbr = sItemNbr;
	}
}

Thanks for the help.

You are getting the default toString() when you call System.out.println() of the PalletLocations object. You must explicitly write your own toString() or expand the call of System.out.println() to display all the object infos you want to display.

I made this change, but it will only display the last object in the array, multiple times.

So if I have two ojbects in the array with QTY = 10, first one, and QTY 12 for the second one, it will display "12 12". Do I still need your suggestion of toString();

for (int i = 0; i < palletLocList.size(); i++) {
  System.out.println(PalletLocations.qty);
}

thanks!

display the last object in the array, multiple times.

It should do it palletLocList.size() times as you have coded in the for loop.
It doesn't look in the array at all. It uses the static variable's value for the class.
Because you have the variables static, there is only ONE copy of them. Remove the static modifier for all the variables in the class.

need your suggestion of toString()

You need to add the method: public String toString() { <your code here> }
to the PalletLocations class.

Edited 6 Years Ago by NormR1: n/a

I still have the issue of getting a particular item from the arraylist. When I run my while loop code, I have added two palLoc objects to palletLocList. When I go through the

if (fromComboBox.getItemCount() > 0 ) {

piece, the setText should be set to the first object's location. It currently sets it to the second location, which is the last one added to the list. How do I point to specifiy object in the arraylist?

PalletLocations palLoc = new PalletLocations();

if (rsPallets.first()){
bPalletFound = true;
while (rsPallets.isAfterLast() == false) {
if (rsPallets.getLong("QTY") > 0) {
palLoc.addPalletLocation(palletText.getText(), rsPallets.getString("LOCATION"),rsPallets.getLong("QTY"), rsPallets.getString("ITEM_NO"));
palletLocList.add(palLoc);
sPalletItemNo = rsPallets.getString("ITEM_NO");
fromComboBox.addItem(palLoc.location + " " + palLoc.qty);
lPalletLocations = lPalletLocations + 1;
}
rsPallets.next();
}

if (fromComboBox.getItemCount() > 0 ) {
qtyText.setText(palLoc.location);
}
public class PalletLocations {
	public String palletNbr;
	public String location;
	public long qty;
	public String itemNbr;
	
	public void addPalletLocation(String sPalletNbr, String sLocation, long lQty, String sItemNbr) {
		palletNbr = sPalletNbr;
		location = sLocation;
	    qty = lQty;
	    itemNbr = sItemNbr;
	}
	
	public String toString() {
	       return location;
    }

}

Thanks for all the help.

Edited 6 Years Ago by cjmartin: n/a

How do I point to specifiy object in the arraylist?

Does the ArrayList class have any methods to do what you want?
What does "point to" mean? Have the index of an entry?

All I need for the arraylist is to keep a collection of data. So I have a Location and for a particular Location it has 4 properties (palletNbr, location, qty, itemNbr). I am assuming the arraylist is what I need for this (I come from a VB background and am basing this off of a collection of Types). Then I need to be able to access particular Locations and retrieve its properties. So when I say "point to" I mean how do I retrieve data from a particular Location in the arraylist? For example I have 3 Locations, with its 5 properties, how do I retrieve the data from the 2nd one. If I was using an array I would use like aPallets[2].Location or something similar I believe. So yes, like having the index.

Well, my boss had me working on other projects so I just started this one back up this morning. I am still at the same point, trying to determine how to get a specific piece of data from a specific item in my arraylist. I have code that adds a collection of items to the arraylist. Then I want to pull out certain pieces of info based on a certain item in the collection. Though it just seems that I only get the last item added. I don't know how to retrieve info from the other items. For example, when I am doing this, qtyText.setText(palletLocList.get(0).qty);, it seems to only pull the data from the last record added to the arraylist entered and not the first as I would expect.

My latest code:

PalletLocations palLoc = new PalletLocations();

if (rsPallets.first()){
	bPalletFound = true;

  while (rsPallets.isAfterLast() == false) {
    if (rsPallets.getLong("QTY") > 0) {
      palLoc.addPalletLocation(palletText.getText(), rsPallets.getString 
       ("LOCATION"),rsPallets.getString("QTY"), rsPallets.getString("ITEM_NO"));
      palletLocList.add(palLoc);
      sPalletItemNo = rsPallets.getString("ITEM_NO");
      fromComboBox.addItem(palLoc.location + "   " + palLoc.qty);
      lPalletLocations = lPalletLocations + 1;
  }
  rsPallets.next();
}

if (fromComboBox.getItemCount() > 0 ) {
  qtyText.setText(palletLocList.get(0).qty);
  lMaxQuantity = palletLocList.get(0).qty;
  if (fromComboBox.getItemCount() == 1) {
    toText.requestFocus();
  }else{
    fromComboBox.requestFocus();
  }
fromComboBox.setSelectedIndex(0);
}
}

Thanks.

Edited 6 Years Ago by cjmartin: n/a

As I do more debugging, I have now noticed that when the code adds the second collection of items to the arraylist, it seems to overwrite the first collection of items. So I then have two sets of items that are identical. Any help? Thanks.

As I do more debugging, I have now noticed that when the code adds the second collection of items to the arraylist, it seems to overwrite the first collection of items. So I then have two sets of items that are identical. Any help? Thanks.

Its hard to make sense of what the program is doing with only a few lines of code shown.

Can you make a small complete program that compiles, executes and demos the problem?

Hopefully this will help. This is all the code used where the problem occurs. You can see I made some changes since the last post still coming out with the same issue (both items in the collection are identical).

WMS_Main Class

private void PalletInput() {
    Statement stmtPallet = null;
    long lPalletLocations;
    ResultSet rsPallets = null;
    Boolean bPalletFound = new Boolean(false);
		
    ArrayList<PalletLocations> palletLocList = new ArrayList<PalletLocations>();
				
    try {
      WarehouseTracer.bNoConnectivity = false;
      fromComboBox.removeAllItems();
      toText.setText("");
      qtyText.setText("");
      lPalletLocations = 0;
      WarehouseTracer.GetOracleConn();
		
      if (WarehouseTracer.bNoConnectivity.equals(true) || (WarehouseTracer.oracleConn == null) || (WarehouseTracer.oracleConn.isClosed() == true)) {
        //No connectivity so do not try to get data
        WarehouseTracer.bNoConnectivity = true;
	fromComboBox.requestFocus();
	return;
      }else{
        stmtPallet = WarehouseTracer.oracleConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
	rsPallets = stmtPallet.executeQuery("SELECT * FROM RPRT.PCA_WMS_LOCATION_POSITION WHERE PALLET_NO = '" + palletText.getText() + "' ORDER BY LOCATION ASC");
				
	PalletLocations palLoc = new PalletLocations();
				
	if (rsPallets.first()){
	  bPalletFound = true;
	    while (rsPallets.isAfterLast() == false) {
	      if (rsPallets.getLong("QTY") > 0) {
		palLoc.setPalletNbr(palletText.getText());
		palLoc.setLocation(rsPallets.getString("LOCATION"));
		palLoc.setQty(rsPallets.getString("QTY"));
		palLoc.setItemNbr(rsPallets.getString("ITEM_NO"));
		palletLocList.add(palLoc);
							
                //palLoc.addPalletLocation(palletText.getText(), rsPallets.getString("LOCATION"),rsPallets.getString("QTY"), rsPallets.getString("ITEM_NO"));
		//palletLocList.add(palLoc);
  		sPalletItemNo = rsPallets.getString("ITEM_NO");
		fromComboBox.addItem(palLoc.location + "   " + palLoc.qty);
		lPalletLocations = lPalletLocations + 1;
              }
              rsPallets.next();
 	}
	
	if (fromComboBox.getItemCount() > 0 ) {
	  toText.setText(palletLocList.get(0).location);
	  qtyText.setText(palletLocList.get(2).qty);
	  lMaxQuantity = palletLocList.get(2).qty;
	  
	  if (fromComboBox.getItemCount() == 1) {
	    toText.requestFocus();
	  }else{
	    fromComboBox.requestFocus();
	  }
	  fromComboBox.setSelectedIndex(0);
	}

      }
    }
  }
		
  catch (Exception e) {
    e.printStackTrace();
  }
  finally {
		}
}

PalletLocations Class

package wms;

public class PalletLocations {
	public String palletNbr;
	public String location;
	public String qty;
	public String itemNbr;
	
	public void addPalletLocation(String sPalletNbr, String sLocation, String sQty, String sItemNbr) {
		palletNbr = sPalletNbr;
		location = sLocation;
	    qty = sQty;
	    itemNbr = sItemNbr;
	}

	public String getPalletNbr() {
		return palletNbr;
	}

	public void setPalletNbr(String palletNbr) {
		this.palletNbr = palletNbr;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public String getQty() {
		return qty;
	}

	public void setQty(String qty) {
		this.qty = qty;
	}

	public String getItemNbr() {
		return itemNbr;
	}

	public void setItemNbr(String itemNbr) {
		this.itemNbr = itemNbr;
	}
	
	/*public String toString() {
	       return location;
    }*/
	

}

Can you make a small complete program that compiles, executes and demos the problem?

I don't see a main() method in this code you just posted, so I can't believe it will execute.

package wms;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

import org.dyno.visual.swing.layouts.Constraints;
import org.dyno.visual.swing.layouts.GroupLayout;
import org.dyno.visual.swing.layouts.Leading;


//VS4E -- DO NOT REMOVE THIS LINE!
public class WMS_Main extends JFrame implements KeyListener {

	private static final long serialVersionUID = 1L;
	private JLabel jLabel0;
	private JLabel jLabel1;
	private JLabel jLabel2;
	private JLabel jLabel3;
	private JTextField palletText;
	private JTextField toText;
	private JComboBox fromComboBox;
	private JTextField qtyText;
	private JLabel jLabel4;
	private JTextField itemDescText;
	private JLabel noConnLabel;
	private JButton submitButton;
	private JButton clearButton;
	String sPallet = "";
	String sPalletItemNo = "";
	String lMaxQuantity;
	private static final String PREFERRED_LOOK_AND_FEEL = "javax.swing.plaf.metal.MetalLookAndFeel";
	
	/**
	 * Main entry of the class.
	 * Note: This class is only created so that you can easily preview the result at runtime.
	 * It is not expected to be managed by the designer.
	 * You can modify it as you like.
	 */
	public static void main(String[] args) {
		installLnF();
		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				WMS_Main frame = new WMS_Main();
				frame.setDefaultCloseOperation(WMS_Main.EXIT_ON_CLOSE);
				frame.setTitle("Warehouse Tracer " + WarehouseTracer.appVersion + " on the Controls " + WarehouseTracer.sUserName + " using " + WarehouseTracer.computerName);
				frame.getContentPane().setPreferredSize(frame.getSize());
				frame.pack();
				frame.setLocationRelativeTo(null);
				frame.setResizable(false);
				frame.setVisible(true);
			}
		});
	}
	
	private static void installLnF() {
		try {
			String lnfClassname = PREFERRED_LOOK_AND_FEEL;
			if (lnfClassname == null)
				lnfClassname = UIManager.getCrossPlatformLookAndFeelClassName();
			UIManager.setLookAndFeel(lnfClassname);
		} catch (Exception e) {
			System.err.println("Cannot install " + PREFERRED_LOOK_AND_FEEL
					+ " on this platform:" + e.getMessage());
		}
	}
	
	public WMS_Main() {
		/*bForceTabStopOnFrom = False
	    lPalletLocations = 0
	    sPallet = "";
	    sCommand = ""
	    sActiveControl = ""
	    sPreviousControl = ""*/
		
		setTitle("Warehouse Tracer " + WarehouseTracer.appVersion + " on the Controls " + WarehouseTracer.sUserName + " using " + WarehouseTracer.computerName);
		setLocationRelativeTo(null);
		setResizable(false);

		addKeyListener(this);
		initComponents();
		
		lMaxQuantity = "130";
	    WarehouseTracer.sBadgeNumber = "";
	    WarehouseTracer.bScroll.equals(false);
		WarehouseTracer.bNoConnectivity = false;
		noConnLabel.setVisible(false);
		
		ReadParseFile();
		WarehouseTracer.Initialize();
		SetConnectivityFlag();
	}

	private void initComponents() {
		setLayout(new GroupLayout());
		add(getJLabel0(), new Constraints(new Leading(20, 170, 10, 10), new Leading(27, 53, 10, 10)));
		add(getJLabel1(), new Constraints(new Leading(20, 170, 10, 10), new Leading(129, 53, 10, 10)));
		add(getJLabel2(), new Constraints(new Leading(20, 170, 10, 10), new Leading(213, 53, 10, 10)));
		add(getpalletText(), new Constraints(new Leading(300, 479, 10, 10), new Leading(27, 73, 12, 12)));
		add(getToText(), new Constraints(new Leading(300, 479, 12, 12), new Leading(200, 75, 12, 12)));
		add(getFromComboBox(), new Constraints(new Leading(300, 478, 12, 12), new Leading(112, 73, 12, 12)));
		add(getQtyText(), new Constraints(new Leading(300, 479, 12, 12), new Leading(293, 75, 12, 12)));
		add(getJLabel4(), new Constraints(new Leading(20, 233, 12, 12), new Leading(374, 53, 12, 12)));
		add(getItemDescText(), new Constraints(new Leading(18, 643, 12, 12), new Leading(418, 42, 10, 10)));
		add(getJLabel3(), new Constraints(new Leading(20, 242, 10, 10), new Leading(300, 53, 10, 10)));
		add(getNoConnLabel(), new Constraints(new Leading(668, 190, 10, 10), new Leading(472, 53, 12, 12)));
		add(getSubmitButton(), new Constraints(new Leading(18, 76, 10, 10), new Leading(489, 10, 10)));
		add(getClearButton(), new Constraints(new Leading(136, 76, 10, 10), new Leading(489, 12, 12)));
		setSize(861, 600);
	}

	private JButton getClearButton() {
		if (clearButton == null) {
			clearButton = new JButton();
			clearButton.setText("Clear");
		}
		return clearButton;
	}

	private JButton getSubmitButton() {
		if (submitButton == null) {
			submitButton = new JButton();
			submitButton.setText("Submit");
			submitButton.addKeyListener(new KeyAdapter() {
				public void keyPressed(KeyEvent event) {
					submitButtonKeyKeyPressed(event);
				}	
				
			});

			submitButton.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					submitButtonMouseMouseClicked(event);
				}
			});
			
		}
		return submitButton;
	}

	private JLabel getNoConnLabel() {
		if (noConnLabel == null) {
			noConnLabel = new JLabel();
			noConnLabel.setFont(new Font("Arial", Font.BOLD, 24));
			noConnLabel.setText("No Connectivity");
			noConnLabel.setForeground(Color.RED);
		}
		return noConnLabel;
	}

	private JTextField getItemDescText() {
		if (itemDescText == null) {
			itemDescText = new JTextField();
			itemDescText.setFont(new Font("Arial", Font.BOLD, 52));
			itemDescText.setText("");
		}
		return itemDescText;
	}

	private JLabel getJLabel4() {
		if (jLabel4 == null) {
			jLabel4 = new JLabel();
			jLabel4.setFont(new Font("Arial", Font.BOLD, 24));
			jLabel4.setText("Item Description");
		}
		return jLabel4;
	}

	private JTextField getQtyText() {
		if (qtyText == null) {
			qtyText = new JTextField();
			qtyText.setFont(new Font("Arial", Font.BOLD, 52));
			qtyText.setText("");
		}
		return qtyText;
	}

	private JComboBox getFromComboBox() {
		if (fromComboBox == null) {
			fromComboBox = new JComboBox();
			fromComboBox.setEditable(true);
			fromComboBox.setBackground(Color.white);
			fromComboBox.setFont(new Font("Arial", Font.BOLD, 52));
			fromComboBox.setModel(new DefaultComboBoxModel(new Object[] { "" }));
			fromComboBox.setDoubleBuffered(false);
			fromComboBox.setBorder(null);
			fromComboBox.addKeyListener(new KeyAdapter() {
	
				public void keyPressed(KeyEvent event) {
					fromComboBoxKeyKeyPressed(event);
				}
			});
			fromComboBox.addFocusListener(new FocusAdapter() {
	
				public void focusGained(FocusEvent event) {
					fromComboBoxFocusFocusGained(event);
				}
	
				public void focusLost(FocusEvent event) {
					fromComboBoxFocusFocusLost(event);
				}
			});
		}
		return fromComboBox;
	}

	private JTextField getToText() {
		if (toText == null) {
			toText = new JTextField();
			toText.setFont(new Font("Arial", Font.BOLD, 52));
			toText.setText("");
			toText.addKeyListener(new KeyAdapter() {
				
				public void keyPressed(KeyEvent event) {
					toTextKeyKeyPressed(event);
				}
				
			});
			
			toText.addFocusListener(new FocusAdapter() {
				public void focusGained(FocusEvent event) {
					toTextFocusFocusGained(event);
				}
				
				public void focusLost(FocusEvent event) {
					toTextFocusFocusLost(event);
				}


			});
		}
		return toText;
	}

	private JTextField getpalletText() {
		if (palletText == null) {
			palletText = new JTextField();
			palletText.setFont(new Font("Arial", 1,52));
			palletText.setText("");
			palletText.addKeyListener(new KeyAdapter() {
				
				public void keyPressed(KeyEvent event) {
					palletTextKeyKeyPressed(event);
				}
			});
			
			palletText.addFocusListener(new FocusAdapter() {
				public void focusLost(FocusEvent event) {
					palletTextFocusFocusLost(event);
				}

			});
		}
		return palletText;
	}

	private JLabel getJLabel3() {
		if (jLabel3 == null) {
			jLabel3 = new JLabel();
			jLabel3.setFont(new Font("Arial", Font.BOLD, 52));
			jLabel3.setText("Quantity :");
		}
		return jLabel3;
	}

	private JLabel getJLabel2() {
		if (jLabel2 == null) {
			jLabel2 = new JLabel();
			jLabel2.setFont(new Font("Arial", Font.BOLD, 52));
			jLabel2.setText("To :");
		}
		return jLabel2;
	}

	private JLabel getJLabel1() {
		if (jLabel1 == null) {
			jLabel1 = new JLabel();
			jLabel1.setFont(new Font("Arial", Font.BOLD, 52));
			jLabel1.setText("From :");
		}
		return jLabel1;
	}

	private JLabel getJLabel0() {
		if (jLabel0 == null) {
			jLabel0 = new JLabel();
			jLabel0.setText("Pallet :");
			jLabel0.setFont(new Font("Arial", Font.BOLD,52));
		}
		return jLabel0;
	}

	private void submitButtonMouseMouseClicked(MouseEvent event) {
		try {
			WarehouseTracer.GetOracleConn();
			
			if (WarehouseTracer.oracleConn != null) { 
				if (WarehouseTracer.bNoConnectivity.equals(true) || (WarehouseTracer.oracleConn.isClosed() == true)) {
					//if previous control = "QUANTITY" THEN
					if (IsDataValid()) {
						WriteOfflineFile(palletText.getText(), fromComboBox.getSelectedItem(), toText.getText(), qtyText.getText());
					}
				}else{
					DoSubmit();
					if ((WarehouseTracer.bDataInserted.equals(false)) && (WarehouseTracer.bDataOK.equals(true))) {
						WriteOfflineFile(palletText.getText(), fromComboBox.getSelectedItem(), toText.getText(), qtyText.getText());
					}
				}
			}
			
			SetConnectivityFlag();
		
		}catch (Exception e) {
			e.printStackTrace();
		}
		
		finally {
			
		}
		
	}
	
	private void submitButtonKeyKeyPressed(KeyEvent e) {
		//System.out.println ("test " + wms.WarehouseTracer.sBadgeNumber);
		if ((e.getKeyCode() == 47) && (e.isShiftDown())){
			
		}

		if ((e.getKeyCode() == 56) && (e.isShiftDown())){
			
		}
		
	}
	
	public void keyPressed(KeyEvent evt) {
		char ch = evt.getKeyChar();	
		ProcessKey(ch);
	}
	
	public void keyReleased(KeyEvent evt) {
	}
	
	private void palletTextKeyKeyPressed(KeyEvent e) {
		if (e.getKeyCode() == 10) {
			if (sPallet != palletText.getText()) {
				PalletInput();
				InsertPalletScan();
				SetConnectivityFlag();
			}
		}else{
			char ch = e.getKeyChar();
			ProcessKey(ch);
		}
	}
	
	private void palletTextFocusFocusLost(FocusEvent event) {
		if (!palletText.getText().trim().equals("")) {
			if (sPallet != palletText.getText()) { 
				PalletInput();
				SetConnectivityFlag();
			}
		}
	}
	
	private void toTextKeyKeyPressed(KeyEvent e) {
		if (e.getKeyCode() == 10) {
			ToInput();
		}
	}
	
	private void toTextFocusFocusGained(FocusEvent event) {
		if (toText.getText().length() > 0 ) {
			toText.setSelectionStart(0);
			toText.setSelectionEnd(toText.getText().length());
		}
	}
	
	private void toTextFocusFocusLost(FocusEvent event) {
		ToInput();
	}
	
	
	private void fromComboBoxKeyKeyPressed(KeyEvent e) {
		int num = fromComboBox.getItemCount();
		
		if (e.getKeyCode() == 10) {
			if (WarehouseTracer.bScroll.equals(true)) {
				fromComboBox.requestFocus();
				WarehouseTracer.bScroll = false;
			}else {
				FromInput();
			}
		}else if (e.getKeyCode() == 35) {
			//use # to scroll through From dropdown
			WarehouseTracer.bScroll = true;
			if (fromComboBox.getItemAt(num).equals(fromComboBox.getSelectedItem())) {
				fromComboBox.setSelectedIndex(0);
			}else{
				fromComboBox.setSelectedIndex(fromComboBox.getSelectedIndex() + 1);
			}
		}
	}
	
	private void fromComboBoxFocusFocusGained(FocusEvent event) {
		//need to highlight text
	}
	
	private void fromComboBoxFocusFocusLost(FocusEvent event) {
		FromInput();
	}
	
	private void DoChangeFocus() {
		
	}
	
	private void DoQuit() {
		//unload form
	}
	
	
	private void DoShutDown() {
		
	}
	
	private void DoSubmit() {
		//Insert transaction
		
		Statement stmtPallets = null;
		Statement stmtDriver = null;
		ResultSet rsDriver = null;
		Statement stmtOOrec = null;
		ResultSet rsOOrec = null;
		Statement stmtItemNo = null;
		ResultSet rsItemNo = null;
		String fromLocation;
		String newline = System.getProperty("line.separator");
		String driverName;
		String itemNo;
		String sqlStatement;
		
		WarehouseTracer.bDataInserted.equals(false);
		
		try {
			if (IsDataValid()) {
				ReadParseFile();
				
				WarehouseTracer.GetOracleConn();
				
				if (WarehouseTracer.bNoConnectivity.equals(true) || (WarehouseTracer.oracleConn == null) || (WarehouseTracer.oracleConn.isClosed() == true)) {
					return;
				}else{
					//Parse fromComboBox to get From Location
					if (fromComboBox.toString().indexOf(" ") != -1) {
						fromLocation = fromComboBox.toString().substring(fromComboBox.toString().indexOf(" "));
					}else{
						fromLocation = fromComboBox.toString();
					}
					
					//'Check to see if pallet is an OO, O1, O2, or O3 and being moved to order. If so, then do not allow and display warning.
					if (toText.getText().substring(1) == "6" ) {
						stmtOOrec = WarehouseTracer.oracleConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
						rsOOrec = stmtOOrec.executeQuery("select * from xxpca.xxpca_inventory_v@plk where substr(location,1,1) = 'O' and sublot_no = '" + palletText.getText() + "'");
						if (rsOOrec.first()){
							WarehouseTracer.bDataOK.equals(false);
							WarehouseTracer.sMessage = "Pallet tag on hold (OO). DO NOT USE FOR ORDERS." + newline + "Tarima bloqueada (OO). NO USAR EN ORDENES.";
							new MessageCenter().setVisible(true);
							palletText.setSelectionStart(0);
							palletText.setSelectionEnd(palletText.getText().length());
							palletText.requestFocus();
						}

					}
					
					//'Try to get Driver Name if no connectivity when logging in
					if (WarehouseTracer.sUserName == "") {
						stmtDriver = WarehouseTracer.oracleConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
						rsDriver = stmtDriver.executeQuery("SELECT EMPLOYEE_NAME FROM KR_EMPLOYEE_V WHERE BADGENUM = '" + WarehouseTracer.sUserID + "'");
						if (rsOOrec.first()){
							//driver name not found
							driverName = " ";
						}else{
							driverName = rsDriver.getString("Employee_Name");
						}
					}else{
						driverName = WarehouseTracer.sUserName;
					}
					
					//Try to get ITEM Number if necessary
					if (sPalletItemNo.trim() == "") {
						stmtItemNo = WarehouseTracer.oracleConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
						rsItemNo = stmtItemNo.executeQuery("SELECT ITEM_NO FROM XXPCA.XXPCA_INVENTORY_V@PLK WHERE SUBLOT_NO = '" + palletText.getText() + "'");
						if (rsItemNo.first()){
							//Item not found
							itemNo = " ";
						}else{
							itemNo = rsItemNo.getString("ITEM_NO");
						}
					}else{
						itemNo = sPalletItemNo;
					}
					
					//Check Qty size
					if (Long.parseLong(qtyText.getText()) >= 1500) {
						WarehouseTracer.sMessage = "Quantity value must be less than 1500. " + newline + "Cantidad de valor deve de ser menos de 1500.";
						new MessageCenter().setVisible(true);
						WarehouseTracer.bDataOK.equals(false);
						qtyText.setSelectionStart(0);
						qtyText.setSelectionEnd(qtyText.getText().length());
						qtyText.requestFocus();
					}else if (fromLocation.trim() == toText.getText().trim()){
						WarehouseTracer.sMessage = "From and To locations cannot be the same. " + newline + "Ubicacion DE..PARA debe ser diferente.";
						new MessageCenter().setVisible(true);
						WarehouseTracer.bDataOK.equals(false);
						toText.setSelectionStart(0);
						toText.setSelectionEnd(qtyText.getText().length());
						toText.requestFocus();
					}else{
						stmtPallets = WarehouseTracer.oracleConn.createStatement();
						sqlStatement = "INSERT INTO RPRT.PCA_WMS_FG (PALLET_NO,LOCATION_FROM,LOCATION_TO,QTY,TRANSACTION_DATE,MODIFIED_BY,MODIFIED_DATE,LOT_ID,REC_ID,ITEM_NO,COMPUTER_ID, EMPLOYEE_NAME)";
						sqlStatement = sqlStatement + " VALUES ('" + palletText.getText() + "','" + fromLocation + "','" + toText.getText() + "'," + qtyText.getText() + "," + getDateTime() + ",'" + WarehouseTracer.sUserID + "'," + getDateTime() + ",NULL,RPRT.PCA_WMS_FG_SEQ.NEXTVAL" + ",'" + itemNo + "','" + WarehouseTracer.computerName + "','" + driverName + "')";
						stmtPallets.executeUpdate(sqlStatement);
						
						WarehouseTracer.bDataInserted.equals(true);
						ResetData();
					}
					WarehouseTracer.DropOracleConn();
				}
			}
		}
		
		catch (Exception e) {
			e.printStackTrace();
		}
		
		finally {
			if (rsOOrec != null) try { rsOOrec.close(); } catch(Exception e) {}
			if (stmtOOrec != null) try { stmtOOrec.close(); } catch(Exception e) {}
			if (rsItemNo != null) try { rsItemNo.close(); } catch(Exception e) {}
			if (stmtItemNo != null) try { stmtItemNo.close(); } catch(Exception e) {}
			if (rsDriver != null) try { rsDriver.close(); } catch(Exception e) {}
			if (stmtDriver != null) try { stmtDriver.close(); } catch(Exception e) {}
			if (stmtPallets != null) try { stmtPallets.close(); } catch(Exception e) {}
		}
		
	}
	
	private void FromInput() {
		Boolean bIsLocationOK = new Boolean(false);
		int num = fromComboBox.getItemCount();
		
		//Do not try to verify From combo if empty do to no connectivity
		if (num == 0) {
			//set focus to From ?????
			return;
		}
		
		bIsLocationOK.equals(false);
		if ((fromComboBox.getSelectedItem() == "PROD") || (fromComboBox.getSelectedItem() == "ADJUST") || (fromComboBox.getSelectedItem() == "SF1") || (fromComboBox.getSelectedItem() == "SF2")) {
			bIsLocationOK.equals(true);
		}else{
			for (int i = 0; i < num; i++) {
				if (fromComboBox.getSelectedItem() == fromComboBox.getItemAt(i)) {
					fromComboBox.setSelectedIndex(i);
					bIsLocationOK.equals(true);
					return;
				}
			}
		}
		
		if (bIsLocationOK.equals(true)) {
			if ((fromComboBox.getSelectedItem() == "PROD") || (fromComboBox.getSelectedItem() == "ADJUST") || (fromComboBox.getSelectedItem() == "SF1") || (fromComboBox.getSelectedItem() == "SF2")) {
				qtyText.setText("0");
				lMaxQuantity = "130";
			}else{
				//qtyText.setText(palloc(index).qty);
			}
			toText.setSelectionStart(0);
			toText.setSelectionEnd(toText.getText().length());
			toText.requestFocus();
		}
		WarehouseTracer.sMessage = "From Location must be in the list of possible values.";
		new MessageCenter().setVisible(true);
	}
	
	
	private void GetItemDesc(String palletItemNo) {
		//Get the Item Description for the product on the pallet
		Statement stmtItemDesc = null;
		ResultSet rsItemDesc = null;
		
		try {
			WarehouseTracer.GetOracleConn();
			
			if (WarehouseTracer.bNoConnectivity.equals(true) || (WarehouseTracer.oracleConn == null) || (WarehouseTracer.oracleConn.isClosed() == true)) {
				//No connectivity so do not try to get data
				WarehouseTracer.bNoConnectivity = true;
				fromComboBox.requestFocus();
				return;
			}
			
			stmtItemDesc = WarehouseTracer.oracleConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
			rsItemDesc = stmtItemDesc.executeQuery("SELECT ITEM_DESC1 FROM RPRT.PCA_ITEM_INFO WHERE ITEM_NO = '" + palletItemNo + "'");
			
			if (rsItemDesc.first()){
				itemDescText.setText(rsItemDesc.getString("ITEM_DESC1"));
			}
		}
		
		catch (Exception e) {
			
		}
		
		finally {
			
		}
	}
	
	private void InsertPalletScan() {
		//Every time a Pallet is scanned the PCA_WMS_PALLET_SCAN table will get updated
		
		Statement stmtPalletScan = null;
		
		try {
			WarehouseTracer.GetOracleConn();
			
			if (WarehouseTracer.bNoConnectivity.equals(true) || (WarehouseTracer.oracleConn == null) || (WarehouseTracer.oracleConn.isClosed() == true)) {
				//No connectivity so do not try to get data
				WarehouseTracer.bNoConnectivity = true;
				fromComboBox.requestFocus();
				return;
			}
			stmtPalletScan = WarehouseTracer.oracleConn.createStatement();
			//stmtPalletScan.executeUpdate("INSERT INTO TNT.TR_PALLETS (ID, CARTONID, DATEONPALLET, ORACLEPALLETNUMBER) VALUES (RPRT.TR_PALLETS_SEQ.NEXTVAL, 'NO READ', " + getDateTime() + ", '"+ palletText.getText() + "')");
		}
		
		catch (Exception e) {
			e.printStackTrace();
		}
		
		finally {
			if (stmtPalletScan != null) try { stmtPalletScan.close(); } catch(Exception e) {}
		}
		
	}
	
	private Boolean IsDataValid() {
		String newline = System.getProperty("line.separator");
		
		WarehouseTracer.bDataOK.equals(true);
		
		if (palletText.getText().length() == 0) {
			WarehouseTracer.sMessage = "Pallet Number not specified." + newline + "Numero de Tarima no especificado.";
			new MessageCenter().setVisible(true);
			WarehouseTracer.bDataOK.equals(false);
			palletText.setSelectionStart(0);
			palletText.setSelectionEnd(palletText.getText().length());
			palletText.requestFocus();
		}else{
			if (!isNumeric(palletText.getText())) {
				WarehouseTracer.sMessage = "Pallet Number must be numeric." + newline + "Numero de Tarima debe ser numerico.";
				new MessageCenter().setVisible(true);
				WarehouseTracer.bDataOK.equals(false);
				palletText.setSelectionStart(0);
				palletText.setSelectionEnd(palletText.getText().length());
				palletText.requestFocus();
			}
		}
		
		if (WarehouseTracer.bDataOK.equals(true)) {
			WarehouseTracer.bDataOK.equals(false);
			if ((fromComboBox.getSelectedItem() == "PROD") || (fromComboBox.getSelectedItem() == "ADJUST") || (fromComboBox.getSelectedItem() == "SF1") || (fromComboBox.getSelectedItem() == "SF2")) {
				WarehouseTracer.bDataOK.equals(true);
			}else{
				for (int iCounter = 0; iCounter < fromComboBox.getItemCount() - 1; iCounter++) {
					if (fromComboBox.getSelectedItem() == fromComboBox.getItemAt(iCounter)) {
						WarehouseTracer.bDataOK.equals(true);
						return WarehouseTracer.bDataOK;
					}
				}
			}
			if (WarehouseTracer.bDataOK.equals(false)) {
				WarehouseTracer.sMessage = "From Location is incorrect." + newline + "Ubicacion incorrecta.";
				new MessageCenter().setVisible(true);
				//fromComboBox.setSelectionStart(0);
			//	fromComboBox.setSelectionEnd(palletText.getText().length());
				fromComboBox.getEditor().selectAll();
				fromComboBox.requestFocus();
			}
		}
		if (WarehouseTracer.bDataOK.equals(true)) {
			WarehouseTracer.bDataOK.equals(false);
			if ((fromComboBox.getSelectedItem() == "PROD") || (fromComboBox.getSelectedItem() == "ADJUST") || (fromComboBox.getSelectedItem() == "SF1") || (fromComboBox.getSelectedItem() == "SF2")) {
				WarehouseTracer.bDataOK.equals(true);
			}else{
				if (toText.getText().substring(1,1) == "6") {
					WarehouseTracer.bDataOK.equals(true);
				}else{
					if (! IsLocationValid(toText.getText())) {
						WarehouseTracer.sMessage = "To Location is incorrect." + newline + "Ubicacion Incorrecta.";
						new MessageCenter().setVisible(true);
						WarehouseTracer.bDataOK.equals(false);
						toText.setSelectionStart(0);
						toText.setSelectionEnd(palletText.getText().length());
						toText.requestFocus();
					}
				}
			}
		}
		
		if (WarehouseTracer.bDataOK.equals(true)) {
			if (qtyText.getText().length() == 0) {
				WarehouseTracer.sMessage = "Quantity value must be entered." + newline + "Ingrese cantidad.";
				new MessageCenter().setVisible(true);
				WarehouseTracer.bDataOK.equals(false);
				qtyText.setSelectionStart(0);
				qtyText.setSelectionEnd(qtyText.getText().length());
				qtyText.requestFocus();
			}else{
				if (!isNumeric(qtyText.getText())) {
					WarehouseTracer.sMessage = "Quantity value must be entered." + newline + "Ingrese cantidad.";
					new MessageCenter().setVisible(true);
					WarehouseTracer.bDataOK.equals(false);
					qtyText.setSelectionStart(0);
					qtyText.setSelectionEnd(qtyText.getText().length());
					qtyText.requestFocus();
				}else{
					if (Long.parseLong(qtyText.getText()) > Long.parseLong(lMaxQuantity)) {
						WarehouseTracer.sMessage = "Quantity cannot be greater than Pallet size at this location (" + lMaxQuantity + "). " + newline + "Ingrese cantidad.";
						new MessageCenter().setVisible(true);
						WarehouseTracer.bDataOK.equals(false);
						qtyText.setSelectionStart(0);
						qtyText.setSelectionEnd(qtyText.getText().length());
						qtyText.requestFocus();
					}else{
						if (Long.parseLong(qtyText.getText()) <= 0) {
							WarehouseTracer.sMessage = "Quantity must be a value greater than 0. " + newline + "Cantidad debe ser mayor que 0.";
							new MessageCenter().setVisible(true);
							WarehouseTracer.bDataOK.equals(false);
							qtyText.setSelectionStart(0);
							qtyText.setSelectionEnd(qtyText.getText().length());
							qtyText.requestFocus();
						}else{
							if (Long.parseLong(qtyText.getText()) >= 1500) {
								WarehouseTracer.sMessage = "Quantity value must be less than 1500. " + newline + "Cantidad de valor deve de ser menos de 1500.";
								new MessageCenter().setVisible(true);
								WarehouseTracer.bDataOK.equals(false);
								qtyText.setSelectionStart(0);
								qtyText.setSelectionEnd(qtyText.getText().length());
								qtyText.requestFocus();
							}
						}
					}
					
				}
			}
		}
		return WarehouseTracer.bDataOK.equals(false);
	}
	
	private Boolean IsLocationValid(String sLocation) {
		Boolean bResult = new Boolean(false);
		int iNum;
		
		if (sLocation.equals("9999999999")) {
			return true;
		}else{
			if (sLocation.substring(1) != "6") {
				if (isNumeric(sLocation.substring(1))) {
					iNum = Integer.parseInt(sLocation.substring(1)) ;
					if (iNum >= 0 && iNum <= 3) {
						if (isNumeric(sLocation.substring(3,1))) {
							iNum = Integer.parseInt(sLocation.substring(3,1)) ;
							if ((iNum >= 1) && (iNum <= 6)) {
								if (isNumeric(sLocation.substring(5,2))) {
									iNum = Integer.parseInt(sLocation.substring(5,2));
									if ((iNum >= 1) && (iNum <= 24)) {
										if (isNumeric(sLocation.substring(8,1))) {
											iNum = Integer.parseInt(sLocation.substring(8,1));
											if ((iNum >= 0) && (iNum <= 3)) {
												bResult.equals(true);
											}
										}
									}
								}
							}
	                    }
					}
				}
			}
		}
		return bResult;
	}
	
	private void PalletInput() {
		Statement stmtPallet = null;
		long lPalletLocations;
		ResultSet rsPallets = null;
		Boolean bPalletFound = new Boolean(false);
		
		ArrayList<PalletLocations> palletLocList = new ArrayList<PalletLocations>();
				
		try {
			WarehouseTracer.bNoConnectivity = false;
			fromComboBox.removeAllItems();
			toText.setText("");
			qtyText.setText("");
		
			lPalletLocations = 0;
			
			WarehouseTracer.GetOracleConn();
			
			if (WarehouseTracer.bNoConnectivity.equals(true) || (WarehouseTracer.oracleConn == null) || (WarehouseTracer.oracleConn.isClosed() == true)) {
				//No connectivity so do not try to get data
				WarehouseTracer.bNoConnectivity = true;
				fromComboBox.requestFocus();
				return;
			}else{
				stmtPallet = WarehouseTracer.oracleConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
				rsPallets = stmtPallet.executeQuery("SELECT * FROM RPRT.PCA_WMS_LOCATION_POSITION WHERE PALLET_NO = '" + palletText.getText() + "' ORDER BY LOCATION ASC");
				
				PalletLocations palLoc = new PalletLocations();
				
			    if (rsPallets.first()){
			    	bPalletFound = true;
			    	
					while (rsPallets.isAfterLast() == false) {
						if (rsPallets.getLong("QTY") > 0) {
							
							palLoc.setPalletNbr(palletText.getText());
							palLoc.setLocation(rsPallets.getString("LOCATION"));
							palLoc.setQty(rsPallets.getString("QTY"));
							palLoc.setItemNbr(rsPallets.getString("ITEM_NO"));
							palletLocList.add(palLoc);
							
//							palLoc.addPalletLocation(palletText.getText(), rsPallets.getString("LOCATION"),rsPallets.getString("QTY"), rsPallets.getString("ITEM_NO"));
						//	palletLocList.add(palLoc);
							sPalletItemNo = rsPallets.getString("ITEM_NO");
							fromComboBox.addItem(palLoc.location + "   " + palLoc.qty);
							lPalletLocations = lPalletLocations + 1;
						}
						rsPallets.next();
					}
					
					if (fromComboBox.getItemCount() > 0 ) {
						toText.setText(palletLocList.get(0).location);
						qtyText.setText(palletLocList.get(2).qty);
						lMaxQuantity = palletLocList.get(2).qty;
						if (fromComboBox.getItemCount() == 1) {
							toText.requestFocus();
						}else{
							fromComboBox.requestFocus();
						}
						fromComboBox.setSelectedIndex(0);
					}

			    }
			}
		}
		
		catch (Exception e) {
			e.printStackTrace();
		}
		
		finally {
			
		}
	}
	
	private void ProcessKey(char ch) {
		try {
			switch(ch){
				case '~': DoQuit(); break;
				
				case '*':
					DoSubmit(); 
					if ((WarehouseTracer.bDataInserted.equals(false)) && (WarehouseTracer.bDataOK.equals(true))) {
						WriteOfflineFile(palletText.getText(), fromComboBox.getSelectedItem(), toText.getText(), qtyText.getText());
					}
					SetConnectivityFlag();
					break;
				
				case '>': DoChangeFocus(); break;
					
				case '?': ResetData(); break;
				
				case '<': break;
				
				case '^': break;
				
				case '_': 
					ReadParseFile();
					DoShutDown();
					break;
				
				case '$': break;
				
				case '#':
					//????
				
				default:
					//????
			}
			
			/* If sCommand <> "" Then
		        If sCommand = "BACKSPACE" Then
		            KeyAscii = 8
		        Else
		            KeyAscii = 0
		        End If
		    End If*/
		    
		}		
		catch (Exception e){
			e.printStackTrace();
		}
		
		finally{
			
		}
			
			

	}
	
	private void ReadParseFile(){
		//Records that could not be saved because of No Connectivity are saved in C:\WarehouseTracer.txt.  This Sub reads and parses that
		//file for the data elements.  Then saves the records to the db.
		Statement stmtFile = null;
		ResultSet rsFile = null;
		String[] aLine;
		String itemNo;
		String driverName;
		Object quantity;
		String sqlStatement;
		
		try{
			//check if file exists
			File wtFile = new File(WarehouseTracer.filePath);
			if (wtFile.exists()) {
				FileReader in = new FileReader(WarehouseTracer.filePath); 
				BufferedReader bwin = new BufferedReader(in); 
				String line; 
				while ((line=bwin.readLine()) !=null){
					aLine = line.split("\\|");
					for(int i = 0; i < aLine.length ; i++){
						System.out.println(aLine[i].trim());
					}
					
					//Try to get ITEM NUMBER if necessary
					if (aLine[8].trim().equals("")) {
						WarehouseTracer.GetOracleConn();
						if (WarehouseTracer.bNoConnectivity.equals(true) || (WarehouseTracer.oracleConn == null) || (WarehouseTracer.oracleConn.isClosed() == true)) {
							//No connectivity so do not try to get data
							WarehouseTracer.bNoConnectivity.equals(true);
							return;
						}else{
							stmtFile = WarehouseTracer.oracleConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
							rsFile = stmtFile.executeQuery("SELECT ITEM_NO FROM XXPCA.XXPCA_INVENTORY_V@PLK WHERE SUBLOT_NO = '" + palletText.getText());
							if (!rsFile.first()){
								//Item No not found
								itemNo = "";
								stmtFile.close();
								rsFile.close();
							}else{
								itemNo = rsFile.getString("ITEM_NO");
								stmtFile.close();
								rsFile.close();
							}
						}
						WarehouseTracer.DropOracleConn();
					}else{
						itemNo = aLine[8].trim();
					}
					
					//Try to get Driver Name if no connectivity when logging in
					if (aLine[10].trim().equals("")) {
						WarehouseTracer.GetOracleConn();
						if (WarehouseTracer.bNoConnectivity.equals(true) || (WarehouseTracer.oracleConn == null) || (WarehouseTracer.oracleConn.isClosed() == true)) {
							//No connectivity so do not try to get data
							WarehouseTracer.bNoConnectivity.equals(true);
							return;
						}else{
							stmtFile = WarehouseTracer.oracleConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
							rsFile = stmtFile.executeQuery("SELECT EMPLOYEE_NAME FROM KR_EMPLOYEE_V WHERE BADGENUM = '" + aLine[6] + "'");
							if (!rsFile.first()){
								driverName = " ";
							}else{
								driverName = rsFile.getString("Employee_Name");
								stmtFile.close();
								rsFile.close();
							}
						}
						WarehouseTracer.DropOracleConn();
					}else{
						driverName = aLine[10].trim();
					}
					
					//checking to see if Qty is empty
					if (aLine[4].trim().equals("")) {
						quantity = "NULL";
					}else{
						quantity = aLine[4].trim();
					}
					
					sqlStatement = "INSERT INTO RPRT.PCA_WMS_FG (PALLET_NO,LOCATION_FROM,LOCATION_TO,QTY,TRANSACTION_DATE,MODIFIED_BY,MODIFIED_DATE,LOT_ID,REC_ID,ITEM_NO,COMPUTER_ID, EMPLOYEE_NAME)";
					sqlStatement = sqlStatement + " VALUES ('" + aLine[1].trim() + "','" + aLine[2].trim() + "','" + aLine[3].trim() + "'," + quantity + "," + aLine[5].trim() + ",'" + aLine[6].trim() + "'," + aLine[7].trim() + ",NULL,RPRT.PCA_WMS_FG_SEQ.NEXTVAL" + ",'" + itemNo.trim() + "','" + aLine[9].trim() + "','" + driverName + "')";
					
					WarehouseTracer.GetOracleConn();
					if (WarehouseTracer.bNoConnectivity.equals(true) || (WarehouseTracer.oracleConn == null) || (WarehouseTracer.oracleConn.isClosed() == true)) {
						//No connectivity so do not try to get data
						WarehouseTracer.bNoConnectivity.equals(true);
						return;
					}else{
						stmtFile.executeUpdate(sqlStatement);
						stmtFile.close();
						WarehouseTracer.DropOracleConn();
					}

				} 
				WarehouseTracer.bDataInserted.equals(true);
				
				bwin.close(); 
				in.close();
			}
		}
		
		catch (Exception e){
			e.printStackTrace();
		}
		
		finally{
			if (rsFile != null) try { rsFile.close(); } catch(Exception e) {}
			if (stmtFile != null) try { stmtFile.close(); } catch(Exception e) {}
		}
	}
	
	private void ResetData() {
		palletText.setText("");
		fromComboBox.removeAllItems();
		toText.setText("");
		qtyText.setText("");
		itemDescText.setText("");
		sPallet = "";
		lMaxQuantity = "130";
		
	/*	lPalletLocations = 0;
		
	    sPalletItemVariety = ""
        sPalletItemGrade = ""
        sPalletItemSize = ""
        sPalletItemLabel = ""
        sPalletItemPackCode = ""
        sPalletItemPackType = ""
        sPalletItemPoolingGrade = ""
        sPalletItemNo = ""
        lPalletQuantity = 0  */
        
        palletText.requestFocus();

	}
	
	private void SetConnectivityFlag() {
		//Show/hide No Connectivity Label
		
		if (WarehouseTracer.bNoConnectivity.equals(true)) {
			noConnLabel.show();
		}else{
			noConnLabel.hide();
		}
		
	}
	
	private void ToInput() {
		Statement stmtOrders = null;
		ResultSet rsOrders = null;
		Boolean bIsLocationOK = new Boolean(false);
		String newline = System.getProperty("line.separator");
		String sTo = "";
		
		try {
		
			bIsLocationOK.equals(false);
			sTo = toText.getText().trim();
			
			if (sTo.length() > 0) {
				if ((sTo == "PROD") || (sTo == "ADJUST") || (sTo == "SF1") || (sTo == "SF2")) {
					bIsLocationOK.equals(true);
				}else{
					bIsLocationOK = IsLocationValid(sTo);
					
					if (bIsLocationOK.equals(false)) {
						WarehouseTracer.GetOracleConn();
						if (WarehouseTracer.bNoConnectivity.equals(true) || (WarehouseTracer.oracleConn == null) || (WarehouseTracer.oracleConn.isClosed() == true)) {
							WarehouseTracer.bNoConnectivity.equals(true);
							return;
						}else{
							stmtOrders = WarehouseTracer.oracleConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
							rsOrders = stmtOrders.executeQuery("SELECT * FROM RPRT.PCA_ATS_ORDERS WHERE ORDER_NUMBER = '" + toText.getText());
							if (!rsOrders.first()){
								if (sTo.substring(1) == "6") {
						    		WarehouseTracer.sMessage = "Invalid Sales Order." + newline + "Orden de Venta Invalido.";
									new MessageCenter().setVisible(true);
								}else {
						    		WarehouseTracer.sMessage = "Invalid Location." + newline + "Ubicacion Invalida.";
									new MessageCenter().setVisible(true);
								}
							}else{
								bIsLocationOK.equals(true);
								rsOrders = stmtOrders.executeQuery("SELECT * FROM RPRT.PCA_ATS_ORDERS WHERE ORDER_NUMBER = '" + toText.getText() + " AND ITEM_NO = '" + sPalletItemNo + "'");
								if (!rsOrders.first()){
									bIsLocationOK.equals(false);
						    		WarehouseTracer.sMessage = "The Sales order does not include the item " + sPalletItemNo + ". Do you want to proceed? " + newline + "Orden no incluye este articulo. Desea continuar?";
									new MessageCenter().setVisible(true);
								}
								//if yesno = yes then ..... 
								
							}
						}
					}
				}
			}
			if (bIsLocationOK.equals(true)) {
				if (sTo != fromComboBox.getSelectedItem()) {
					qtyText.requestFocus();
				}else{
		    		WarehouseTracer.sMessage = "From and To locations cannot be the same. " + newline + "Ubicacion DE..PARA debe ser diferente.";
					new MessageCenter().setVisible(true);
				}
			}
			
			if (bIsLocationOK.equals(true)) {
				qtyText.setSelectionStart(0);
				qtyText.setSelectionEnd(qtyText.getText().length());
				qtyText.requestFocus();
			}else{
				toText.setSelectionStart(0);
				toText.setSelectionEnd(toText.getText().length());
				toText.requestFocus();
			}
			
			WarehouseTracer.DropOracleConn();
			
		} catch (Exception e) {
			
		}
		
		finally {
			if (rsOrders != null) try { rsOrders.close(); } catch(Exception e) {}
			if (stmtOrders != null) try { stmtOrders.close(); } catch(Exception e) {}

		}

	}
	
	private void WriteOfflineFile(String palletNbr, Object fromLocation, String toLocation, String qty) throws IOException {
		//When there is no connectivity to save file to db, write to local file
		String fromLoc;
		String newline = System.getProperty("line.separator");
		BufferedWriter out = new BufferedWriter(new FileWriter(WarehouseTracer.filePath, true));
		
		try{
			//Parse fromComboBox to get From Location
			if (fromLocation.toString().indexOf(" ") != -1) {
				fromLoc = fromLocation.toString().substring(fromLocation.toString().indexOf(" "));
			}else{
				fromLoc = fromLocation.toString();
			}
			
			if (fromLoc.trim().equals(toText.getText().trim())) {
				WarehouseTracer.bDataOK.equals(false);
	    		WarehouseTracer.sMessage = "From and To locations cannot be the same. " + newline + "Ubicacion DE..PARA debe ser diferente.";
				new MessageCenter().setVisible(true);
				toText.setSelectionStart(0);
				toText.setSelectionEnd(toText.getText().length());
				toText.requestFocus();
			}
			
			if (Long.parseLong(qtyText.getText()) < 1500) {
				
				/*String sFilePath = "";
				String sFileName = "/Desktop/ErrorLog.txt";
				String sFileName = "/home/user/ErrorLog.txt";
				String sLogEntry = "***";
				
				java.io.File currentDir = new java.io.File("");
				sFilePath = currentDir.getAbsolutePath();*/
				
			    /*BufferedWriter out = new BufferedWriter(new FileWriter(sFilePath + sFileName, true));*/
				out.write(palletNbr + "|" + fromLoc + "|" + toLocation + "|" + qty + "|" + getDateTime() + "|" + WarehouseTracer.sUserID + "|" + getDateTime() + "|" + sPalletItemNo + "|" + WarehouseTracer.computerName + "|" + WarehouseTracer.sUserName + "\r\n");
			   	out.close();
			   	
			   	ResetData();
			}else{
				WarehouseTracer.sMessage = "Quantity value must be less than 1500. " + newline + "Cantidad de valor deve de ser menos de 1500.";
				new MessageCenter().setVisible(true);
				WarehouseTracer.bDataOK.equals(false);
				qtyText.setSelectionStart(0);
				qtyText.setSelectionEnd(qtyText.getText().length());
				qtyText.requestFocus();
			}

			
		} catch (Exception e) {
			e.printStackTrace();
			
			if (out != null) {
				out.close();
			}
		}
		
		finally {
			if (out != null) {
				out.close();
			}
		}
			
	}
	
	private String getDateTime() {
		DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
	    Date date = new Date();
	    return dateFormat.format(date);
	} 
	
	public static boolean isNumeric(String inputData) {  return inputData.matches("-?\\d+(.\\d+)?");}

	public void keyTyped(KeyEvent arg0) {
		
	}
	

}

Can you make a small complete program that compiles, executes and demos the problem?
1262 lines of code doesn't fit in a small program.
The program is tooooooooooooo big.

Also I do NOT have any of these packages:

import org.dyno.visual.swing.layouts.Constraints;
import org.dyno.visual.swing.layouts.GroupLayout;
import org.dyno.visual.swing.layouts.Leading;

Edited 6 Years Ago by NormR1: n/a

Here is a small program that demos the problem. Thanks for your help!!!

import java.util.ArrayList;

public class arrayListTest {

	
	public static void main(String[] args) {
		ArrayListTest();
	}
	
	private static void ArrayListTest() {
		ArrayList<PalletLocations1> palletLocList = new ArrayList<PalletLocations1>();
				
		try {
			
				PalletLocations1 palLoc = new PalletLocations1();
				
		    	for(int i = 0; i < 3 ; i++){
		    		palLoc.setPalletNbr("Pallet " + i);
					palLoc.setLocation("Location " + i);
					palLoc.setQty("Quantity " + i);
					palLoc.setItemNbr("Item " + i);
					palletLocList.add(palLoc);
				}
			    	
				String toText = palletLocList.get(0).location;
				String qtyText = palletLocList.get(0).qty;
				
		}
		
		catch (Exception e) {
			e.printStackTrace();
		}
		
		finally {
			
		}
	}
}
public class PalletLocations1 {
	public String palletNbr;
	public String location;
	public String qty;
	public String itemNbr;
	
	public void addPalletLocation(String sPalletNbr, String sLocation, String sQty, String sItemNbr) {
		palletNbr = sPalletNbr;
		location = sLocation;
	    qty = sQty;
	    itemNbr = sItemNbr;
	}

	public String getPalletNbr() {
		return palletNbr;
	}

	public void setPalletNbr(String palletNbr) {
		this.palletNbr = palletNbr;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public String getQty() {
		return qty;
	}

	public void setQty(String qty) {
		this.qty = qty;
	}

	public String getItemNbr() {
		return itemNbr;
	}

	public void setItemNbr(String itemNbr) {
		this.itemNbr = itemNbr;
	}

}

How does it demo the problem? I don't see any comments in the code saying:
// ******* HERE X should be Y

There are no print outs

When I execute the code, nothing is output. The job runs and exits???

One problem I'm seeing in your demo is that you only create one PalLoc object. Move the new PalLoc() instruction into the for loop, so that you're adding a different object to the arraylist each time.
I believe what you're doing here is creating one PalLoc object and then repeatedly changing its fields, so it ends up with one object whose Location is Loaction2, quantity is Quantity2, and so forth.

Edited 6 Years Ago by jon.kiparsky: corrected fencepost error

How does it demo the problem? I don't see any comments in the code saying:
// ******* HERE X should be Y

There are no print outs

When I execute the code, nothing is output. The job runs and exits???

Updated code to include system.out.printlns and some comments. Thanks.

import java.util.ArrayList;

public class arrayListTest {

	
	public static void main(String[] args) {
		ArrayListTest();
	}
	
	private static void ArrayListTest() {
		ArrayList<PalletLocations1> palletLocList = new ArrayList<PalletLocations1>();
				
		try {
			
				PalletLocations1 palLoc = new PalletLocations1();
				
		    	for(int i = 0; i < 3 ; i++){
		    		palLoc.setPalletNbr("Pallet " + i);
					palLoc.setLocation("Location " + i);
					palLoc.setQty("Quantity " + i);
					palLoc.setItemNbr("Item " + i);
					palletLocList.add(palLoc);
				}
			    	
				String toText = palletLocList.get(0).location;
				String qtyText = palletLocList.get(0).qty;
				
				//I would expect Location to equal Location 0 at this point but it comes out as Location 2
				System.out.println("Location = " + toText);
				//I would expect Quantity to equal Quantity 0 at this point but it comes out as Location 2				
				System.out.println("Quantity = " + qtyText);
		}
		
		catch (Exception e) {
			e.printStackTrace();
		}
		
		finally {
			
		}
	}
}

Yes, I just tested the post by jon.kiparsky's. It seems to be working. Thank you all for your help. Even if you didn't post a solution, the questions asked help me better understand java.

Thanks again.

This question has already been answered. Start a new discussion instead.