FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Topics & Contributions
   Tools
(Moderator: REAS)
   P5 Application Demo
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: P5 Application Demo  (Read 2579 times)
Martin

122417302122417302martingomez_listsmg1ph WWW Email
P5 Application Demo
« on: Nov 9th, 2002, 4:46pm »

Download, source, instructions, information, et al...
 
www.instituteofmedia.com/martin/mediadesign/P5AppDemo/
 
Feedback, updates, modifications, hacks, comments, rants and raves would be highly appreciated.
 
Obsessive-Compulsive Note: Unless hacked by user, 1024x768 screen resolution *required*. Built for Windows (I don't have a Mac... one day... ).
 
fry

WWW
Re: P5 Application Demo
« Reply #1 on: Nov 9th, 2002, 7:36pm »

cool idea, nice to have several running at once.
 
one undocumented feature of BApplet is that it can run as a standalone app, but it needs you to tell it the name of your applet in order to run. so, using your example, if you're inside the directory and type:  
javaw BApplet helloworld
will run the applet in its own frame, as a regular java app. this is roughly how the export to application thing will work once that's implemented (actually, there will be an option to make it full screen, as you've done in your example).  
 
regarding the screen size, if you aren't aware, it's possible to get the screen size from java.awt.Toolkit, so something like:
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
will give you the sizing of the beast.  
 
for the curious, here's the main() from BApplet:
 
Code:

  static public void main(String args[]) {
    if (args.length != 1) {
      System.err.println("error: BApplet <appletname>");
      System.exit(1);
    }
 
    try {
      Frame frame = new Frame();
      Class c = Class.forName(args[0]);
      BApplet applet = (BApplet) c.newInstance();
      applet.init();
      applet.start();
 
      Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
 
      frame.setLayout(new BorderLayout());
      frame.add(applet, BorderLayout.CENTER);
      frame.pack();
 
      frame.setLocation((screen.width - applet.g.width) / 2,
                  (screen.height - applet.g.height) / 2);
 
      frame.show();
      applet.requestFocus(); // get keydowns right away
 
      frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
          System.exit(0);
        }
      });
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(1);
    }
  }
« Last Edit: Nov 10th, 2002, 5:46am by fry »  
fry

WWW
Re: P5 Application Demo
« Reply #2 on: Nov 9th, 2002, 7:38pm »

hrm, i need to figure out how to post fixed-width code segments on this bboard
 
also forgot to mention, the requestFocus() call tends to be very important.
 
Martin

122417302122417302martingomez_listsmg1ph WWW Email
Re: P5 Application Demo
« Reply #3 on: Nov 10th, 2002, 3:38am »

didn't know that there was a main() inside BApplet. it's a real neat function -- being able to run your program as an application. this would enable me to set the screen res and the color depth (since they are only available to pure application) using swing hehe.
 
i was wondering about one thing though. originally, i used BorderLayout too in the hope of achieving a center effect if you maximized the frame window. however, the sketch still aligns to the top left portion of the window when maximized. i guess i should just panel here and panel there. gonna try it out later when i get home.
 
Code:
static public void main(String args[]) {  
  if (args.length != 1) {  
    System.err.println("error: BApplet <appletname>");  
    System.exit(1);  
  }  
 
  try {  
    Frame frame = new Frame();  
    Class c = Class.forName(args[0]);  
    BApplet applet = (BApplet) c.newInstance();  
    applet.init();  
    applet.start();  
        
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();  
        
    frame.setLayout(new BorderLayout());  
    frame.add(applet, BorderLayout.CENTER);
    // martin: perhaps nested panels outside?
    frame.pack();  
        
    frame.setLocation((screen.width - applet.g.width) / 2,  
      (screen.height - applet.g.height) / 2);  
        
    frame.show();  
    applet.requestFocus(); // get keydowns right away  
                           // martin: if i'm not mistaken, this sets the
                           // focus to the applet within the frame?
 
    frame.addWindowListener(new WindowAdapter() {  
      public void windowClosing(WindowEvent e) {  
        System.exit(0);  
      }  
    });  
  } catch (Exception e) {  
      e.printStackTrace();  
      System.exit(1);  
    }  
}

 
one way to post fixed-width code segments on this bboard is to use {code}codehere{/code} (change {} to [])...
« Last Edit: Nov 10th, 2002, 3:54am by Martin »  
pollux

WWW Email
Re: P5 Application Demo
« Reply #4 on: Apr 25th, 2003, 1:27pm »

two thingies:
 
one, is that i remember to have downloaded the app, and it working... but now it tells me that it cannot find the main class. any thoughts?
 
two, is on help as to implement the main() stuff on an applet. sorry, but things like "if you're inside the directory and type..." are way beyond my grasp.
 
can somebody kind enough explain how to do it?
 
thanks,
 

pollux | www.frwrd.net
benelek

35160983516098 WWW Email
Re: P5 Application Demo
« Reply #5 on: Apr 28th, 2003, 4:29am »

on Apr 25th, 2003, 1:27pm, pollux wrote:
sorry, but things like "if you're inside the directory and type..." are way beyond my grasp.

 
I believe the Windows command line interface was being referred to (start->run->"cmd"). it's similar to the old DOS way of life. use "cd <directoryName>" to move to the exported applet's folder, and "java -cp <appName>.jar <appName> <appName>" to run the applet as application. Note that it's case sensitive.
 
anyway, in my experience running exported applets from cmd as applications is very slow (not to mention the fact that you have to know how to use cmd in order to run it). let me know if i need to go into more detail!
 
-jacob
 
_martin
Guest
Email
Re: P5 Application Demo
« Reply #6 on: Apr 28th, 2003, 7:17am »

on Apr 25th, 2003, 1:27pm, pollux wrote:

one, is that i remember to have downloaded the app, and it working... but now it tells me that it cannot find the main class. any thoughts

 
your classpath env/system variable might have been set. type 'set CLASSPATH=' to unset it.
 
Quote:

two, is on help as to implement the main() stuff on an applet. sorry, but things like "if you're inside the directory and type..." are way beyond my grasp.

 
applet running as an app with main() inside applet code --> http://proce55ing.net/discourse/yabb/board_Tools_action_display__num_1046005023_start_2.html
 
pollux

WWW Email
Re: P5 Application Demo
« Reply #7 on: May 3rd, 2003, 1:05am »

ok, my intellimouse erased all my wonderful post!
 
niente, thanks for all, guys. i'll try with main(); and forget about the command-line. i had it with it!
 
i'll focus for a while on P5. perhaps that's the marvelous thing about Processing, that it gives a beginner programmer as me, the power of doing stuff, without the hassle of, er.., the command-line!
 
i really admire your work, REAS & fry.
 
---
for the fellow beginners, my run.bat for P5AppDemo worked when modified as follows:
 
javaw -cp C:\P5AppDemo\ P5AppDemo P5AppDemo.class
(easy to understand, but i haven't crack the code)
 

pollux | www.frwrd.net
Pages: 1 

« Previous topic | Next topic »