background image Chris Johnson, Index
Containers










forward User Interface Design Using Java background image Chris Johnson, Index
Frames







forward User Interface Design Using Java background image Chris Johnson, Index
Dialogs







forward User Interface Design Using Java background image Chris Johnson, Index
Dialogs



forward User Interface Design Using Java background image Chris Johnson, Index
Dialogs


	dialog = new Dialog(myFrame, "SimpleDialog", true);
	/* true implies a modal dialog */



forward User Interface Design Using Java background image Chris Johnson, Index
FileDialog







forward User Interface Design Using Java background image Chris Johnson, Index
FileDialog










forward User Interface Design Using Java Chris Johnson, Index
FileDialog

/* 

        File:   FileDialog.java

        Author: Chris Johnson
                johnson@dcs.gla.ac.uk

        Modified: 21.10.98

        Description:
        Illustrates dialogs to load and save a file.

*/


import java.applet.Applet;
import java.awt.*;

public class FileDialogTest extends Applet{
        
        Button load = new Button("Load file...");
        Button save = new Button("Save file...");
        FileDialog dialog;
        String filename;
        
        public void init(){
                add(load);      /* set up buttons that users presses on */ 
                add(save);      /* initial screen to then call up either*/
        }                       /* the load or save dialogs as appropriate */
        
                
        
        public boolean action(Event event, Object what){
                        
                showStatus(null);
                        
                if (event.target == load){
                        Button button = load;
                        Frame myFrame = getFrame(button);
                        dialog = new FileDialog(myFrame, "Load A File");
                }
                else if (event.target == save){
                        Button button = save;
                        Frame myFrame = getFrame(button);
                        dialog = new FileDialog(myFrame, "Save A File", FileDialog.SAVE);
                }
                        
                dialog.show();
                        
                if((filename = dialog.getFile())!= null)
                        showStatus(filename);
                else
                        showStatus("FileDialog Cancelled");
                        
                return true;
        }

        static Frame getFrame (Component c) {

                Frame frame = null;

                while ((c= c.getParent())!= null){
                        if (c instanceof Frame)
                        frame = (Frame) c;
                }
                return frame;
        }
        
}



forward User Interface Design Using Java background image Chris Johnson, Index
Containers










forward User Interface Design Using Java background image Chris Johnson, Index
Containers


 				     Object
                                          |
                                    Component
                                          |
                             ------------
                       Container  
                          |
                   -----------  
                  Panel         Window 
                                          |
                            ----------
                        Dialog       Frame
                                           |
	                            FileDialog

forward User Interface Design Using Java background image Chris Johnson, Index
Containers
Hint: use your browser to open this image.







forward User Interface Design Using Java background image Chris Johnson, Index
Windows







forward User Interface Design Using Java background image Chris Johnson, Index
Windows






forward User Interface Design Using Java background image Chris Johnson, Index
Windows







forward User Interface Design Using Java background image Chris Johnson, Index
Frames



forward User Interface Design Using Java background image Chris Johnson, Index
Frames


/*
* A frame 
* Author: Chris Johnson (johnson@dcs.gla.ac.uk), revised 11/10/98
* Produces a warning window on the screen
* Beware - there is no way of closing the frame!
*/
 
import java.awt.*;
 
public class SimpleWarningFrame extends Frame {
 
	static private final int frame_height = 150;
	static private final int frame_width = 250;
 
	public SimpleWarningFrame () {
        	setBackground(Color.red);
        	setForeground(Color.black);
	}
 
   	public static void main (String[] args){
        	Frame f= new SimpleWarning();
        	f.setTitle("Warning");
        	f.resize(frame_width, frame_height);
        	f.show(true);
   	}
}







forward User Interface Design Using Java background image Chris Johnson, Index
Frames







forward User Interface Design Using Java background image Chris Johnson, Index
Frames







forward User Interface Design Using Java background image Chris Johnson, Index
Dialogs







forward User Interface Design Using Java background image Chris Johnson, Index
Dialogs



forward User Interface Design Using Java background image Chris Johnson, Index
Dialogs


	dialog = new Dialog(myFrame, "SimpleDialog", true);
	/* true implies a modal dialog */



forward User Interface Design Using Java background image Chris Johnson, Index
FileDialog







forward User Interface Design Using Java background image Chris Johnson, Index
FileDialog










forward User Interface Design Using Java Chris Johnson, Index
FileDialog

/* 

        File:   FileDialog.java

        Author: Chris Johnson
                johnson@dcs.gla.ac.uk

        Modified: 21.10.98

        Description:
        Illustrates dialogs to load and save a file.

*/


import java.applet.Applet;
import java.awt.*;

public class FileDialogTest extends Applet{
        
        Button load = new Button("Load file...");
        Button save = new Button("Save file...");
        FileDialog dialog;
        String filename;
        
        public void init(){
                add(load);      /* set up buttons that users presses on */ 
                add(save);      /* initial screen to then call up either*/
        }                       /* the load or save dialogs as appropriate */
        
                
        
        public boolean action(Event event, Object what){
                        
                showStatus(null);
                        
                if (event.target == load){
                        Button button = load;
                        Frame myFrame = getFrame(button);
                        dialog = new FileDialog(myFrame, "Load A File");
                }
                else if (event.target == save){
                        Button button = save;
                        Frame myFrame = getFrame(button);
                        dialog = new FileDialog(myFrame, "Save A File", FileDialog.SAVE);
                }
                        
                dialog.show();
                        
                if((filename = dialog.getFile())!= null)
                        showStatus(filename);
                else
                        showStatus("FileDialog Cancelled");
                        
                return true;
        }

        static Frame getFrame (Component c) {

                Frame frame = null;

                while ((c= c.getParent())!= null){
                        if (c instanceof Frame)
                        frame = (Frame) c;
                }
                return frame;
        }
        
}



forward User Interface Design Using Java background image Chris Johnson, Index
Containers










forward