I want to add a image file selected from a directory (by clicking a button goes to the path). When I choose that jpg image it does not appears directly in the canvas where I want to put on it unless and until I minimize and maximize the application window. Below is the code I am using
//Button browse = new Button(shell, SWT.PUSH);
//Canvas dogPhoto = new Canvas(shell, SWT.BORDER);
// static Image dogImage;
browse.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
fileName = new FileDialog(shell).open();
System.out.println("fileNmae "+fileName);
if (fileName != null) {
dogImage = new Image(display, fileName);
dogPhoto.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent event) {
//if (dogImage != null)
System.out.println("hello in Paint2");
{
event.gc.drawImage(dogImage, 0, 0);
}
}
});
}
newText = newText + "File Selected - "+fileName;
textArea.setText(newText);
}
});