Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JPanel Icon change issue...  RSS feed

 
tim charles
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The follow method is run when a button in my program is clicked. The first time it is run it changes the icons on some JLabels ok, but if I run it a second time it doesn't seem to change the icon. Everything else in the method is working correctly. I have highlighted the code not working in bold. Any ideas?

Cheers
Tim

private void jbConvertActionPerformed(java.awt.event.ActionEvent evt) {

///////////////////////////////////////LOCAL VARIABLES//////////////////////////////////////////

//JPEG output directory filename
String jpgURL = System.getProperty("user.dir") + "\\photoPopup\\images\\image.jpg";
//PPM output directory filename
String ppmURL = System.getProperty("user.dir") + "\\photoPopup\\images\\image.ppm";
//PNM (Superpixel) output directory filename
String superpixelURL = System.getProperty("user.dir") + "\\photoPopup\\images\\image.pnm";
//JPEG (Superpixel) output directory filename
String superjpgURL = System.getProperty("user.dir") + "\\photoPopup\\images\\super.jpg";
//Labeled image directory filename
String labeledImageURL = System.getProperty("user.dir") + "\\photoPopup\\results\\image.l.jpg";
//Segment Algorithm application directory
String segmentURL = System.getProperty("user.dir") + "\\segment";
//Automatic PhotoPopup application directory
String photoPopupURL = System.getProperty("user.dir") + "\\photoPopup\\src";

/////////////////////////////////////////////////////////////////////////////////////////////////

System.out.println("---IMAGE CONVERSION STARTED---");
jtaLog.append("\n---IMAGE CONVERSION STARTED---\n");

//Convert input image to JPEG format for photoPopup
convertImage("jpg", jpgURL, inputImage, "Input Image");

//Convert input image to ppm format for image segementation
convertImage("ppm", ppmURL, inputImage, "Input Image");

//Execute Segmentation Application
executeApp("cmd.exe /c cd " + segmentURL + " && segment.exe 0.8 100 100 ../photoPopup/images/image.ppm ../photoPopup/images/image.pnm", "Image Segmentation");

//Put superpixel image into BufferedImage
try{
superpixelImage = ImageIO.read( new File(superpixelURL));
System.out.println("Superpixel Image Successfully Loaded");
jtaLog.append("Superpixel Image Successfully Loaded\n");
}catch (IOException e) {
System.out.println("ERROR: Unable to Load Superpixel Image");
jtaLog.append("ERROR: Unable to Load Superpixel Image\n");
}//end catch

//Convert superpixel PNM image to JPEG, so it can be displayed in JLabel
convertImage("jpg", superjpgURL, superpixelImage, "Superpixel Image");

//Execute Automatic Photo Popup Application
executeApp("cmd.exe /c cd " + photoPopupURL + " && photoPopup.exe ./classifiers_08_22_2005 ../images/image.jpg pnm ../results", "3D VRML Model Construction");

//Put labeled image into BufferedImage
try {
labeledImage = ImageIO.read( new File(labeledImageURL));
System.out.println("Labeled Image Successfully Loaded");
jtaLog.append("Labeled Image Successfully Loaded\n");
} catch (IOException e) {
System.out.println("ERROR: Unable to Load Labeled Image");
jtaLog.append("ERROR: Unable to Load Labeled Image\n");
}

//Display VRML model in "3D Model" tab
createModelViewer();

//Enable Image/Model Viewer Tabs
jTabbedPane.setEnabled(true);
System.out.println("---IMAGE CONVERSION FINISHED---");
jtaLog.append("---IMAGE CONVERSION FINISHED---\n\n");

//Display labelled image in "Labelled Image" tab
jlLabeledImage.setIcon(new ImageIcon(labeledImageURL));
//Display superpixel image in "Superpixel Image" tab
jlSuperpixel.setIcon(new ImageIcon(superjpgURL));


//Enable Save Menu Items
jmiSaveSuperpixel.setEnabled(true);
jmiSaveLabeled.setEnabled(true);
jmiSaveModel.setEnabled(true);
//Disable Convert Button
jbConvert.setEnabled(false);
}
 
Rob Camick
Ranch Hand
Posts: 2752
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you need further help then you need to create a SSCCE (Short, Self Contained, Compilable and Executable, Example Program), that demonstrates the incorrect behaviour.

Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!