java - Displaying an image onto a JPanel? -


i have searched on google, looked @ documentation on oracle's webpage, read chapter graphics in java can't seem figure out please help! want button uploads image onto jlabel located in jpanel located in jframe. nothing more that! why isn't code working? happens when execute program absolutely nothing. nothing gets appended log , there aren't errors... nothing happens, i've been programming java quite time never worked graphics can't solve problem myself...

jlabel imagelabel = new jlabel(); private void uploadbuttonactionperformed(java.awt.event.actionevent evt) {                                                  jfilechooser filechooser = new jfilechooser();     filechooser.setcurrentdirectory(new java.io.file("c:\\"));     filechooser.setdialogtitle("choose file");     filechooser.setfileselectionmode(jfilechooser.files_only);      if (filechooser.showopendialog(this) == jfilechooser.approve_option) {         system.out.println("getcurrentdirectory(): "                 + filechooser.getcurrentdirectory());         system.out.println("getselectedfile() : "                 + filechooser.getselectedfile());         imagepath = filechooser.getselectedfile().tostring();         imageicon imageicon = new imageicon(imagepath);         imagelabel.seticon(imageicon);     }  } 


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

Bubble Sort Manually a Linked List in Java -

asp.net mvc - SSO between MVCForum and Umbraco7 -