Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Adding ScrollBar to JOptionPane.showConfirmDialog

Zulfi KhanNov 1 2015 — edited Nov 4 2015

Hi,

I am trying to display scrolling facility in JOptionPane. I have 20 JTextFields but i can see only 16 of them. I have written the following code:

Object[] message={

  "Input value 1:",field1,

  "Input value 2:",field2,

  "Input value 3:",field3,

  "Input value 4:",field4,

  "Input value 5:",field5,

  "Input value 6:",field6,

  "Input value 7:",field7,

  "Input value 8:",field8,

  "Input value 9:",field9,

  "Input value 10:",field10,

  "Input value 11:",field11,

  "Input value 12:",field12,

  "Input value 13:",field13,

  "Input value 14:",field14,

  "Input value 15:",field15,

  "Input value 16:",field16,

  "Input value 17:",field17,

  "Input value 18:",field18,

  "Input value 19:",field19,

  "Input value 20:",field20,

  };

JScrollPane pane = new JScrollPane(message);

int option=JOptionPane.showConfirmDialog(null,pane,"Enter all values", JOptionPane.OK_CANCEL_OPTION);

I am getting following error message:

>javac AssQ1_2.java

AssQ1_2.java:57: error: incompatible types: Object[] cannot be converted to Comp

onent

JScrollPane pane = new JScrollPane(message);

                                   ^

Note: Some messages have been simplified; recompile with -Xdiags:verbose to get

full output

1 error

>

Somebody please guide me.

Zulfi.

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 2 2015
Added on Nov 1 2015
4 comments
2,036 views