JOptionDialog - add a text area

is there a way to add a disabled JTextArea to a JOptionDialog?
(I want to have a scrollable text area since I have a lot of text to show - and JDOptionDialog has it all in place already - an Icon, buttons and such...)
or is writing my own Dialog the only solution?

In the API documentation for JOptionPane.showxxxDialog, you'll see that one of the parameters you can use is "Object message" This Object can be something besides a String. For example, a panel with a label and a text area.          JTextArea ta = new JTextArea("Some text");
          JLabel label = new JLabel("some label");
          JPanel p = new JPanel();
          p.add(label);
          p.add(ta);
          String result = JOptionPane.showInputDialog(null,p);

Similar Messages

  • How to add a text area in a Content pane..?

    Hi,
    I created a content pane with 5 buttons. One of them is a quit button, and I was able to create an "system.exit(0)" event handling for him. My problem is.. I have 4 other buttons, and I want them to show some text when I click them. How do I add a text area bellow my content pane..?
    Copy/paste my code to see what im talking about :) :
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Interface extends JFrame {
    public Interface() {
    Container contentPane = getContentPane();
    contentPane.setLayout(new FlowLayout());
    JButton button1 = new JButton("Test1");
    JButton button2 = new JButton("Test2");
    JButton button3 = new JButton("Test3");
    JButton button4 = new JButton("Test4");
    JButton button5 = new JButton("Quit");
    ButtonHandler handler = new ButtonHandler();
    button5.addActionListener( handler );
    contentPane.add(button1);
    contentPane.add(button2);
    contentPane.add(button3);
    contentPane.add(button4);
    contentPane.add(button5);
    contentPane.setBackground(Color.orange);
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    public static void main(String args[]) {
    Interface window = new Interface();
    window.setLocation(250,350);
    window.setTitle("FlowLayout");
    window.pack();
    window.setTitle("Test");
    window.setVisible(true);
    public class ButtonHandler implements ActionListener {
    public void actionPerformed( ActionEvent e )
    System.exit(0);
    Thanks alot! :)

    By default the content pane of the JFrame uses a Border Layout. So you should:
    1) Create a JPanel
    2) Set the layout of the JPanel to FlowLayout
    3) add the buttons to the panel
    4) add the panel to the content pane
    5) add your text area to the content pane
    Read this section from the Swing tutorial on "Using Layout Managers":
    http://java.sun.com/docs/books/tutorial/uiswing/layout/using.html

  • To load text area by clicking on a button

    Hello Experts,
    In my application, i want to add a text area to add comment.
    I will provide one button to add comment. When I click on it, it should load a text area with submit button.
    After typing some text in text area and click submit, it needs to insert into the database.
    How to do it. Please help me.

    Hi,
    just add a hidden variable called P1_SHOW_COMMENT and create for your submit button and your text area a condition which checks if variable is set to "yes".
    Default value is "no" or empty. On button click set item P1_SHOW_COMMENT by pl/sql process to "yes".
    Best regards,
    Tobias
    http://apex-at-work.blogspot.com

  • How do you add an image in the text area of a page/section?

    This has been driving me nuts!
    When I try to add an image to a page, it will ONLY go into the header.  If I try to drag the image onto the page where the text is, it gets hidden behind a layer.
    I've looked at the menu choices and I don't seem to be allowed to bring the image to the front.  Nor does clicking in the text area and then trying to paste or insert the image - it still goes up in the header.
    What is the secret to placing images along with your text on a page in the iBooks Author program?
    Thanks!

    Wow, Apple has really constrained the "box" that we have to fit our books into!
    I was hoping to take some iPad screenshots and put them inline with the text.  Since they are portrait iPad screenshots, the book that I'd like to create looks much better (and makes more sense) in portrait mode.
    Apple has released this awesome tool, yet they seem to have restricted the author from using any creativity at all.

  • How do i add a an editable text area along with a basic shape?

    hiee
    Thank u guys for replying to my previous query.I got the solution.
    Now ,my problem is, whenever i am drawing a new shape on the panel i want to add an editable text area along with the shape so that the shape can be given a userdefined name(something like Rational Ross).
    I am using g.drawString() but with that i can only add a static string.
    How can i add a JTextField or JTextArea along with the shape??
    Thanking u guys in advance.
    anvesha.

    It is considered standard procedure to acknowledge people's replies in the corresponding thread.
    As for your current problem, you'll have to make sure that the component you're subclassing is at least a Container. A JPanel could be a good pick. Set the layoutManager to null. Add your JTextField to your JPanel and use myTextField.setBounds(x, y, width, height) to place it whereever you want.

  • How to add document header text area on fb03's selection screen

    hi,
    i want to add an additional area on fb03's selection screen. i need document header text area for my document searchs. is it possible?

    Refer to this thread
    How to Add field to Selection screen of Tx. FBL5N

  • When I type I cannot add text when I select the text area and double click. Why?

    When I type I cannot add text when I select the text area and double click. Why?

    Premiere Elements 11  trial version for macMac computer photos uploaded to the timeline just finetrying to make a new title, streaming or in a framedouble clicked on the text in the box and nothing shows up when I type on my keyboard. I can delete the words that are there but not type in new ones. I selected the type and size, etc.
    Thanks if you can figure it out. I gave up!
    I may just un-install it all together if I can't get to work.Joanne
    Date: Thu, 9 May 2013 17:59:08 -0700
    From: [email protected]
    To: [email protected]
    Subject: When I type I cannot add text when I select the text area and double click. Why?
        Re: When I type I cannot add text when I select the text area and double click. Why?
        created by A.T. Romano in Premiere Elements - View the full discussion
    Joanne Murray J2 What version of Premiere Elements are you using and on what operating system (including 32 or 64 bit) is your Premiere Elements installed? Forgive the questions if you have been there and done that, but I do not want to take anything for granted that might hinder a speedy resolution to your issue. Are you opening an already created title that is sitting on the Timeline in order to edit it in the Titler or are you trying to create a new Title (Default Text or other)? Do you know how to work with the Selection Tool and Type Tool in the Titler? Once I know what version of Premiere Elements that you are using, I will give you specific how to details. Thanks. ATR
         Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5307494#5307494
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5307494#5307494
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5307494#5307494. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Premiere Elements by email or at Adobe Community
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Simple Right-click menu in Text Area

    How can I simply implement a right-click menu with
    the options copy-paste on a text area or editor pane?
    I believe there must be ready code for sth like that.

        protected void createPopupMenu ()
            mMenu = new JPopupMenu ();
            cutOption = mMenu.add(new JMenuItem("Cut"));
            cutOption .addActionListener ( new ActionListener ()
                public void actionPerformed ( ActionEvent e )
                   //do cut here
            copyOption = mMenu.add(new JMenuItem("Copy"));
            copyOption .addActionListener ( new ActionListener ()
                public void actionPerformed ( ActionEvent e )
                   //do copy here
            pasteOption = mMenu.add(new JMenuItem("Paste"));
            pasteOption .addActionListener ( new ActionListener ()
                public void actionPerformed ( ActionEvent e )
                   //do paste here
            });when you instantiate your textarea or editpane add this line:
            createPopupMenu (); //popup menu for right clickshould work perfectly

  • How Can I add/change text/description in accounting view of Vendor master ?

    /nxk02 --> (give vendor, company code ) 
    then check the check box of 'Accounting info' under Company code data block -->  then hit 'Enter'
    --> it goes to next screen.  Then in this screen, click menu 'Extras' --> then press "Texts" under that menu. 
    So that popup screen appears with the Description.
    I need to know from where these descriptions are coming or where these descption  can be maintained ? Because I need to add/change these  descriptions to my vendors
    YOUR HELP IS HIGHLTY APPRECIATED.  Please help....
    THANKS IN ADVANCE.

    Hi Aman,
    Because these texts are maintained at Company Code level for the Vendor, they are part of the Accounts Payable configuration in the SAP IMG. 
    SPRO > Financial Accounting > Accounts Receivable and Accounts Payable > Vendor Accounts > Master Data > Preparations for Creating Vendor Master Data > Define Text IDs for Accounting Texts (Vendors)
    Transaction OBT5
    Regards, 
    Monika

  • Line numbers in text area

    im using the class JTextArea of the swing class to view some text documents.
    How i can vies the number of lines of each document:
    i want the line numbers not in the document but as a part of the text area. for example:
    1:line 1
    2:something
    3:something
    4:sjdhfskjhsl
    Please help.Thanx

    You can do it in two ways.
    Place a JLabel on left of your Text Area, Add a KeyListener to the text area. On each ENTER key press count lines of JTextArea.getLineCount(). and paint your JLabel as well. Secondly you will need to move the JLabel as soon as the ScrollBar of JScrollPane will move.
    Second way is like:
    <code>
    import java.awt.Toolkit;
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.text.BadLocationException;
    public class MyTextArea extends JTextArea{
    public MyTextArea(){
    super("1: ");
    setCaretPosition(3);
    addKeyListener(new MyKeyListener());
    class MyKeyListener extends KeyAdapter{
    public void keyReleased(KeyEvent e){
    try{
    switch(e.getKeyCode()){
    case KeyEvent.VK_ENTER:
    int position=getCaretPosition();
    int line=getLineOfOffset(position);
    insert((line + 1) + ": ", position);
    changeLineNos(line);
    break;
    case KeyEvent.VK_BACK_SPACE:
    position=getCaretPosition();
    line=getLineOfOffset(position);
    if(line > 0){
    int cLoc=getCollonLocation(position);
    int diff=position - cLoc;
    if(diff <= 2){
    replaceRange("", getLineEndOffset(line - 1) - 1, cLoc + diff);
    changeLineNos(line);
    } else{
    int cLoc=getCollonLocation(position);
    int diff=position - cLoc;
    if(diff <= 2){
    if(getLineCount() > 1){
    replaceRange("", 0, getLineEndOffset(0));
    changeLineNos(0);
    } else{
    setText("1: ");
    Toolkit.getDefaultToolkit().beep();
    break;
    } catch(BadLocationException ex){
    ex.printStackTrace();
    private void changeLineNos(int lineNo) throws BadLocationException{
    int total=getLineCount();
    if(total > lineNo){
    while(lineNo < total){
    int offset=getLineStartOffset(lineNo);
    int collonLocation=getCollonLocation(offset, lineNo);
    replaceRange("" + ++lineNo, offset, collonLocation);
    private int getCollonLocation(int offset, int lineNo) throws BadLocationException{
    return getText(offset, getLineEndOffset(lineNo) - offset).indexOf(':') + offset;
    private int getCollonLocation(int caretPosition) throws BadLocationException{
    int lineNo=getLineOfOffset(caretPosition);
    int offset=getLineStartOffset(lineNo);
    return getText(offset, getLineEndOffset(lineNo) - offset).indexOf(':') + offset;
    public static void main(String argv[]){
    JFrame frame=new JFrame();
    MyTextArea area=new MyTextArea();
    frame.getContentPane().add(new JScrollPane(area));
    frame.setSize(300, 200);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    </code>
    Regards,

  • I just bought a second iPhone for my business... I used my existing apple account and now all my texts are coming to both phones.. How do I get a secondary apple ID and change it on my business phone?

    I used my existing apple ID when I purchased a second iPhone for my business.. Now all my texts are coming to both phones.. Is there a way to create a new apple account for my business phone and if so.. How do I delete one and add another?

    Yes, you can have two separate Apple IDs, and it's pretty easy to set this up. Go into Settings > iTunes & App Store on your business phone. You should see your current Apple ID. Tap on it, then tap on sign out. You can then create a new Apple ID, using a different email address and password than those associated with the Apple ID on your other phone. Log back in using this new information, and you shouldn't get the texts that come to your other phone.
    Hope this helped!

  • Everytime i try to add a text box the program crashes.  Why and how do I fix it?

    Since I purchased and installed Adobe Photoshop Elements every time I try to add a text box the program crashes.  Why and how do I fix it?

    TeeKnows wrote:
    Debit cards are accepted in the iTunes store.
    No longer accepted for NEW accounts, however if a debit card were associated with the account BEFORE this change, they can still be used.

  • How to add new text and an empty space before a file name with Automator

    I can create a new service to add to multiple files some text before the file name but I need to add even an empty space; e.g. file name original  becomes: new text(space)file name original. The aim is to add this text and space to multiple files.
    I hope to be understood. Please can somebody help me?
    Thanks

    This is an old Apple-supplied AppleScript that will do the job.
    IMPORTANT: note the conditions of use: it will choose the frontmost Finder window to operate on. Therefore, open the folder you want to change the names of and make it the front finder window BEFORE running the script.
    Add to File Names
    This script is designed to add a prefix or suffix to files in the front window of the desktop.
    If no folder windows are open, the script will affect items on the desktop.
    Copyright © 2001–2007 Apple Inc.
    You may incorporate this Apple sample code into your program(s) without
    restriction.  This Apple sample code has been provided "AS IS" and the
    responsibility for its operation is yours.  You are not permitted to
    redistribute this Apple sample code as "Apple sample code" after having
    made changes.  If you're going to redistribute the code, we require
    that you make it clear that the code was descended from Apple sample
    code, but that you've made changes.
    --March 2014: Changes by Phil Stokes to make the script work on 10.9
    --these changes are simply reversing the order of parameters in the lines that have "copy" in them
    -- The following line is disabled due to a Menu Manager bug
    --set the source_folder to (choose folder with prompt "Pick the folder containing the files to rename:")
    try
              tell application "Finder" to set the source_folder to (folder of the front window) as alias
    on error -- no open folder windows
              set the source_folder to path to desktop folder as alias
    end try
    set the prefix_or_suffix to ""
    repeat
              display dialog "Enter the prefix or suffix to use:" default answer the prefix_or_suffix buttons {"Cancel", "Prefix", "Suffix"}
              copy the result as list to {button_pressed, prefix_or_suffix}
              if the prefix_or_suffix is not "" then exit repeat
    end repeat
    set the item_list to list folder source_folder without invisibles
    set source_folder to source_folder as string
    repeat with i from 1 to number of items in the item_list
              set this_item to item i of the item_list
              set this_item to (source_folder & this_item) as alias
              set this_info to info for this_item
              set the current_name to the name of this_info
              if folder of this_info is false and ¬
                        alias of this_info is false then
                        if the button_pressed is "Prefix" then
                                  set the new_file_name to the (the prefix_or_suffix & the current_name) as string
                        else
                                  set the new_file_name to the (the current_name & the prefix_or_suffix) as string
                        end if
                        my set_item_name(this_item, the new_file_name)
              end if
    end repeat
    beep 2
    on set_item_name(this_item, new_item_name)
              tell application "Finder"
      --activate
                        set the parent_container_path to (the container of this_item) as text
                        if not (exists item (the parent_container_path & new_item_name)) then
                                  try
                                            set the name of this_item to new_item_name
                                  on error the error_message number the error_number
                                            if the error_number is -59 then
                                                      set the error_message to "This name contains improper characters, such as a colon (:)."
                                            else --the suggested name is too long
                                                      set the error_message to error_message -- "The name is more than 31 characters long."
                                            end if
      --beep
                                            tell me to display dialog the error_message default answer new_item_name buttons {"Cancel", "Skip", "OK"} default button 3
                                            copy the result as list to {button_pressed, new_item_name}
                                            if the button_pressed is "Skip" then return 0
                                            my set_item_name(this_item, new_item_name)
                                  end try
                        else --the name already exists
      --beep
                                  tell me to display dialog "This name is already taken, please rename." default answer new_item_name buttons {"Cancel", "Skip", "OK"} default button 3
                                  copy the result as list to {button_pressed, new_item_name}
                                  if the button_pressed is "Skip" then return 0
                                  my set_item_name(this_item, new_item_name)
                        end if
              end tell
    end set_item_name

  • How to add new text field in standard report

    how to add new text field in standard report?

    Hi,
    I presume you are talking about a report display in ALV and u wish to add a column to it .
    If it is a global requirement ,as in table being used there in ALV can be modified, then you can append the table and the system should pick up the same automatically from there.
    Otherwise , you can make a Z program . Modify the catalog being used in ALV.
    Regards,
    Shweta

  • How do I retrieve all data from a table and display it on a text area?

    I want to retrieve all the data from one of my MS Access data table and display them all in a text area. how do i go among doing this?
    In my car table i have the fields lined up like this..
    license,color,doors and year_made
    I have an Object class called CAR that will contain methods to set the data from these fields when it gets retrieved.
    here's what i go so far.....
    statement = getDBConnection().createStatement();
         rs = statement.executeQuery("select * from car");
         boolean moreRS = rs.next();
    if(moreRS)
    car.setLicense(rs.getLong(1));
         car.setColor(rs.getString(2));
         car.setDoors(rs.getString(3));
    car.setYearMade(rs.getString(4));
    //but this will only get me one car. How do I get more car data?
    HELP!!

    Vector cars = new Vector();
    while (rs.next()) {
      String license = rs.getLong(1);
      String color = rs.getLong(2);
      String doors = rs.getLong(3);
      String year = rs.getLong(4);
      myTextArea.append(license+"\t"+color+"\t"+doors+"\t"+year+"\n");
      Car car = new Car();
      car.setLicense(license);
      car.setColor(color);
      car.setDoors(doors);
      car.setYearMade(year);
      cars.add(car);
    }t=tab
    n=newline
    Vector: http://java.sun.com/j2se/1.4.1/docs/api/java/util/Vector.html

Maybe you are looking for