I am doing Gui's on Netbeans and am writing a program that sells flower ornaments and such. I have everything added to an arraylist. But when it comes to showing, I am on another tab and need to pass the arraylist to that method for display, any help? Link me to some tutorial if anything please.

Meaning I would have to display from the same button action... Can't send the Arraylist information to be used in another method? Right now I am writing down to file and up to be used in the second method in order to have the information. Any way I can do this with an array. Keeping everything in their respective tabs/ methods?

public void SubmitInformation() {
        String flowerType = "", name = "", address = "", phoneNum = "", flowerArrange = "",
                quantity = "", orderNum = "", gift = "";
        
        
        
        if (jComboBox1.getSelectedItem().toString().contentEquals("Roses")){
            flowerType = jComboBox1.getSelectedItem().toString();
            if (jRadioButton1.isSelected()){
                flowerArrange = "Ornamental";
                if (jSpinner1.getModel().getValue().toString().equals("0"))
                JOptionPane.showMessageDialog(mainPanel, "Please choose a quantity of Arrangements.");
            else
                quantity = jSpinner1.getValue().toString();
            
            }
            else if (jRadioButton2.isSelected()){
                flowerArrange = "Bouquet";
                if (jSpinner1.getModel().getValue().toString().equals("0"))
                JOptionPane.showMessageDialog(mainPanel, "Please choose a quantity of Arrangements.");
                else 
                quantity = jSpinner1.getValue().toString();
            
            }
            else if (jRadioButton3.isSelected()){
                flowerArrange = "Single Flower";
                if (jSpinner1.getModel().getValue().toString().equals("0"))
                JOptionPane.showMessageDialog(mainPanel, "Please choose a quantity of Arrangements.");
                else 
                quantity = jSpinner1.getValue().toString();
            
            }
            else
                JOptionPane.showMessageDialog(mainPanel, "Please choose an Arrangement");
        
            if (jTextField1.getText().toString().isEmpty())
                JOptionPane.showMessageDialog(mainPanel, "Please your name.");
            else
                name = jTextField1.getText().toString();
            if (jTextField2.getText().toString().isEmpty())
                JOptionPane.showMessageDialog(mainPanel, "Please your address.");
            else 
                address = jTextField2.getText().toString();
            if (jTextField3.getText().toString().isEmpty())
                JOptionPane.showMessageDialog(mainPanel, "Please your phone number.");
            else
                phoneNum = jTextField3.getText().toString();
            
            
            if (jCheckBox1.isSelected())
                gift = "True";
            else 
                gift = "False";
            
            if (!jTextField1.getText().toString().isEmpty() & 
                !jTextField2.getText().toString().isEmpty() &
                !jTextField3.getText().toString().isEmpty() &
                !jSpinner1.getModel().getValue().toString().equals("0")){
            Random r = new Random();
            orderNum = String.valueOf(r.nextInt(100000));
            
            JOptionPane.showMessageDialog(mainPanel, "Please write down this Order Number: " + orderNum + ".");
                try {
                    PrintWriter out = new PrintWriter("FlowerOrders.txt");
                    out.println(name);
                    out.println(address);
                    out.println(phoneNum);
                    out.println(orderNum);
                    out.println(flowerType);
                    out.println(flowerArrange);
                    out.println(quantity);
                    out.println(gift);
                    out.close();
                } catch (FileNotFoundException ex) {
                    JOptionPane.showMessageDialog(mainPanel, "File cannot be opened.");
                    Logger.getLogger(FlowersView.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
            
        else if (jComboBox1.getSelectedItem().toString().contentEquals("Lilies")){
            flowerType = jComboBox1.getSelectedItem().toString();
            if (jRadioButton1.isSelected()){
                flowerArrange = "Ornamental";
                if (jSpinner1.getModel().getValue().toString().equals("0"))
                JOptionPane.showMessageDialog(mainPanel, "Please choose a quantity of Arrangements.");
            else 
                quantity = jSpinner1.getValue().toString();
            
            }
            else if (jRadioButton2.isSelected()){
                flowerArrange = "Bouquet";
                if (jSpinner1.getModel().getValue().toString().equals("0"))
                JOptionPane.showMessageDialog(mainPanel, "Please choose a quantity of Arrangements.");
                else 
                quantity = jSpinner1.getValue().toString();
            
            }
            else if (jRadioButton3.isSelected()){
                flowerArrange = "Single Flower";
                if (jSpinner1.getModel().getValue().toString().equals("0"))
                JOptionPane.showMessageDialog(mainPanel, "Please choose a quantity of Arrangements.");
                else 
                quantity = jSpinner1.getValue().toString();
            
            }
            else
                JOptionPane.showMessageDialog(mainPanel, "Please choose an Arrangement");
        
            if (jTextField1.getText().toString().isEmpty())
                JOptionPane.showMessageDialog(mainPanel, "Please your name.");
            else
                name = jTextField1.getText().toString();
            if (jTextField2.getText().toString().isEmpty())
                JOptionPane.showMessageDialog(mainPanel, "Please your address.");
            else 
                address = jTextField2.getText().toString();
            if (jTextField3.getText().toString().isEmpty())
                JOptionPane.showMessageDialog(mainPanel, "Please your phone number.");
            else
                phoneNum = jTextField3.getText().toString();
            
            
            if (jCheckBox1.isSelected())
                gift = "True";
            else 
                gift = "False";
            
            
            
            if (!jTextField1.getText().toString().isEmpty() & 
                !jTextField2.getText().toString().isEmpty() &
                !jTextField3.getText().toString().isEmpty() &
                !jSpinner1.getModel().getValue().toString().equals("0")){
            Random r = new Random();
            orderNum = String.valueOf(r.nextInt(100000));
            
            JOptionPane.showMessageDialog(mainPanel, "Please write down this Order Number: " + orderNum + ".");
            
            try {
                    PrintWriter out = new PrintWriter("FlowerOrders.txt");
                    out.println(name);
                    out.println(address);
                    out.println(phoneNum);
                    out.println(orderNum);
                    out.println(flowerType);
                    out.println(flowerArrange);
                    out.println(quantity);
                    out.println(gift);
                    out.close();
                } catch (FileNotFoundException ex) {
                    JOptionPane.showMessageDialog(mainPanel, "File cannot be opened.");
                    Logger.getLogger(FlowersView.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
        else if (jComboBox1.getSelectedItem().toString().contentEquals("Daisies")){
            flowerType = jComboBox1.getSelectedItem().toString();
            if (jRadioButton1.isSelected()){
                flowerArrange = "Ornamental";
                if (jSpinner1.getModel().getValue().toString().equals("0"))
                JOptionPane.showMessageDialog(mainPanel, "Please choose a quantity of Arrangements.");
            else
                quantity = jSpinner1.getValue().toString();
            
            }
            else if (jRadioButton2.isSelected()){
                flowerArrange = "Bouquet";
                if (jSpinner1.getModel().getValue().toString().equals("0"))
                JOptionPane.showMessageDialog(mainPanel, "Please choose a quantity of Arrangements.");
                else
                quantity = jSpinner1.getValue().toString();
            
            }
            else if (jRadioButton3.isSelected()){
                flowerArrange = "Single Flower";
                if (jSpinner1.getModel().getValue().toString().equals("0"))
                JOptionPane.showMessageDialog(mainPanel, "Please choose a quantity of Arrangements.");
                else
                quantity = jSpinner1.getValue().toString();
            
            }
            else
                JOptionPane.showMessageDialog(mainPanel, "Please choose an Arrangement");
        
            if (jTextField1.getText().toString().isEmpty())
                JOptionPane.showMessageDialog(mainPanel, "Please your name.");
            else
                name = jTextField1.getText().toString();
            if (jTextField2.getText().toString().isEmpty())
                JOptionPane.showMessageDialog(mainPanel, "Please your address.");
            else 
                address = jTextField2.getText().toString();
            if (jTextField3.getText().toString().isEmpty())
                JOptionPane.showMessageDialog(mainPanel, "Please your phone number.");
            else
                phoneNum = jTextField3.getText().toString();
            
            
            if (jCheckBox1.isSelected())
                gift = "True";
            else 
                gift = "False";
            
            if (!jTextField1.getText().toString().isEmpty() & 
                !jTextField2.getText().toString().isEmpty() &
                !jTextField3.getText().toString().isEmpty() &
                !jSpinner1.getModel().getValue().toString().equals("0")){
            Random r = new Random();
            orderNum = String.valueOf(r.nextInt(100000));
           
            JOptionPane.showMessageDialog(mainPanel, "Please write down this Order Number: " + orderNum + ".");
            
            try {
                    PrintWriter out = new PrintWriter("FlowerOrders.txt");
                    out.println(name);
                    out.println(address);
                    out.println(phoneNum);
                    out.println(orderNum);
                    out.println(flowerType);
                    out.println(flowerArrange);
                    out.println(quantity);
                    out.println(gift);
                    out.close();
                } catch (FileNotFoundException ex) {
                    JOptionPane.showMessageDialog(mainPanel, "File cannot be opened.");
                    Logger.getLogger(FlowersView.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
        else if (jComboBox1.getSelectedItem().toString().contentEquals("Sunflowers")){
            flowerType = jComboBox1.getSelectedItem().toString();
            if (jRadioButton1.isSelected()){
                flowerArrange = "Ornamental";
                if (jSpinner1.getModel().getValue().toString().equals("0"))
                JOptionPane.showMessageDialog(mainPanel, "Please choose a quantity of Arrangements.");
            else 
                quantity = jSpinner1.getValue().toString();
            
            }
            else if (jRadioButton2.isSelected()){
                flowerArrange = "Bouquet";
                if (jSpinner1.getModel().getValue().toString().equals("0"))
                JOptionPane.showMessageDialog(mainPanel, "Please choose a quantity of Arrangements.");
                else
                quantity = jSpinner1.getValue().toString();
            
            }
            else if (jRadioButton3.isSelected()){
                flowerArrange = "Single Flower";
                if (jSpinner1.getModel().getValue().toString().equals("0"))
                JOptionPane.showMessageDialog(mainPanel, "Please choose a quantity of Arrangements.");
                else
                quantity = jSpinner1.getValue().toString();
            
            }
            else
                JOptionPane.showMessageDialog(mainPanel, "Please choose an Arrangement");
        
            
            
            if (jTextField1.getText().toString().isEmpty())
                JOptionPane.showMessageDialog(mainPanel, "Please your name.");
            else
                name = jTextField1.getText().toString();
            if (jTextField2.getText().toString().isEmpty())
                JOptionPane.showMessageDialog(mainPanel, "Please your address.");
            else 
                address = jTextField2.getText().toString();
            if (jTextField3.getText().toString().isEmpty())
                JOptionPane.showMessageDialog(mainPanel, "Please your phone number.");
            else
                phoneNum = jTextField3.getText().toString();
            
            
            
            if (jCheckBox1.isSelected())
                gift = "True";
            else 
                gift = "False";
            
            
            
            if (!jTextField1.getText().toString().isEmpty() & 
                !jTextField2.getText().toString().isEmpty() &
                !jTextField3.getText().toString().isEmpty() &
                !jSpinner1.getModel().getValue().toString().equals("0")){
            Random r = new Random();
            orderNum = String.valueOf(r.nextInt(100000));
            
            JOptionPane.showMessageDialog(mainPanel, "Please write down this Order Number: " + orderNum + ".");
            
            try {
                    PrintWriter out = new PrintWriter("FlowerOrders.txt");
                    out.println(name);
                    out.println(address);
                    out.println(phoneNum);
                    out.println(orderNum);
                    out.println(flowerType);
                    out.println(flowerArrange);
                    out.println(quantity);
                    out.println(gift);
                    out.close();
                } catch (FileNotFoundException ex) {
                    JOptionPane.showMessageDialog(mainPanel, "File cannot be opened.");
                    Logger.getLogger(FlowersView.class.getName()).log(Level.SEVERE, null, ex);
                }
            
            }    
        }
        else
            JOptionPane.showMessageDialog(mainPanel, "Please Choose A Flower Type.");
        
        
    }

    @Action
    public void SubmitName() {
        
        FileReader fr;
        try {
            fr = new FileReader("FlowerOrders.txt");
        
        Scanner s = new Scanner(fr);
        String name = s.nextLine(),
               address = s.nextLine(),
               phoneNum = s.nextLine(),
               orderNum = s.nextLine(),
               flowerType = s.nextLine(),
               flowerArrange = s.nextLine(),
               quantity = s.nextLine(),
               gift = s.nextLine();
               
        if (jTextField4.getText().toString().equals(orderNum)){
          
            
            
            jTextArea1.append("Name: " + name + "\n" +
                              "Address: " + address + "\n" +
                              "Phone Number: " + phoneNum + "\n" +
                              "Order Number: " + orderNum + "\n" +
                              "Flower: " + quantity + " " + flowerArrange + " " +
                              flowerType + "\n" +
                              "Gift?: " + gift + "\n" + "\n");
        }
        else 
            JOptionPane.showMessageDialog(mainPanel, "Please enter correct Order Number.");
        } catch (FileNotFoundException ex) {
            Logger.getLogger(FlowersView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

Can't send the Arraylist information to be used in another method?

Why cant you pass the details in an ArrayList as a parameter to another method.

public void doSomething(ArrayList list){
//Get the arraylist  details and do the necessary task
}

Clearly state as to where the SubmitName() is called from?

Any way I can do this with an array

ArrayList is also sort of an extendable array. So if you are able to achieve by array, it should be possible to do the same by making use of arraylist also

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.