aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Display an array in a swing type box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Display an array in a swing type box" Watch "Display an array in a swing type box" New topic
Author

Display an array in a swing type box

Scotty Steven
Ranch Hand

Joined: Jan 27, 2012
Posts: 80
Hi

I am very new to Java. I am trying to create a swing display of a java keyword array that I have entered, but I'm not sure how to do so. The code so far is as follows:



} // end class

What I would like to do is under the switch case 2, have a list of all the array elemets (except 0) display on either a table type format (5 columns, 10 rows), or just some neat list format inside a swing dialog box. Any help would be appreciated.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

The obvious way to display a "list" in a Swing GUI is via a... JList. Have a look through the Swing tutorial -- that should give you a better start than what you have so far.
Scotty Steven
Ranch Hand

Joined: Jan 27, 2012
Posts: 80
This code looks a little more involved then what I was hoping to achieve. I do not want to select anything from the list. I just want it to display the list on the screen. I am a beginner, and that code is too advanced for me.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> This code looks a little more involved then what I was hoping to achieve.

doesn't get much easier than one line of code

"f.getContentPane().add(new JScrollPane(new JList(javaKeyword)));"

Scotty Steven
Ranch Hand

Joined: Jan 27, 2012
Posts: 80
@Michael Dunn

Thanks. This gives me something to study and learn from. You rock!
 
Consider Paul's rocket mass heater.
 
subject: Display an array in a swing type box