Results 1 to 4 of 4
  1. #1
    innovo is offline Member
    Join Date
    Jul 2015
    Posts
    84
    Rep Power
    0

    Default How to return string value to string

    Hello everyone, lately I have been making an application to open CSV files, write to them and save them into a certain directory.


    Currently this is one part of what I'm doing. I have converted an object to a string value, but I am unable to return that string value to my string variable "stringthing". What "stringthing" is supposed to do is whatever value it reads will be loaded into a combobox. From there the string value is in a dropdown menu and can be selected

    I have all of the latter end set up in my package via netbeans, and by manually putting in string values via "public static String stringthing="yes"; " For example "yes" would then appear in a dropdown menu. What I want to do is be able to read a csv file and put those values into a combobox. So far however I can't return the string value to stringthing

    [CODE]
    package evansinterface;
    import java.io.BufferedReader;
    import java.util.Scanner;
    import java.io.FileReader;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.List;
    import evansinterface.Student;
    import java.io.PrintStream;

    /**
    * @author
    *
    */

    public class CsvFileReader {

    //Delimiter used in CSV file
    public static String COMMA_DELIMITER = ",";
    public static String stringthing;
    //public static List<Object> students;
    //Student attributes index
    public static int STUDENT_ID_IDX = 0;
    public static int STUDENT_FNAME_IDX = 1;
    public static int STUDENT_LNAME_IDX = 2;
    public static int STUDENT_GENDER = 3;
    public static int STUDENT_AGE = 4;
    public static String Scanner;



    //}
    /**readCsvFile
    *
    * @param fileName
    */
    public static String readCsvFile(String fileName) {

    BufferedReader fileReader = null;

    try {

    //Create a new list of student to be filled by CSV file data
    List students = new ArrayList();
    String line = "";

    //Create the file reader
    fileReader = new BufferedReader(new FileReader(fileName));

    //Read the CSV file header to skip it

    fileReader.readLine();

    //Read the file line by line starting from the second line
    while ((line = fileReader.readLine()) != null) {
    //Get all tokens available in line
    String[] tokens = line.split(COMMA_DELIMITER);
    if (tokens.length > 0) {
    //Create a new student object and fill his data
    Student student = new Student(Long.parseLong(tokens[STUDENT_ID_IDX]), tokens[STUDENT_FNAME_IDX], tokens[STUDENT_LNAME_IDX], tokens[STUDENT_GENDER], Integer.parseInt(tokens[STUDENT_AGE]));
    students.add(student);
    }
    }

    //Print the new student list
    for (Object student : students) {
    stringthing = student.toString();
    System.out.println(stringthing);
    return stringthing;




    }
    }
    catch ( IOException | NumberFormatException e) {
    System.out.println("Error in CsvFileReader !!!");
    } finally {
    try {
    fileReader.close();
    } catch (IOException e) {
    System.out.println("Error while closing fileReader !!!");
    }
    }
    return stringthing;
    }
    public void takeNames(String fName){

    Scanner scanner = new Scanner(System.in);
    System.out.println("Enter your first and last name");
    fName = scanner.next();
    System.out.printf("Hello %s",Scanner); //return statement needed!

    }

    CsvFileReader() {
    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    }
    [CODE/]
    Last edited by innovo; 07-09-2015 at 03:06 PM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: How to return string value to string

    I see println() statements in the code. What do they print out when the program is executed?

    Note: Having a return statement inside of a loop will exit the loop when it is executed.



    Please edit the code and fix the code's formatting. The poor indentations make the code hard to read.
    Last edited by Norm; 07-09-2015 at 02:12 PM.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    innovo is offline Member
    Join Date
    Jul 2015
    Posts
    84
    Rep Power
    0

    Default Re: How to return string value to string

    What is printed out is


    stuff :1, firstName=Anode1, lastName=Anode2, gender=Anode3, age=25]


    which comes from a .csv file that java made and wrote to.

    I'll edit the post and put the other 2 java files into it

  4. #4
    innovo is offline Member
    Join Date
    Jul 2015
    Posts
    84
    Rep Power
    0

    Default Re: How to return string value to string

    Quote Originally Posted by Norm View Post
    I see println() statements in the code. What do they print out when the program is executed?

    Note: Having a return statement inside of a loop will exit the loop when it is executed.



    Please edit the code and fix the code's formatting. The poor indentations make the code hard to read.


    Sorry, also for some reason I can't edit what I posted so i'll put it here. If it still sucks i'll post again
    Hello everyone, lately I have been making an application to open CSV files, write to them and save them into a certain directory.


    Currently this is one part of what I'm doing. I have converted an object to a string value, but I am unable to return that string value to my string variable "stringthing". What "stringthing" is supposed to do is whatever value it reads will be loaded into a combobox. From there the string value is in a dropdown menu and can be selected

    I have all of the latter end set up in my package via netbeans, and by manually putting in string values via "public static String stringthing="yes"; " For example "yes" would then appear in a dropdown menu. What I want to do is be able to read a csv file and put those values into a combobox. So far however I can't return the string value to stringthing

    Java Code:
    *
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package evansinterface;
    import java.io.BufferedReader;
    import java.util.Scanner;
    import java.io.FileReader;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.List;
    import evansinterface.Student;
    import java.io.PrintStream;
    
    /**
     * @author 
     *
     */
    
    public class CsvFileReader {
    	
    	//Delimiter used in CSV file
    	public static  String COMMA_DELIMITER = ",";
            public static  String stringthing;
            //public static List<Object> students;
    	//Student attributes index
    	public static  int STUDENT_ID_IDX = 0;
    	public static  int STUDENT_FNAME_IDX = 1;
    	public static  int STUDENT_LNAME_IDX = 2;
    	public static  int STUDENT_GENDER = 3; 
    	public static  int STUDENT_AGE = 4;
            public static String Scanner;
    	
            
     
    //}
        /**readCsvFile
         *
         * @param fileName
         */
        public static String readCsvFile(String fileName) {
    
    		BufferedReader fileReader = null;
         
            try {
            	
            	//Create a new list of student to be filled by CSV file data 
            	List students = new ArrayList();
                String line = "";
                
                //Create the file reader
                fileReader = new BufferedReader(new FileReader(fileName));
                
                //Read the CSV file header to skip it
               
                fileReader.readLine();
                
                //Read the file line by line starting from the second line
                while ((line = fileReader.readLine()) != null) {
                    //Get all tokens available in line
                    String[] tokens = line.split(COMMA_DELIMITER);
                    if (tokens.length > 0) {
                    	//Create a new student object and fill his  data
    					Student student = new Student(Long.parseLong(tokens[STUDENT_ID_IDX]), tokens[STUDENT_FNAME_IDX], tokens[STUDENT_LNAME_IDX], tokens[STUDENT_GENDER], Integer.parseInt(tokens[STUDENT_AGE]));
    					students.add(student);
    				}
                }
                
                //Print the new student list
                for (Object student : students) {	
                stringthing = student.toString();
                System.out.println(stringthing);
                return stringthing;
                
               
                
          
    			}
            } 
            catch ( IOException | NumberFormatException e) {
            	System.out.println("Error in CsvFileReader !!!");
            } finally {
                try {
                    fileReader.close();
                } catch (IOException e) {
                	System.out.println("Error while closing fileReader !!!");
                }
            }
    return stringthing;
    	}
               public void takeNames(String fName){
    
    Scanner scanner = new Scanner(System.in);
    System.out.println("Enter your first and last name");
    fName = scanner.next();
    System.out.printf("Hello %s",Scanner); //return statement needed!
    
            }
    
        CsvFileReader() {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    }

    What do I need to change? I'm stumped here. I recently started learning Java, so if anything is noobish I apologize.

    There are also 2 other files the application uses

    this one writes .csv files

    Java Code:
    package evansinterface;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.List;
    import evansinterface.Student;
    
    /**
     * @author 
     * 
     */
    public class CsvFileWriter {
    	
    	//Delimiter used in CSV file
    	public static final String COMMA_DELIMITER = ",";
    	private static final String NEW_LINE_SEPARATOR = "\n";
    	//CSV file header
    	public static final String FILE_HEADER = "id,firstName,lastName,gender,age\t"+"id,firstName,lastName,gender,age";
    
    	public static void writeCsvFile(String fileName) {
    		
    		//Create new students objects
    		Student student1 = new Student(1, "Anode1", "Anode2", "Anode3", 25);
    		Student student2 = new Student(2, "lotnumber", "lotnumber2", "lotnumber3", 23);
    		Student student3 = new Student(3, "lotnumber4", "lotnumber5", "lotnumber6", 24);
    		Student student4 = new Student(4, "lotnumber7", "lotnumber8", "lotnumber9", 20);
    		Student student5 = new Student(5, "lotnumber10", "lotnumber11", "lotnumber12", 22);
    		Student student6 = new Student(6, "lotnumber13", "lotnumber14", "lotnumber15", 21);
    		
    		//Create a new list of student objects
    		Student[] students = new Student[6];
    		students[0] = student1;
    		students[1] = student2;
    		students[2] = student3;
    		students[3] = student4;
    		students[4] = student5;
    		students[5] = student6;
    		
    		
    		FileWriter fileWriter = null;
    				
    		try {
    			fileWriter = new FileWriter(fileName); //where you'll designate destination file
    
    			//Write the CSV file header
    			fileWriter.append(FILE_HEADER.toString());
    			
    			//Add a new line separator after the header
    			fileWriter.append(NEW_LINE_SEPARATOR);
    			
    			//Write a new student object list to the CSV file
    			for (Student student : students) {
    				fileWriter.append(String.valueOf(student.getId()));
    				fileWriter.append(COMMA_DELIMITER);
    				fileWriter.append(student.getFirstName());
    				fileWriter.append(COMMA_DELIMITER);
    				fileWriter.append(student.getLastName());
    				fileWriter.append(COMMA_DELIMITER);
    				fileWriter.append(student.getGender());
    				fileWriter.append(COMMA_DELIMITER);
    				fileWriter.append(String.valueOf(student.getAge()));
    				fileWriter.append(NEW_LINE_SEPARATOR);
    			}
    
    			
    			
    			System.out.println("CSV file was created successfully !!!");
    			
    		} catch (Exception e) {
    			System.out.println("Error in CsvFileWriter !!!");
    			e.printStackTrace();
    		} finally {
    			
    			try {
    				fileWriter.flush();
    				fileWriter.close();
    			} catch (IOException e) {
    				System.out.println("Error while flushing/closing fileWriter !!!");
                    e.printStackTrace();
    			}
    			
    		}
    	}
    }

    and this code just defines "students" I believe. I did not write all of this but I am just using it for what I want to do.


    Java Code:
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package evansinterface;
    
    /**
     * @author 
     *
     */
    //public String firstName;
    public class Student {
    	
    	private long id;
    	private String firstName;
    	private String lastName;
    	private String gender;
    	private int age;
    	/**
    	 * @param id
    	 * @param firstName
    	 * @param lastName
    	 * @param gender
    	 * @param age
    	 */
    	public Student(long id, String firstName, String lastName, String gender,
    			int age) {
    		super();
    		this.id = id;
    		this.firstName = firstName;
    		this.lastName = lastName;
    		this.gender = gender;
    		this.age = age;
    	}
    	/**
    	 * @return the id
    	 */
    	public long getId() {
    		return id;
    	}
    	/**
    	 * @param id the id to set
    	 */
    	public void setId(long id) {
    		this.id = id;
    	}
    	/**
    	 * @return the firstName
    	 */
    	public String getFirstName() {
    		return firstName;
    	}
    	/**
    	 * @param firstName the firstName to set
    	 */
    	public void setFirstName(String firstName) {
    		this.firstName = firstName;
    	}
    	/**
    	 * @return the lastName
    	 */
    	public String getLastName() {
    		return lastName;
    	}
    	/**
    	 * @param lastName the lastName to set
    	 */
    	public void setLastName(String lastName) {
    		this.lastName = lastName;
    	}
    	/**
    	 * @return the gender
    	 */
    	public String getGender() {
    		return gender;
    	}
    	/**
    	 * @param gender the gender to set
    	 */
    	public void setGender(String gender) {
    		this.gender = gender;
    	}
    	/**
    	 * @return the age
    	 */
    	public int getAge() {
    		return age;
    	}
    	/**
    	 * @param age the age to set
    	 */
    	public void setAge(int age) {
    		this.age = age;
    	}
    	
    	@Override
    	public String toString() {
    		return "stuff :" + id + ", firstName=" + firstName
    				+ ", lastName=" + lastName + ", gender=" + gender + ", age="
    				+ age + "]";
    	}
    }


    after all 3 of those files there is the GUI which puts everything together
    Java Code:
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package evansinterface;
    //import java.io.IOException;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    //import java.io.*;
    //import java.io.FileWriter;
    //import java.io.IOException;
    //import java.util.ArrayList;
    //import java.util.List;
    //import evansinterface.Student;
    //import java.io.BufferedReader;
    //import java.io.FileReader;
    import java.io.IOException;
    //import java.util.ArrayList;
    //import java.util.List;
    
    
    
    /**
     *
     * @author 
     */ 
    public class mainWindow extends javax.swing.JFrame {
    public static String yup=CsvFileWriter.FILE_HEADER;
    public static String anode0=CsvFileReader.stringthing;
    public static String anode1="anode 1";
    public static String anode2="anode 2";
    public static String anode3="anode 3";
    public static String anode4="anode 4";
    public static String anode5="anode 5";
    public static String cathode1="cathode 1";
    public static String headerglassing="headerglassinglot";
    public static String tantalumlot="tantalum lot";
        /**
         * Creates new form mainWindow
         */
        public mainWindow() {
            initComponents();
           // createWriter();
          //System.out.printf(anode0);
          
          //System.out.println("tried to open excelinC.exe file");
          //jComboBox1.addItem(CsvFileReader.COMMA_DELIMITER);
          //jComboBox1.addItem(CsvFileReader.student.toString());
          jComboBox1.addItem(yup);
          jComboBox1.addItem(anode0);
          jComboBox1.addItem(anode1);
          jComboBox1.addItem(anode2);
          jComboBox1.addItem(anode3);
          jComboBox1.addItem(anode4);
          jComboBox1.addItem(anode5);
          jComboBox1.addItem("N/A");
          jComboBox2.addItem(anode1);
          jComboBox2.addItem(anode2);
          jComboBox2.addItem(anode3);
          jComboBox2.addItem(anode4);
          jComboBox2.addItem(anode5);
          jComboBox2.addItem("N/A");
          jComboBox3.addItem(anode1);
          jComboBox3.addItem(anode2);
          jComboBox3.addItem(anode3);
          jComboBox3.addItem(anode4);
          jComboBox3.addItem(anode5);
          jComboBox3.addItem("N/A");
          jComboBox4.addItem(anode1);
          jComboBox4.addItem(anode2);
          jComboBox4.addItem(anode3);
          jComboBox4.addItem(anode4);
          jComboBox4.addItem(anode5);
          jComboBox4.addItem("N/A");
          jComboBox5.addItem(anode1);
          jComboBox5.addItem(anode2);
          jComboBox5.addItem(anode3);
          jComboBox5.addItem(anode4);
          jComboBox5.addItem(anode5);
          jComboBox5.addItem("N/A");
          jComboBox6.addItem(anode1);
          jComboBox6.addItem(anode2);
          jComboBox6.addItem(anode3);
          jComboBox6.addItem(anode4);
          jComboBox6.addItem(anode5);
          jComboBox6.addItem("N/A");
          jComboBox7.addItem(anode1);
          jComboBox7.addItem(anode2);
          jComboBox7.addItem(anode3);
          jComboBox7.addItem(anode4);
          jComboBox7.addItem(anode5);
          jComboBox7.addItem("N/A");
          jComboBox8.addItem(anode1);
          jComboBox8.addItem(anode2);
          jComboBox8.addItem(anode3);
          jComboBox8.addItem(anode4);
          jComboBox8.addItem(anode5);
          jComboBox8.addItem("N/A");
          
         // String.valueOf("that");
          
          //createReader();
          
        }
    
        //private void createWriter(){
         //   writer = new CsvFileWriter();
            
        //}
       
        //private void createReader(){
     //       reader = new CsvFileReader();
       // }
        /**
         * This method is called from within the constructor to initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is always
         * regenerated by the Form Editor.
         */
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
        private void initComponents() {
    
            jFrame1 = new javax.swing.JFrame();
            jDialog1 = new javax.swing.JDialog();
            jMenuItem1 = new javax.swing.JMenuItem();
            jTextField1 = new javax.swing.JTextField();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jLabel3 = new javax.swing.JLabel();
            jButton1 = new javax.swing.JButton();
            jButton2 = new javax.swing.JButton();
            jButton3 = new javax.swing.JButton();
            jButton4 = new javax.swing.JButton();
            jButton5 = new javax.swing.JButton();
            jComboBox1 = new javax.swing.JComboBox();
            jComboBox2 = new javax.swing.JComboBox();
            jProgressBar1 = new javax.swing.JProgressBar();
            jButton6 = new javax.swing.JButton();
            jButton7 = new javax.swing.JButton();
            jLabel4 = new javax.swing.JLabel();
            jComboBox3 = new javax.swing.JComboBox();
            jButton8 = new javax.swing.JButton();
            jLabel5 = new javax.swing.JLabel();
            jComboBox4 = new javax.swing.JComboBox();
            jLabel6 = new javax.swing.JLabel();
            jLabel7 = new javax.swing.JLabel();
            jComboBox5 = new javax.swing.JComboBox();
            jComboBox6 = new javax.swing.JComboBox();
            jLabel8 = new javax.swing.JLabel();
            jComboBox7 = new javax.swing.JComboBox();
            jButton9 = new javax.swing.JButton();
            jButton10 = new javax.swing.JButton();
            jButton11 = new javax.swing.JButton();
            jButton12 = new javax.swing.JButton();
            jLabel9 = new javax.swing.JLabel();
            jComboBox8 = new javax.swing.JComboBox();
            jButton13 = new javax.swing.JButton();
    
            javax.swing.GroupLayout jFrame1Layout = new javax.swing.GroupLayout(jFrame1.getContentPane());
            jFrame1.getContentPane().setLayout(jFrame1Layout);
            jFrame1Layout.setHorizontalGroup(
                jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 400, Short.MAX_VALUE)
            );
            jFrame1Layout.setVerticalGroup(
                jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 300, Short.MAX_VALUE)
            );
    
            javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
            jDialog1.getContentPane().setLayout(jDialog1Layout);
            jDialog1Layout.setHorizontalGroup(
                jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 400, Short.MAX_VALUE)
            );
            jDialog1Layout.setVerticalGroup(
                jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 300, Short.MAX_VALUE)
            );
    
            jMenuItem1.setText("jMenuItem1");
    
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    
            jTextField1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jTextField1ActionPerformed(evt);
                }
            });
    
            jLabel1.setText("PN");
    
            jLabel2.setText("Anode1");
    
            jLabel3.setText("Anode 2");
    
            jButton1.setText("Okay");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
                }
            });
    
            jButton2.setText("Okay");
            jButton2.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton2ActionPerformed(evt);
                }
            });
    
            jButton3.setText("Okay");
            jButton3.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton3ActionPerformed(evt);
                }
            });
    
            jButton4.setText("Back");
            jButton4.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton4ActionPerformed(evt);
                }
            });
    
            jButton5.setText("Next");
            jButton5.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton5ActionPerformed(evt);
                }
            });
    
            jComboBox1.setToolTipText("");
            jComboBox1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jComboBox1ActionPerformed(evt);
                }
            });
    
            jComboBox2.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jComboBox2ActionPerformed(evt);
                }
            });
    
            jProgressBar1.setMaximum(40);
    
            jButton6.setText("Help");
            jButton6.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton6ActionPerformed(evt);
                }
            });
    
            jButton7.setText("Write CSV");
            jButton7.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton7ActionPerformed(evt);
                }
            });
    
            jLabel4.setText("Anode 3");
    
            jComboBox3.setAutoscrolls(true);
            jComboBox3.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jComboBox3ActionPerformed(evt);
                }
            });
    
            jButton8.setText("Okay");
            jButton8.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton8ActionPerformed(evt);
                }
            });
    
            jLabel5.setText("Anode 4");
    
            jComboBox4.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jComboBox4ActionPerformed(evt);
                }
            });
    
            jLabel6.setText("Anode 5");
    
            jLabel7.setText("Cathode Lot");
    
            jComboBox5.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jComboBox5ActionPerformed(evt);
                }
            });
    
            jComboBox6.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jComboBox6ActionPerformed(evt);
                }
            });
    
            jLabel8.setText("Header Glassing Lot");
    
            jComboBox7.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "" }));
            jComboBox7.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jComboBox7ActionPerformed(evt);
                }
            });
    
            jButton9.setText("Okay");
            jButton9.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton9ActionPerformed(evt);
                }
            });
    
            jButton10.setText("Okay");
            jButton10.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton10ActionPerformed(evt);
                }
            });
    
            jButton11.setText("Okay");
            jButton11.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton11ActionPerformed(evt);
                }
            });
    
            jButton12.setText("Okay");
            jButton12.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton12ActionPerformed(evt);
                }
            });
    
            jLabel9.setText("Tantalum Lot");
    
            jComboBox8.setToolTipText("");
            jComboBox8.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jComboBox8ActionPerformed(evt);
                }
            });
    
            jButton13.setText("Okay");
            jButton13.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton13ActionPerformed(evt);
                }
            });
    
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(layout.createSequentialGroup()
                            .addContainerGap()
                            .addComponent(jProgressBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGroup(layout.createSequentialGroup()
                            .addContainerGap(93, Short.MAX_VALUE)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel1)
                                .addComponent(jButton4)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jTextField1))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jLabel2)
                                        .addGroup(layout.createSequentialGroup()
                                            .addGap(6, 6, 6)
                                            .addComponent(jButton2))
                                        .addComponent(jComboBox2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addGroup(layout.createSequentialGroup()
                                            .addGap(6, 6, 6)
                                            .addComponent(jButton3))
                                        .addComponent(jLabel3)
                                        .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(18, 18, 18)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                            .addComponent(jLabel4)
                                            .addGap(56, 56, 56))
                                        .addGroup(layout.createSequentialGroup()
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                .addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(jComboBox4, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                            .addGap(40, 40, 40)))
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jLabel5)
                                        .addComponent(jComboBox3, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jButton10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jLabel6)
                                        .addComponent(jComboBox5, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jButton12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jComboBox6, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(layout.createSequentialGroup()
                                            .addComponent(jLabel8)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(jLabel9)
                                            .addGap(0, 119, Short.MAX_VALUE))
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                .addComponent(jButton11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(jComboBox7, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                .addComponent(jButton13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(jComboBox8, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(109, 109, 109)
                                    .addComponent(jButton7)
                                    .addGap(95, 95, 95)
                                    .addComponent(jButton6)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jButton5)))))
                    .addGap(81, 81, 81))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(54, 54, 54)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel2)
                                .addComponent(jLabel3))
                            .addGap(14, 14, 14))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addContainerGap()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel4)
                                .addComponent(jLabel5)
                                .addComponent(jLabel6)
                                .addComponent(jLabel7)
                                .addComponent(jLabel8)
                                .addComponent(jLabel9))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jComboBox5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jComboBox6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jComboBox7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jComboBox8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(14, 14, 14)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jButton1)
                                .addComponent(jButton2)
                                .addComponent(jButton3)
                                .addComponent(jButton8)))
                        .addGroup(layout.createSequentialGroup()
                            .addGap(18, 18, 18)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jButton9)
                                .addComponent(jButton10)
                                .addComponent(jButton12)))
                        .addGroup(layout.createSequentialGroup()
                            .addGap(18, 18, 18)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jButton11)
                                .addComponent(jButton13))))
                    .addGap(35, 35, 35)
                    .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton4)
                            .addComponent(jButton7)
                            .addComponent(jButton6))
                        .addComponent(jButton5))
                    .addContainerGap(37, Short.MAX_VALUE))
            );
    
            pack();
        }// </editor-fold>                        
    
        private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {                                            
              inString1 = jTextField1.getText();
    
        }                                           
    
        private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            // TODO add your handling code here:
        }                                        
    
        private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                         
         jTextField1.setText(jComboBox1.getSelectedItem().toString());
        }                                        
    
        private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        CsvFileReader.readCsvFile("Z:\\database\\outputFile01.csv");    // TODO add your handling code here:
        }                                        
    
        private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // instring2 = jComboBox1.addItem(yup);  // TODO add your handling code here:
         
        }                                          
    
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            //TODO add your handling code here:
        }                                        
    
        private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) {                                           
            CsvFileReader.readCsvFile("Z:\\database\\outputFile01.csv"); // TODO add your handling code here:
        }                                          
    
        private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {                                         
          
    
        // TODO add your handling code here:
        }                                        
    
        private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {                                         
          try {
                Process process = Runtime.getRuntime().exec( "cmd.exe /C start wat.vbs" );  // open "help" file
           } catch (IOException ex) {
               Logger.getLogger(mainWindow.class.getName()).log(Level.SEVERE, null, ex);
           }
             System.out.println("tried to open excelinC.exe file");
        }                                        
    
        private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            CsvFileWriter.writeCsvFile("Z:\\database\\outputFile01.csv");
        }                                        
    
        private void jComboBox3ActionPerformed(java.awt.event.ActionEvent evt) {                                           
            // TODO add your handling code here:
             //class ParseCSV {
     // public  void main(String[] args) {
       // try {
          //csv file containing data
       //   String strFile = "z:\\database\\serialnumbers.csv";
        //  CSVReader reader = new CSVReader(new FileReader(strFile));
        //  String [] nextLine;
         // int lineNumber = 0;
          //while ((nextLine = reader.readNext()) != null) {
          //  lineNumber++;
           // System.out.println("Line # " + lineNumber);
    
            // nextLine[] is an array of values from the line
           // System.out.println(nextLine[4] + "etc...");
          //}
        
        //}
        
        //catch {
              //    System.out.println("UH OH");
                  
      
      
    
      
        }                                          
    
        private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            // TODO add your handling code here:
        }                                        
    
        private void jComboBox4ActionPerformed(java.awt.event.ActionEvent evt) {                                           
            // TODO add your handling code here:
        }                                          
    
        private void jComboBox5ActionPerformed(java.awt.event.ActionEvent evt) {                                           
            // TODO add your handling code here:
        }                                          
    
        private void jComboBox6ActionPerformed(java.awt.event.ActionEvent evt) {                                           
            // TODO add your handling code here:
        }                                          
    
        private void jComboBox7ActionPerformed(java.awt.event.ActionEvent evt) {                                           
            // TODO add your handling code here:
        }                                          
    
        private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            // TODO add your handling code here:
        }                                        
    
        private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {                                          
            // TODO add your handling code here:
        }                                         
    
        private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {                                          
            // TODO add your handling code here:
        }                                         
    
        private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {                                          
            // TODO add your handling code here:
        }                                         
    
        private void jComboBox8ActionPerformed(java.awt.event.ActionEvent evt) {                                           
            // TODO add your handling code here:
        }                                          
    
        private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {                                          
            // TODO add your handling code here:
        }                                         
    
        /**
         * @param args the command line arguments
         */
        public static void main(String args[]) {
            /* Set the Nimbus look and feel */
            //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
            /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
             * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
             */
            try {
                for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                    if ("Nimbus".equals(info.getName())) {
                        javax.swing.UIManager.setLookAndFeel(info.getClassName());
                        break;
                    }
                }
            } catch (ClassNotFoundException ex) {
                java.util.logging.Logger.getLogger(mainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (InstantiationException ex) {
                java.util.logging.Logger.getLogger(mainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                java.util.logging.Logger.getLogger(mainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (javax.swing.UnsupportedLookAndFeelException ex) {
                java.util.logging.Logger.getLogger(mainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            }
            //</editor-fold>
    
            /* Create and display the form */
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new mainWindow().setVisible(true);
                }
            });
        }
    
        // Variables declaration - do not modify                     
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton10;
        private javax.swing.JButton jButton11;
        private javax.swing.JButton jButton12;
        private javax.swing.JButton jButton13;
        private javax.swing.JButton jButton2;
        private javax.swing.JButton jButton3;
        private javax.swing.JButton jButton4;
        private javax.swing.JButton jButton5;
        private javax.swing.JButton jButton6;
        private javax.swing.JButton jButton7;
        private javax.swing.JButton jButton8;
        private javax.swing.JButton jButton9;
        private javax.swing.JComboBox jComboBox1;
        private javax.swing.JComboBox jComboBox2;
        private javax.swing.JComboBox jComboBox3;
        private javax.swing.JComboBox jComboBox4;
        private javax.swing.JComboBox jComboBox5;
        private javax.swing.JComboBox jComboBox6;
        private javax.swing.JComboBox jComboBox7;
        private javax.swing.JComboBox jComboBox8;
        private javax.swing.JDialog jDialog1;
        private javax.swing.JFrame jFrame1;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JLabel jLabel3;
        private javax.swing.JLabel jLabel4;
        private javax.swing.JLabel jLabel5;
        private javax.swing.JLabel jLabel6;
        private javax.swing.JLabel jLabel7;
        private javax.swing.JLabel jLabel8;
        private javax.swing.JLabel jLabel9;
        private javax.swing.JMenuItem jMenuItem1;
        private javax.swing.JProgressBar jProgressBar1;
        private javax.swing.JTextField jTextField1;
        // End of variables declaration                   
    
    private CsvFileWriter writer;
    private String inString1;
    private String instring2;
    }

Similar Threads

  1. Using the return statement to display a string
    By Hoverboy in forum New To Java
    Replies: 6
    Last Post: 11-17-2010, 09:22 AM
  2. Why dosent return new string
    By karq in forum New To Java
    Replies: 8
    Last Post: 08-04-2010, 08:51 AM
  3. How do i return a random String from an array?
    By Grendel0 in forum New To Java
    Replies: 9
    Last Post: 03-11-2010, 10:11 AM
  4. Static String Return Type
    By Java_Developer in forum New To Java
    Replies: 17
    Last Post: 10-03-2009, 06:07 PM
  5. HashMap String Return
    By kizilbas1 in forum New To Java
    Replies: 1
    Last Post: 03-10-2008, 03:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •