• Post Reply Bookmark Topic Watch Topic
  • New Topic

Button has stopped working  RSS feed

 
Ranch Hand
Posts: 217
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My button no longer works how I want it to but I'm pretty sure it should of worked but I don't know what to do because there is that many lines of code! I've fixed everything else just making my button import the file left

Basically I had an if statement that says if the mode is export then carry out the code to do the export from the main file to another. then I have another if statement that says if the mode is equal to import then copy the data from one file into the main file. However my code for the import doesn't do anything when I press my button. I've tried to cut down what I have so it can be viewed on here - if it's still to much i'll cut it down a bit more I'm just wondering if I've missed something out. (I already have the file through using a filechooser and getting the entire filepath and putting it into a text field.I just need it to import whats in the chosen file into the main file when the save button is clicked)

 
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hint. Try the equals() method instead.
 
Alice Hampton
Ranch Hand
Posts: 217
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the reply Maneesh and I have changed it to that - the code is still not executed when I try and press the button unfortunately and does nothing. :/
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In that case please post your SSCCE so we can download and run it on our machines
 
Alice Hampton
Ranch Hand
Posts: 217
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two classes - one as the main (opens up the app window) and then my other which is the import/export window (opens up from main app window) I'm not sure I can cut anything out of it as its mainly to do with the swing components being used - any advice you can give on cutting something down like that?

 
Sheriff
Posts: 4289
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Writing an SSCCE can sometimes solve your problem, so it's a good thing to do even if you don't post to a forum.

If you have a complex or long program my advice is to take a deep breath and start over. Make a very simple GUI with just your button and then copy and paste chunks of the original program into the new one, testing each time until the error reappears. Try to paste in only chunks of code to understand completely. When pasting (or writing) a chunk of code causes the error, you know where to look. If the problem still alludes you, post the code here.
 
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, you're jumping through a lot of unnecessary hoops to verify the file extension. All you need to test is fileName.toLowerCase().endsWith(".xml")
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!