wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Alternative for getting textfile in my gui Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Alternative for getting textfile in my gui" Watch "Alternative for getting textfile in my gui" New topic
Author

Alternative for getting textfile in my gui

Stewart Etie
Greenhorn

Joined: Apr 28, 2013
Posts: 3

I've been trying get textfile in my GUI for a while and nothing is working out. I using JComboBox and recently found out that it wouldn't work that way... My textfile displays a movie,name,price,time and rating for about 4 titles. I can post the code if you want but its a bit messy.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

You might want to clean up the messiness, because that might be contributing to your confusion. So start with that.

And I have no idea what a JComboBox would have to do with displaying text, so I can't imagine why you're using that. But maybe you have a perfectly good reason for using it for some related purpose -- seeing the (cleaned up) code would help us to understand.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

And, welcome to the Ranch!
Stewart Etie
Greenhorn

Joined: Apr 28, 2013
Posts: 3

Paul Clapham wrote:And, welcome to the Ranch!


Thank you

Here is the code:

It has a error when initializing the combo box

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

You mean this JComboBox?



I don't think that can be the case because you don't ever do anything at all with that variable. But... you didn't say anything about what error you were getting, so it's a bit hard for us to debug that error. So could you read our FAQ entry TellTheDetails (<== click that link) and then tell us about the error?
Stewart Etie
Greenhorn

Joined: Apr 28, 2013
Posts: 3

Paul Clapham wrote:You mean this JComboBox?



I don't think that can be the case because you don't ever do anything at all with that variable. But... you didn't say anything about what error you were getting, so it's a bit hard for us to debug that error. So could you read our FAQ entry TellTheDetails (<== click that link) and then tell us about the error?


Ok thanks I can be clearer now. Eclipse tell me that the constructor JComboBox(ArrayList<String>) is undefined(I'm even adding item to it in line 54). I expect the code to display the movie names in the JComboBox and I believe that my code for opening up the file is correct. Strange thing is if i used initialized array it works fine.

edit: I forgot to replace movieBox name with movieLists
Ishan Pandya
Ranch Hand

Joined: Feb 06, 2012
Posts: 219

movieName is an ArrayList as you have defined.. and JComboBox does not have a constructor taking an ArrayList into it. Try Vector instead of it.

Hope it helps..

and try looking at docs.


OCPJP
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
That was a bad bit of design, using Vector as the parameter type rather than overloading it with List.
Ishan Pandya
Ranch Hand

Joined: Feb 06, 2012
Posts: 219

Campbell Ritchie wrote:That was a bad bit of design, using Vector as the parameter type rather than overloading it with List.


I didnt got you..can you please explain with example that how to overload with List?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
You can’t overload it; it is the designers of the combo box class who made the mistake.
You might be able to extend the class and add such a constructor, however.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Alternative for getting textfile in my gui
 
Similar Threads
Reading a textfile stored in an jar archiv
J# exe runs on my system but not on others
how to highlight impt date in JList..?
Servlet and I/O
gwt, textfile upload