home *** CD-ROM | disk | FTP | other *** search
/ Late Night VRML 2.0 with Java CD-ROM / code.zip / Ch12 / ui / dialogs / ShapeDialog.java < prev    next >
Text File  |  1997-01-02  |  1KB  |  58 lines

  1. // VRML Generator
  2. // (c) Justin Couch
  3. //
  4. // From Chapter 13: Late Night VRML 2.0 and Java
  5. //
  6. // The container dialog for editing the properties of each node
  7. // This should be subclassed to produce the desired dialog
  8.  
  9. package ui.dialogs;
  10.  
  11. import java.awt.*;
  12. import ui.dialogs.VrmlBaseDialog;
  13. import geometry.Shape;
  14. import ui.VrmlTree;
  15. import VrmlScene;
  16. import VrmlTypes;
  17. import exceptions.NoSelectedNodeException;
  18.  
  19. public class ShapeDialog extends VrmlBaseDialog
  20. {
  21.  
  22.     public ShapeDialog(Frame parent, VrmlTree tree, VrmlScene data)
  23.     {
  24.         super(parent, "Edit Shape Node");
  25.  
  26.         vrml_data = data;
  27.         screen_data = tree;
  28.         
  29.         pack();
  30.     }
  31.  
  32.     // this class needs to be implemented by the derived class.
  33.     public boolean applyInformation()
  34.     {
  35.         String str;
  36.         
  37.         Shape shape = new Shape(browser);
  38.  
  39.         str = name.getText();
  40.  
  41.         if(str.equals(""))
  42.             shape.name = null;
  43.         else
  44.             shape.name = new String(str);
  45.  
  46.         try
  47.         {
  48.             vrml_data.addNode(VrmlTypes.Shape, shape);
  49.         }
  50.         catch (NoSelectedNodeException e)
  51.         {
  52.             // should do something like barf with a dialog box here.
  53.         }
  54.         return false;
  55.     }
  56.  
  57. }
  58.