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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:44:09+00:00 2026-05-13T11:44:09+00:00

All I want to do is have a JOptionPane inputDialog with a JTextArea instead

  • 0

All I want to do is have a JOptionPane inputDialog with a JTextArea instead of a JTextField.
I tried putting the JTextArea inside of the Message parameter like so

Object[] inputText = new Object[]{new JLabel("Enter Graph Information"),
                                  newJTextArea("",20,10)};
graphInfo=(String)JOptionPane.showInputDialog(null,
                                              inputText,
                                              "Create Graph",
                                              JOptionPane.PLAIN_MESSAGE,
                                              null,
                                              null,
                                              "");

But it still has the text field at the bottom and I cannot get the text from the JTextArea.
Is there any way to either remove the original text field and get the text from the jtextarea or replace the text field with the text area completely? I’m trying to avoid having to make a custom dialog if possible and this “seems” like something that should be easy to do?

  • 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-13T11:44:09+00:00Added an answer on May 13, 2026 at 11:44 am

    You’re on the right lines; you just need to use showConfirmDialog instead of showMessageDialog, which allows you to pass any Component as your “message” and have it displayed within the JDialog. You can then capture the contents of the JTextArea if the user clicks OK; e.g.

    int okCxl = JOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(this),
                                        textArea,
                                        "Enter Data",
                                        JOptionPane.OK_CANCEL_OPTION)
    
    if (okCxl == JOptionPane.OK_OPTION) {
      String text = textArea.getText();
      // Process text.
    }
    

    If you want to show a JLabel in conjunction with your JTextArea you can create and pass in a JPanel containing both Components; e.g.

    JTextArea textArea = ...
    JPanel pnl = new JPanel(new BorderLayout());
    
    pnl.add(new JLabel("Please enter some data:"), BorderLayout.NORTH);
    pnl.add(textArea, BorderLayout.CENTER);
    
    JOptionPane.show...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an object, and I want to list all the selectors to which
Say I have an interface IFoo and I want all subclasses of IFoo to
Is this possible? I want to have the To:, Body, and an Attachment all
We have several common libs. Ideally we want them all to use the latest
We have multiple vb projects.We want to put error handlers in all functions, and
I have information spread out across a few databases and want to put all
I have the following markup, and I want to make the All radio button
I have several std::vector , all of the same length. I want to sort
I have problem with return statment >.< I want to store all magazine names
I want to have all the efficiencies of EnumSet and pass it around without

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.