Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8459839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:26:22+00:00 2026-06-10T13:26:22+00:00

I know its easy but I am freaking doing it for about 2 hours

  • 0

I know its easy but I am freaking doing it for about 2 hours now and I can’t seems figure out why I can’t pass the JTextArea value from a variable to the other java files because I separated my ActionEvent code to another File from my Object (specifically the JTextArea), guys find out what went wrong on my code.

actionlistener code:

public class ButtonAction{
    public static class AddInv implements ActionListener{
    public void actionPerformed(ActionEvent e){
        AbstractButton inv = (AbstractButton)e.getSource();
        AddInventory addInv = new AddInventory();

        if(inv.getActionCommand().equals("SAVE")){
            invName = addInv.areaName.getText();                
            JOptionPane.showMessageDialog(null, invName);
        }   
    }
}
}

Here’s my Button and textarea object code from another java file, this is my class AddInventory:

ActionListener add = new ButtonAction.AddInv();
areaName = new JTextArea(2, 35);
//my TextArea
JButton buttonSave = new JButton("SAVE");
buttonSave.addActionListener(add);

Guys can you try this code and tell me if it is working in your computer guys.
because what I’m planning to do is save this text area value to my database.

I’m already connected the oracle database and I just need to insert some records.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:26:23+00:00Added an answer on June 10, 2026 at 1:26 pm

    I’d start by examining the purpose of

    addInv = new AddInventory();
    s1 = addInv.areaName.getText();
    

    To me, this says, create me a new AddInventory and give me the default value of it’s areaName text field…which is probably nothing…

    UPDATE

    Still the same problem…

    AddInventory addInv = new AddInventory();
    
    if(inv.getActionCommand().equals("SAVE")){
        invName = addInv.areaName.getText();                
        JOptionPane.showMessageDialog(null, invName);
    }   
    

    Some how, you either need to pass the reference to the text area to the action…

    UPDATE EXAMPLE

    Ideally you want some kind of controller/model to take care of this, but as an example…

    areaName = new JTextArea(2, 35);
    ActionListener add = new ButtonAction.AddInv(areaName);
    //my TextArea
    JButton buttonSave = new JButton("SAVE");
    buttonSave.addActionListener(add);
    

    And you action class…

    public class ButtonAction{
        public static class AddInv implements ActionListener{
            private JTextArea text;
            public AddInv(JTextArea text) {
                this.text = text;
            }
            public void actionPerformed(ActionEvent e){
                AbstractButton inv = (AbstractButton)e.getSource();
    
                if(inv.getActionCommand().equals("SAVE")){
                    invName = text.getText();                
                    JOptionPane.showMessageDialog(null, invName);
                }   
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know it's an easy way of doing it but i didn't find it
i know its already allot of info about that in internet, but i'm new
I know its easy to do this with Eclipse but i dont have that.
I know, that its easy to share my project with team in eclipse, but
I know its very easy to split data in strings, but still i want
I know its easy to stack images on top of one another but I
I know its quite easy topic, but I found the syntax provided on w3.com
I know there is one, but it's not easy to implement the way I
first of all i would like to say i know its probably an easy
I know its possible to create activities by doing something like the code bellow,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.