----- Original Message ----- From "Bentz, Chad" Date Mon, 1 May 2006 22:05:05 -0400 Subject Sigining jar If anyone having trouble with the jars, here is what i do: After i compile i call a little batch file make.bat that contains the below: jar cvf CliSer.jar *.class jarsigner CliSer.jar YOURKEY chmod 644 CliSer.jar -It will prompt for your password here.. PS chmod the batch to be executable ----- Original Message ----- From "Spiegel, Daniel" Date Tue, 12 Jun 2007 21:00:35 -0400 Subject Closing the Window I received two viable methods for the window closing (worth 2 points each): 1. I found a way to close the window/tab in Internet Explorer using this line in the applet: getAppletContext().showDocument(new URL("javascript:self.close();")); It has to be in a try/catch clause for the new URL() or throw the exception, but when I tried this in FireFox it gave the error script cannot open windows it did not create. There are sites that claim if you trick the browser into thinking it opened the current window by changing the statement to: getAppletContext().showDocument(new URL("javascript:self.open('javascript:self.close();', '_self', '');')); I could not get this to work in FireFox's new version. 2. I don't know if this is perfect, but it works. I found out you can get back to the main page and call javascript functions from the JApplet using getAppletContext().showDocument(), so I used that to call a javascript function which closes the tab. Heres the example: http://acad.kutztown.edu/~ROTH7439/index.html Open it and view source. -- _________________________________________________________________ |Dr Daniel S. Spiegel Assistant Professor| |Department of Computer Science Kutztown University| |Faculty Office: 254 Lytle Hall Phone:(610)683-4423| |e-mail: spiegel@kutztown.edu | |Web: http://faculty.kutztown.edu/spiegel | -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- ----- Original Message ----- From "Bartkowski, Christopher" Date Wed, 13 Jun 2007 18:42:58 -0400 Subject Re: Closing the Window Joe's approach is how I've used javascript in the past. The third parameter in the window.open may also be useful. You can use it to specify the size of the window, with some other options. The example below removes all the navigation items so the user can not use the new page for normal browsing, as well as making the size so it can not be resized. window.open(url,'','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=790,height=550') Dr. Spiegel wrote: > I received two viable methods for the window closing (worth 2 points each): > > 1. I found a way to close the window/tab in Internet Explorer using this > line in > the applet: > > getAppletContext().showDocument(new URL("javascript:self.close();")); > > It has to be in a try/catch clause for the new URL() or throw the > exception, > but when I tried this in FireFox it gave the error script cannot open > windows > it did not create. There are sites that claim if you trick the browser into > thinking it opened the current window by changing the statement to: > > getAppletContext().showDocument(new > URL("javascript:self.open('javascript:self.close();', '_self', '');')); > > I could not get this to work in FireFox's new version. > > > 2. I don't know if this is perfect, but it works. I found out you can > get back to > the main page and call javascript functions from the JApplet using > getAppletContext().showDocument(), so I used that to call a javascript > function > which closes the tab. Heres the example: > > http://acad.kutztown.edu/~ROTH7439/index.html > > Open it and view source. > ----- Original Message ----- From "Waid, Christopher" Date Sun, 17 Jun 2007 11:12:08 -0400 Subject Re: Closing the Window Dr. Spiegel wrote: > I received two viable methods for the window closing (worth 2 points each): > > 1. I found a way to close the window/tab in Internet Explorer using this > line in > the applet: > > getAppletContext().showDocument(new URL("javascript:self.close();")); > > It has to be in a try/catch clause for the new URL() or throw the > exception, > but when I tried this in FireFox it gave the error script cannot open > windows > it did not create. There are sites that claim if you trick the browser into > thinking it opened the current window by changing the statement to: > > getAppletContext().showDocument(new > URL("javascript:self.open('javascript:self.close();', '_self', '');')); > > I could not get this to work in FireFox's new version. > > > 2. I don't know if this is perfect, but it works. I found out you can > get back to > the main page and call javascript functions from the JApplet using > getAppletContext().showDocument(), so I used that to call a javascript > function > which closes the tab. Heres the example: > > http://acad.kutztown.edu/~ROTH7439/index.html > > Open it and view source. > Talk about bad coding practices. If it isn't a standard and doesn't work in modern browsers, or likely won't work you shouldn't use it. Even Microsoft has almost certainly disabled this in v7. The open / close seems a little out of touch and I'd be hesitant to use it either. ----- Original Message ----- From "Shepley, Peter" Date Sun, 17 Jun 2007 20:35:03 -0400 Subject Re: Closing the Window cwaid083 said: > If it isn't a standard and doesn't work > in modern browsers, or likely won't work you shouldn't use it. Why? If there is the ability and need to perform a function, no matter how obfuscated, it can still be used in code. Bad coding practices would be allowing the code to run if it is not supported on the system. ----- Original Message ----- From "Bartkowski, Christopher" Date Thu, 28 Jun 2007 21:25:21 -0400 Subject setToolTipText() There was discussion before class Tuesday about using a tooltip, in place of a label, for showing a move result. setToolTipText("string") is inherited from JComponent and it does seems to work for my JLabel. setToolTipText(null) disables it. ----- Original Message ----- From "Petersen, Michael" Date Fri, 29 Jun 2007 16:29:53 -0400 Subject Disappearing components I have a problem with disappearing components. They were displaying fine, but I am now trying to implement the animation parts of the program and therefore need paint(). Once I have added this my components all disappear until I hover over them with my mouse. Any ideas? ----- Original Message ----- From "Bartkowski, Christopher" Date Fri, 29 Jun 2007 17:13:18 -0400 Subject Re: Disappearing components I had the same issue in Iteration 2. What I did was extend Jpanel, and implement the paint part in the JPanel. This localized the painting to the JPanel. Since it was a JPanel, I could easily emulate the JPanel's look with paint. It seems like whatever you implement paint with, the paint will override the rest. So, if it's a certain area you want to paint, you could possibly put a panel there and use paint with that panel. Not sure if there's a better way, but that's how I got it to work. mpete510 wrote: > I have a problem with disappearing components. They were displaying fine, but > I am now trying to implement the animation parts of the program and therefore > need paint(). Once I have added this my components all disappear until I hover > over them with my mouse. Any ideas? ----- Original Message ----- From "Haynes, Shannon" Date Fri, 29 Jun 2007 21:42:25 -0400 Subject Problem with Animation Threads I have been working to get my animations to work using the Image Animation example and editing it so that I can pass and Image array to it in order to create multiple animations using the same class. I declare a new instance of the object, but the animation won't play. I am using a series of pictures. Anyone have any suggestions????? Here's my animateImage class: package game; import java.awt.*; import java.net.*; import java.util.*; import java.applet.Applet; import javax.swing.*; public class animateImage implements Runnable { private int NumImages = 65; private int i = -1; private int ImageNum = 1; private Image[] IMG = new Image[NumImages]; private Thread updateThread = new Thread(this, "Animation Thread"); JPanel frame = new JPanel ( ); Graphics g; public animateImage (Image [] imagePics, int numImg, JPanel j) { frame = j; NumImages = numImg; for (int i = 0; i < NumImages; i++) IMG[i] = imagePics[i]; // updateThread.start(); } public void run() { Thread myThread = Thread.currentThread(); while (updateThread == myThread) { i++; if (i >= NumImages) i = 0; // paint(); g.drawImage(IMG[i], 0, 0, frame); try { if (i == NumImages - 1) updateThread.sleep(3000); else updateThread.sleep(300); } catch (InterruptedException e) { // Get back to work } } } /* public void repaint ( ) { Graphics r; paint (r); } public void paint(Graphics g) { g.drawImage(IMG[i], 0, 0, frame); } */ } I create a new instance of the class like this: animateImage b2e = new animateImage (bear2eagle, numBear2EagleImages, animatePanel); ----- Original Message ----- From "Petersen, Michael" Date Sat, 30 Jun 2007 10:13:20 -0400 Subject Re: Problem with Animation Threads I have done the same exact thing and am running into problems myself. ----- Original Message ----- From "Petersen, Michael" Date Sat, 30 Jun 2007 10:16:22 -0400 Subject Re: Disappearing components Something like that made it work actually. I found this series of posts http://forum.java.sun.com/thread.jspa?threadID=449423&messageID=2043366 late yesterday. The 6th & 7th respectively give the same advice that you give. ----- Original Message ----- From "Bartkowski, Christopher" Date Sat, 30 Jun 2007 10:35:14 -0400 Subject Re: Problem with Animation Threads I used an inner class that extends thread (not implementing runnable). Handing it off to the thread means it won't interfere with the other threads running. class paints extends Thread { public void run() { try { for(int i = 0 ; i <= 10 ; i ++) { index = i; repaint(); sleep(70); } } shaye436 wrote: > I have been working to get my animations to work using the Image Animation > example and editing it so that I can pass and Image array to it in order to > create multiple animations using the same class. I declare a new instance of > the object, but the animation won't play. I am using a series of pictures. > Anyone have any suggestions????? > > Here's my animateImage class: > > package game; > > import java.awt.*; > import java.net.*; > import java.util.*; > import java.applet.Applet; > import javax.swing.*; > > > public class animateImage implements Runnable { > private int NumImages = 65; > private int i = -1; > private int ImageNum = 1; > private Image[] IMG = new Image[NumImages]; > private Thread updateThread = new Thread(this, "Animation Thread"); > JPanel frame = new JPanel ( ); > Graphics g; > > public animateImage (Image [] imagePics, int numImg, JPanel j) { > frame = j; > NumImages = numImg; > for (int i = 0; i < NumImages; i++) > IMG[i] = imagePics[i]; > // updateThread.start(); > } > > public void run() > { > Thread myThread = Thread.currentThread(); > > while (updateThread == myThread) > { > i++; > if (i >= NumImages) > i = 0; > // paint(); > g.drawImage(IMG[i], 0, 0, frame); > try > { > if (i == NumImages - 1) > updateThread.sleep(3000); > else > updateThread.sleep(300); > } > catch (InterruptedException e) > { > // Get back to work > } > } > } > > /* public void repaint ( ) { > Graphics r; > paint (r); > } > > public void paint(Graphics g) > { > g.drawImage(IMG[i], 0, 0, frame); > } > */ > } > > > > I create a new instance of the class like this: > > animateImage b2e = new animateImage (bear2eagle, numBear2EagleImages, > animatePanel); ----- Original Message ----- From "Haynes, Shannon" Date Sat, 30 Jun 2007 14:18:32 -0400 Subject java security exception I keep getting java.security.AccessControlException: access denied (java.io.FIlePermission b_e01.gif read) when I try to load the images to run in the thread. I've tried making a URL object out of it, but I get a MalformedURLException. Does anyone have any suggestions? ----- Original Message ----- From "Petersen, Michael" Date Sat, 30 Jun 2007 17:56:50 -0400 Subject Re: Problem with Animation Threads I am still having trouble. What does your paint look like? Something like this? public void paint(Graphics g) { g.drawImage(IMG[i], 0, 0, this); } ----- Original Message ----- From "Bartkowski, Christopher" Date Sat, 30 Jun 2007 19:04:18 -0400 Subject Re: Problem with Animation Threads g.drawImage(images[index],0,0,x,y,null); You specified a location, but it looks like no width/height for the actual image. mpete510 wrote: > I am still having trouble. What does your paint look like? Something like this? > > public void paint(Graphics g) > { > g.drawImage(IMG[i], 0, 0, this); > } ----- Original Message ----- From "Petersen, Michael" Date Sat, 30 Jun 2007 19:10:13 -0400 Subject Re: Problem with Animation Threads Even with a width and height it still does not work for me... Here is my subclass: class Animation extends Thread { int numImages; String codeBase; public Animation(String loc, int num) { numImages = num; codeBase = loc; img = new Image[numImages]; } public void run() { for(int j = 0; j < numImages; j++) { try { img[j] = getImage(new URL(codeBase), Integer.toString(j) + ".jpg"); } catch(Exception e){} } try { for(index = 0; index < numImages; index++) { repaint(); sleep(100); } }catch(Exception e){} index = -1; } } And then the paint function is: public void paint(Graphics g) { super.paint(g); if(index != -1) g.drawImage(img[index], 0, 540, 480, 100, this); } What I don't get is in this setup the animations run is getting called, and the loop is executing numImages number of times but the paint function is not getting called at all. I found this out by putting some println's in each of them. It boggles my mind how even with repaint() getting called the paint() is not getting called. ----- Original Message ----- From "Haynes, Shannon" Date Sat, 30 Jun 2007 20:20:42 -0400 Subject Re: Problem with Animation Threads I am having the exact same problem with my paint function not being called. The run( ) runs perfectly, but paint is never called. ----- Original Message ----- From "Bartkowski, Christopher" Date Sat, 30 Jun 2007 20:45:08 -0400 Subject Re: Problem with Animation Threads Your try-catch (catch section) is empty. You could try putting the getStackTrace & getMessage and see if you're getting an error somewhere. mpete510 wrote: > Even with a width and height it still does not work for me... > > Here is my subclass: > class Animation extends Thread > { > int numImages; > String codeBase; > public Animation(String loc, int num) > { > numImages = num; > codeBase = loc; > img = new Image[numImages]; > } > > public void run() > { > for(int j = 0; j < numImages; j++) > { > try > { > img[j] = getImage(new URL(codeBase), Integer.toString(j) + ".jpg"); > } > catch(Exception e){} > } > try > { > for(index = 0; index < numImages; index++) > { > repaint(); > sleep(100); > } > }catch(Exception e){} > index = -1; > } > } > > And then the paint function is: > public void paint(Graphics g) > { > super.paint(g); > if(index != -1) > g.drawImage(img[index], 0, 540, 480, 100, this); > } > > > What I don't get is in this setup the animations run is getting called, and the > loop is executing numImages number of times but the paint function is not getting > called at all. I found this out by putting some println's in each of them. It > boggles my mind how even with repaint() getting called the paint() is not getting > called. ----- Original Message ----- From "Petersen, Michael" Date Sat, 30 Jun 2007 20:51:55 -0400 Subject Re: Problem with Animation Threads I put those in and nothing else gets printed to the console. ----- Original Message ----- From "Petersen, Michael" Date Sat, 30 Jun 2007 23:15:48 -0400 Subject Re: Problem with Animation Threads (some results) Chris suggested that I look at Dr. Spiegels example here http://faculty.kutztown.edu/spiegel/CSc421/java/Images/AnimateImageNoFlicker.html . After looking at that I added the "img[index] = createImage(480, 100);" line, and the area where the animation is flickers a bit. Not the image that I was looking for, but some flickering is better than none. public void paint(Graphics g) { super.paint(g); if(index != -1) { img[index] = createImage(480, 100); g.drawImage(img[index], 0, 540, 480, 100, this); } } ----- Original Message ----- From "Reeser, Jonathan" Date Sun, 1 Jul 2007 12:56:09 -0400 Subject Re: Problem with Animation Threads repaint() and paint() are members of Component. It looks like the Animation class does not inherit (directly or indirectly) from a Component; therefore, not displayable. I'm guessing paint() isn't getting called because it is a top level function (not overriding paint from Component). Similarly, I doubt repaint() is calling Component.repaint(), it could be doing something completely different than expected. ----- Original Message ----- From "Reeser, Jonathan" Date Sun, 1 Jul 2007 13:02:48 -0400 Subject Re: Disappearing components I had this problem: 1) Add components to a panel. They are displayed fine. 2) Remove all existing components from the panel. They are removed from the display. 3) Add new components to the panel. Not displayed. The solution was: Note: this inherits from JPanel this.removeAll(); // fails without this call this.revalidate(); // add new components here this.repaint(); NOTE: All my subcomponents do all drawing in paint(). ----- Original Message ----- From "Reeser, Jonathan" Date Sun, 1 Jul 2007 13:06:22 -0400 Subject Re: java security exception Loading an image from the jar: URL url = getClass().getResource( "file.jpg" ); try { image = Toolkit.getDefaultToolkit().getImage( url ); mt.addImage( image, 1 ); mt.waitForID( 1 ); } catch( Exception e2 ) { System.out.println( "Failed to load image: " + strFile ); } ----- Original Message ----- From "Bartkowski, Christopher" Date Mon, 2 Jul 2007 07:57:45 -0400 Subject Re: Problem with Animation Threads I don't believe that's the issue. Unless I misunderstood, Animation is a subclass of another class and that is where the paint is, that parent class. jrees393 wrote: > repaint() and paint() are members of Component. It looks like the Animation class > does not inherit (directly or indirectly) from a Component; therefore, not > displayable. I'm guessing paint() isn't getting called because it is a top level > function (not overriding paint from Component). Similarly, I doubt repaint() is > calling Component.repaint(), it could be doing something completely different than > expected.