java - Evaluating jFileChooser options -


i'm working program opens jdialog jmenu, need evaluate option users choose (open, cancel or exit) in order proceed in different ways.

int result;//     result = jfilechooser1.showopendialog(this);      if (result == jfilechooser.approve_option) {         system.out.println(jfilechooser1.getselectedfile().getname());         system.out.println(jfilechooser1.getselectedfile().getabsolutepath());         ...         }      else if (result == jfilechooser.cancel_option) {         ...     } 

the problem everytime need evaluate result, showopendialog() opens again dialog.

there other way options without oppening dialog?

it seems mean have run code block again , again evaluating result choosed. if truth, , can't split showopendialog() thing if...else... thing, can define varible belong class, name can "ischoosed"(boolean), , doing this:

      if(ischoosed == false) {         result = jfilechooser1.showopendialog(this);         ischoosed = true;     }  

Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -