home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-10-10 | 2.9 KB | 131 lines |
- import java.awt.*;
- import java.awt.peer.ComponentPeer;
- import java.applet.*;
- import com.ms.com.*;
- import com.ms.awt.*;
- import com.ms.awt.peer.*;
- import com.ms.directX.*;
- import java.net.URL;
- import java.net.MalformedURLException;
- import java.io.FilenameFilter;
- import java.io.File;
-
- public class TestGraph extends Applet
- {
- Stretch s;
- Button doIt;
- FlickStretch f = null;
- FlickViewer v = null;
-
- public String frameMenu[] = null;
-
- ////////////////////////////////////////////////////////////////////////////
-
- public static void main(String args[])
- {
- TestGraphFrame frame = new TestGraphFrame("DirectX sample");
-
- //----------------------------------------------------------------------
- // Must show Frame before we size it so insets() will return valid values
- frame.show();
- frame.hide();
- frame.resize(frame.insets().left + frame.insets().right + 128,
- frame.insets().top + frame.insets().bottom + 64);
-
- TestGraph applet = new TestGraph();
-
- frame.add("Center", applet);
- applet.init();
- applet.start();
- applet.frameMenu = frame.frameMenu;
- frame.show();
- }
-
- //////////////////////////////////////////////////////////////////////////
- //
- // init
- //
- public void init()
- {
- doIt = new Button("Start Viewer");
- s = new Stretch(this);
-
- setLayout(new GridLayout(1, 2, 0, 0));
- Panel pnButtons = new Panel();
- add(s);
- add(pnButtons);
- s.addNotify();
- s.resize(64,64);
- s.show();
-
- pnButtons.setLayout(new GridLayout(2, 1, 0, 0));
- pnButtons.add(doIt);
-
- f = s.doInit();
- if( f != null )
- f.start();
- }
-
- //////////////////////////////////////////////////////////////////////////
-
- public boolean action(Event e, Object arg)
- {
- Object target = e.target;
-
- if( target == doIt )
- {
- f.stop();
-
- ViewFrame vFrame;
-
- vFrame = new ViewFrame("Direct 3D in Java!", this);
-
- vFrame.resize(640, 480);
- vFrame.show();
- v = vFrame.startDirect(this, frameMenu);
- v.start();
- return true;
- }
-
- return false;
- }
-
- //////////////////////////////////////////////////////////////////////////
-
- public String getFileName(String rawFileName)
- {
- String file;
-
- try
- {
- URL url = new URL( getDocumentBase(), rawFileName);
- file = url.getFile();
- char c0 = file.charAt(0);
- char c1 = file.charAt(1);
- char c2 = file.charAt(2);
- if( ((c0 == '/') && (c2 == ':')) || ((c0 == '/') && (c1 == '\\') && (c2 == '\\')) )
- {
- char ch[] = new char[file.length()-1];
- file.getChars(1,file.length(),ch,0);
- for( int i=0; i<ch.length; i++)
- if( ch[i] == '/' )
- ch[i] = '\\';
-
- file = new String(ch);
- }
- }
- catch(MalformedURLException me)
- {
- file = new String(rawFileName);
- }
- catch(NullPointerException me)
- {
- file = new String(rawFileName);
- }
- return file;
- }
-
- //////////////////////////////////////////////////////////////////////////
-
- }
-