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 6868139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:23:50+00:00 2026-05-27T03:23:50+00:00

How do you make a JTextArea in the JFrame that accepts multiple input from

  • 0

How do you make a JTextArea in the JFrame that accepts multiple input from JOptionPane? Is that even possible? Thanks to whoever helps!

  • 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-05-27T03:23:50+00:00Added an answer on May 27, 2026 at 3:23 am
    1. Create a new class and extend JFrame
    2. add a JTextArea to it. Make it a member variable
    3. add a button to the frame. In the action method call open the input dialog
    4. when the dialog returns, append the text to the JTextArea using its append method (don’t forget to check for empty/null string)

    Here is a sample program:

    import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JTextArea;
    
    public class InputTest extends JFrame {
    
        private final JTextArea textarea;
        private final JButton button;
    
        public InputTest(String title) {
            super(title);
    
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
            textarea = new JTextArea(5,30);
    
            button = new JButton("new input");
            button.addActionListener(new ActionListener() {
    
                @Override
                public void actionPerformed(ActionEvent e) {
                    String input = JOptionPane.showInputDialog(InputTest.this, "Please enter some text");
    
                    if((input != null) && !input.isEmpty()) {
                        textarea.append(input);
                        textarea.append(System.getProperty("line.separator"));
                    }                
                }
            });
    
            JPanel p = new JPanel(new BorderLayout());
            p.add(textarea, BorderLayout.NORTH);
            p.add(button, BorderLayout.SOUTH);
    
    
            this.getContentPane().add(p);
    
        }
    
        public static void main(String[] args) {
            InputTest it = new InputTest("Input Test");
            it.setSize(200, 200);
            it.setVisible(true);
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a seperate JFrame where there is a text box (jTextArea) that takes
I am trying to make a textarea that only will type in caps, even
I'm using java, and I'm trying to make a JTextArea that is non-editable but
I’m editing a <textarea> with JavaScript. The problem is that when I make line
I've managed to make a typewriter class that does what I want it to
I am trying to make a Text Editor using Java Swing. In that I
So I'm working on making a class that will type letters into a JTextArea,
I'm trying to make a textarea input field which automatically replaces specific characters to
I need to execute/display a series of events from a Arraylist to a JTextArea,
I have a form that has a textarea in it. How would I make

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.