Window

Can someone tell me how can I show to the user,in a new window, the values of an array?
[94 byte] By [fde_cpua] at [2007-11-27 4:30:08]
# 1

> Can someone tell me how can I show to the user,in a

> new window, the values of an array?

I will not tell you exactly how but will give suggestions that can probably be of help. :)

Try researching on using TextAreas, Labels, other textual components.

Besides, the requirements you've posted is still quite vague.

lem@phila at 2007-7-12 9:39:20 > top of Java-index,Desktop,Core GUI APIs...
# 2

Create a JList with the elements of the array (or even better a Vector instead of array), then put it into a container such as JPanel or JScrollPane.

Something like this:

import java.awt.*;

import javax.swing.*;

//.... here goes your code...

Integer[] myArray = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 112}; // just for an example

JList myList = new JList(myArray); //myArray should contain Objects,

//if primitive type is required, they should be converted

// to their java.lang Object equivalent

JScrollPane jsp = new JScrollPane(myList);

// and here is a very dumb frame for it, you may have a better one:

JFrame jf = new JFrame("Results:");

jf.getContentPane().add(jsp);

jf.pack();

jf.setVisible(true);

sztyopeka at 2007-7-12 9:39:20 > top of Java-index,Desktop,Core GUI APIs...