%
% chapter Demos: HPWindow.m
% 
% displays the text "Hello Psychophysicist (Normal Window)" and two images 
% in a normal window
%

import javax.swing.JFrame;
import psychWithJava.*;
import javax.imageio.ImageIO;
import java.io.File;
  
XO = 100;
YO = 100;
W = 612;
H = 612;
  
try
    nw = NormalWindow();
     
    %The only addition/change is here:
    mainFrame = JFrame();
    mainFrame.setBounds(XO,YO,W,H);
    mainFrame.add(nw);
    mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    % next two lines are optional
    mainFrame.setResizable(false);
    mainFrame.setTitle('Hello Psychophysicist');
    % you must set it visible
    mainFrame.setVisible(true);
    % up to here
    
    nw.displayText(...
        'Hello Psychophysicist (Normal Window)');
    nw.updateScreen();
    pause(2);
    
    nw.blankScreen();
    nw.hideCursor();
    
    bi1 = im2java2d(imread('psychophysik.png','PNG'));
    nw.displayImage(bi1);
    nw.updateScreen();
    pause(2);
    
    nw.blankScreen();
    
    bi2 = ImageIO.read(File('fechner.png'));
    nw.displayImage(0,0,bi2);
    nw.updateScreen();
    pause(2);
    
    % change this
    % fs.closeScreen();
    mainFrame.dispose();
catch
    % change also this
    % fs.closeScreen();
    mainFrame.dispose();
    rethrow(lasterror);
end