• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Alternative for getting textfile in my gui

 
Stewart Etie
Greenhorn
Posts: 3
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20725
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20725
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And, welcome to the Ranch!
 
Stewart Etie
Greenhorn
Posts: 3
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20725
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 226
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Sheriff
Posts: 48381
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That was a bad bit of design, using Vector as the parameter type rather than overloading it with List.
 
Ishan Pandya
Ranch Hand
Posts: 226
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48381
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic