<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>CodeGuru Forums - Java Programming</title>
		<link>http://forums.codeguru.com/</link>
		<description>Ask your Java programming question and help out others with theirs.</description>
		<language>en</language>
		<lastBuildDate>Sat, 25 May 2013 18:54:50 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://forums.codeguru.com/images/misc/rss.png</url>
			<title>CodeGuru Forums - Java Programming</title>
			<link>http://forums.codeguru.com/</link>
		</image>
		<item>
			<title>How To Enter Name with Whitespaces in a String Variable</title>
			<link>http://forums.codeguru.com/showthread.php?537229-How-To-Enter-Name-with-Whitespaces-in-a-String-Variable&amp;goto=newpost</link>
			<pubDate>Thu, 23 May 2013 06:46:53 GMT</pubDate>
			<description><![CDATA[Hi Team,

 I am wondering how to enter a string with White Space and Store it in a String variable.

  For example : I have created a string named "name".

  String name;

  I want to Store "Michael Jackson" in the String "name". I couldn't do it. My program Just accepts Michael and not Jackson.

here is my code ;

import java.util.Scanner;

public class Stringtwo

{

public static void main(String[] args)

{

String name;

Scanner scannedInfo=new Scanner(System.in);

name=scannedInfo.next();

System.out.println(name);

}

}]]></description>
			<content:encoded><![CDATA[<div>Hi Team,<br />
<br />
 I am wondering how to enter a string with White Space and Store it in a String variable.<br />
<br />
  For example : I have created a string named &quot;name&quot;.<br />
<br />
  String name;<br />
<br />
  I want to Store &quot;Michael Jackson&quot; in the String &quot;name&quot;. I couldn't do it. My program Just accepts Michael and not Jackson.<br />
<br />
here is my code ;<br />
<br />
import java.util.Scanner;<br />
<br />
public class Stringtwo<br />
<br />
{<br />
<br />
public static void main(String[] args)<br />
<br />
{<br />
<br />
String name;<br />
<br />
Scanner scannedInfo=new Scanner(System.in);<br />
<br />
name=scannedInfo.next();<br />
<br />
System.out.println(name);<br />
<br />
}<br />
<br />
}</div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?5-Java-Programming">Java Programming</category>
			<dc:creator>murali89</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?537229-How-To-Enter-Name-with-Whitespaces-in-a-String-Variable</guid>
		</item>
		<item>
			<title>Servlet throws error on compilation</title>
			<link>http://forums.codeguru.com/showthread.php?537173-Servlet-throws-error-on-compilation&amp;goto=newpost</link>
			<pubDate>Tue, 21 May 2013 08:23:57 GMT</pubDate>
			<description><![CDATA[Please I am getting this error when I try to compile a web application in Eclipse. what am i doing wrong? kindly share your professional advice. Thanks. as a newbie to Spring-hibernate application i am following this tutorial - <a href = "http://viralpatel.net/blogs/spring3-mvc-hibernate-maven-tutorial-eclipse-example/?replytocom=42097#respond">Viralpatel- Spring-Hibernate</a>



Code:
---------
type Exception report

message Servlet.init() for servlet spring threw exception

description The server encountered an internal error that prevented it from fulfilling this request.

exception 

javax.servlet.ServletException: Servlet.init() for servlet spring threw exception
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
	org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
	org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
	org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
	org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
	java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	java.lang.Thread.run(Thread.java:722)


root cause 

java.lang.NoSuchMethodError: org.springframework.core.io.ResourceEditor.<init>(Lorg/springframework/core/io/ResourceLoader;Lorg/springframework/core/env/PropertyResolver;)V
	org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)
	javax.servlet.GenericServlet.init(GenericServlet.java:160)
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
	org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
	org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
	org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
	org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
	java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	java.lang.Thread.run(Thread.java:722)


note The full stack trace of the root cause is available in the Apache Tomcat/7.0.30 logs.
---------
]]></description>
			<content:encoded><![CDATA[<div>Please I am getting this error when I try to compile a web application in Eclipse. what am i doing wrong? kindly share your professional advice. Thanks. as a newbie to Spring-hibernate application i am following this tutorial - &lt;a href = &quot;http://viralpatel.net/blogs/spring3-mvc-hibernate-maven-tutorial-eclipse-example/?replytocom=42097#respond&quot;&gt;Viralpatel- Spring-Hibernate&lt;/a&gt;<br />
<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">type Exception report<br />
<br />
message Servlet.init() for servlet spring threw exception<br />
<br />
description The server encountered an internal error that prevented it from fulfilling this request.<br />
<br />
exception <br />
<br />
javax.servlet.ServletException: Servlet.init() for servlet spring threw exception<br />
&nbsp; &nbsp; &nbsp; &nbsp; org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)<br />
&nbsp; &nbsp; &nbsp; &nbsp; org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)<br />
&nbsp; &nbsp; &nbsp; &nbsp; org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)<br />
&nbsp; &nbsp; &nbsp; &nbsp; org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)<br />
&nbsp; &nbsp; &nbsp; &nbsp; org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)<br />
&nbsp; &nbsp; &nbsp; &nbsp; org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)<br />
&nbsp; &nbsp; &nbsp; &nbsp; org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)<br />
&nbsp; &nbsp; &nbsp; &nbsp; java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)<br />
&nbsp; &nbsp; &nbsp; &nbsp; java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)<br />
&nbsp; &nbsp; &nbsp; &nbsp; java.lang.Thread.run(Thread.java:722)<br />
<br />
<br />
root cause <br />
<br />
java.lang.NoSuchMethodError: org.springframework.core.io.ResourceEditor.&lt;init&gt;(Lorg/springframework/core/io/ResourceLoader;Lorg/springframework/core/env/PropertyResolver;)V<br />
&nbsp; &nbsp; &nbsp; &nbsp; org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)<br />
&nbsp; &nbsp; &nbsp; &nbsp; javax.servlet.GenericServlet.init(GenericServlet.java:160)<br />
&nbsp; &nbsp; &nbsp; &nbsp; org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)<br />
&nbsp; &nbsp; &nbsp; &nbsp; org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)<br />
&nbsp; &nbsp; &nbsp; &nbsp; org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)<br />
&nbsp; &nbsp; &nbsp; &nbsp; org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)<br />
&nbsp; &nbsp; &nbsp; &nbsp; org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)<br />
&nbsp; &nbsp; &nbsp; &nbsp; org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)<br />
&nbsp; &nbsp; &nbsp; &nbsp; org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)<br />
&nbsp; &nbsp; &nbsp; &nbsp; java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)<br />
&nbsp; &nbsp; &nbsp; &nbsp; java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)<br />
&nbsp; &nbsp; &nbsp; &nbsp; java.lang.Thread.run(Thread.java:722)<br />
<br />
<br />
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.30 logs.</code><hr />
</div> </div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?5-Java-Programming">Java Programming</category>
			<dc:creator>ken4ward</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?537173-Servlet-throws-error-on-compilation</guid>
		</item>
		<item>
			<title>Help connecting java GUI to dabase</title>
			<link>http://forums.codeguru.com/showthread.php?537115-Help-connecting-java-GUI-to-dabase&amp;goto=newpost</link>
			<pubDate>Sun, 19 May 2013 16:36:57 GMT</pubDate>
			<description><![CDATA[hello everyone,
I have a school project and I have no ideea where to start. I am a begginer and I need help understanding some things. The reason I am asking is because I can`t seem to find a straight answer to my problem no matter where I search for. Maybe I am asking the wrong question so I will try to describe my problem.

What I need to do is, to connect a java program to a database ( mysql ), and via GUI to display some records from a table. 

Now, the table I am trying to display will be called "Flights", and has the next rows: "FlightiD","departure","destination","departureTime","arrivalTime","status", 

The ideea is. that I need 2 GUI`s "Arrivals" and "Departures" that both take data from the table, and another one that allows me to modify the data into the table. Where do I find such a tutorial to help me do this? Is it possible for someone to show me pieces of code that will help me do this? How do I connect my java program to the database?

Of course the "Flights" table has data from other tables (company, Airport ).

I know it`s much to ask, but I need to start from somewhere and all the java tutorials I read and leaned, didn`t show me much about how I can do this. 
Thank you for your help!]]></description>
			<content:encoded><![CDATA[<div>hello everyone,<br />
I have a school project and I have no ideea where to start. I am a begginer and I need help understanding some things. The reason I am asking is because I can`t seem to find a straight answer to my problem no matter where I search for. Maybe I am asking the wrong question so I will try to describe my problem.<br />
<br />
What I need to do is, to connect a java program to a database ( mysql ), and via GUI to display some records from a table. <br />
<br />
Now, the table I am trying to display will be called &quot;Flights&quot;, and has the next rows: &quot;FlightiD&quot;,&quot;departure&quot;,&quot;destination&quot;,&quot;departureTime&quot;,&quot;arrivalTime&quot;,&quot;status&quot;, <br />
<br />
The ideea is. that I need 2 GUI`s &quot;Arrivals&quot; and &quot;Departures&quot; that both take data from the table, and another one that allows me to modify the data into the table. Where do I find such a tutorial to help me do this? Is it possible for someone to show me pieces of code that will help me do this? How do I connect my java program to the database?<br />
<br />
Of course the &quot;Flights&quot; table has data from other tables (company, Airport ).<br />
<br />
I know it`s much to ask, but I need to start from somewhere and all the java tutorials I read and leaned, didn`t show me much about how I can do this. <br />
Thank you for your help!</div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?5-Java-Programming">Java Programming</category>
			<dc:creator>Smashw</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?537115-Help-connecting-java-GUI-to-dabase</guid>
		</item>
		<item>
			<title>Bresenham algorithm</title>
			<link>http://forums.codeguru.com/showthread.php?537111-Bresenham-algorithm&amp;goto=newpost</link>
			<pubDate>Sun, 19 May 2013 14:11:55 GMT</pubDate>
			<description><![CDATA[I use bresenhams line algorithm to draw a line.Sometimes when the slope is close to 0.5 the line isn't drawing correctly.Some parts of the line are thicker than other or the line that is drawn looks like a triangle.The following code is for the first and fourth octant.
Why this is happening?

Code:
---------

public void	draw_line(Graphics g,int x1,int y1,int xn,int yn)
	{
		int error,dx,dy,y,x;
		
	

		dx=xn-x1;
		dy=yn-y1;
		
		y=y1;
		x=x1;
		//the octant of the line
		if(slope==1||slope==4)
		{
			error=-dx/2;
		for( x=x1;x<=xn;x++)
		{  
			PutPixel(g,x,y);
			error=error+dy;
		if(error>=0)
		{y++;
		error=error-dx;}}}
---------
]]></description>
			<content:encoded><![CDATA[<div>I use bresenhams line algorithm to draw a line.Sometimes when the slope is close to 0.5 the line isn't drawing correctly.Some parts of the line are thicker than other or the line that is drawn looks like a triangle.The following code is for the first and fourth octant.<br />
Why this is happening?<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code"><br />
public void&nbsp; &nbsp; &nbsp; &nbsp; draw_line(Graphics g,int x1,int y1,int xn,int yn)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int error,dx,dy,y,x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dx=xn-x1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dy=yn-y1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y=y1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x=x1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //the octant of the line<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(slope==1||slope==4)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error=-dx/2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for( x=x1;x&lt;=xn;x++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PutPixel(g,x,y);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error=error+dy;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(error&gt;=0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {y++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error=error-dx;}}}</code><hr />
</div> </div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?5-Java-Programming">Java Programming</category>
			<dc:creator>killbill689</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?537111-Bresenham-algorithm</guid>
		</item>
		<item>
			<title>adding bftsmart package</title>
			<link>http://forums.codeguru.com/showthread.php?537051-adding-bftsmart-package&amp;goto=newpost</link>
			<pubDate>Thu, 16 May 2013 21:28:05 GMT</pubDate>
			<description><![CDATA[I downloaded the bftsmart-v0.8 . I have tried to follow the instructions from google code. but I don't know
how to get the bftsmart.tom.ServiceProxy to into my eclipse application. just writing import bftsmart.tom.ServiceProxy does not work. please help I am new in java programming]]></description>
			<content:encoded><![CDATA[<div>I downloaded the bftsmart-v0.8 . I have tried to follow the instructions from google code. but I don't know<br />
how to get the bftsmart.tom.ServiceProxy to into my eclipse application. just writing import bftsmart.tom.ServiceProxy does not work. please help I am new in java programming</div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?5-Java-Programming">Java Programming</category>
			<dc:creator>zandere</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?537051-adding-bftsmart-package</guid>
		</item>
		<item>
			<title>Javac is not compiling correctly ... Please help</title>
			<link>http://forums.codeguru.com/showthread.php?537033-Javac-is-not-compiling-correctly-...-Please-help&amp;goto=newpost</link>
			<pubDate>Thu, 16 May 2013 07:53:36 GMT</pubDate>
			<description><![CDATA[Hi Team,

I have installed jdk1.7.0_21 in my windows xp as well as windows 8 Systems.

When i try to compile a Simple Java program. Im getting the following error. 

My code :

public class hello

{

public static void main(string[] args)

{

system.out.println("hello world");

}


}


Error :


C:\Java>javac hello.java
hello.java:5: error: cannot find symbol
public static void main(string[] args)
                        ^
  symbol:   class string
  location: class hello
hello.java:9: error: package system does not exist
system.out.println("hello world");
      ^
2 errors

I have added the path to environment variable (both Class path and Path).  Here is my Path

Class path c:\sybase\ASEP_Win32\3pclass.zip;c:\sybase\ASEP_Win32\monclass.zip;C:\Program Files\Java\jdk1.7.0_21\bin\

C:\Java>path
PATH=c:\sybase\OLEDB;c:\sybase\ODBC;c:\sybase\ASEP_Win32;c:\sybase\OCS-12_5\dll;
c:\sybase\OCS-12_5\lib3p;c:\sybase\OCS-12_5\bin;C:\Program Files\Reflection;C:\W
INDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\system32\nls;C:\W
INDOWS\system32\nls\ENGLISH;C:\Program Files\IFFtools;C:\Program Files\IBM\Direc
tor\bin;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\Sym
antec\pcAnywhere\;C:\Program Files\Common Files\Hitachi ID\;C:\Program Files\Jav
a\jdk1.7.0_21\bin\;C:\TCWIN45\BIN;C:\Program Files\Java\jdk1.7.0_21\bin\


Why am i not able to compile my program. Im really confused. please help.]]></description>
			<content:encoded><![CDATA[<div>Hi Team,<br />
<br />
I have installed jdk1.7.0_21 in my windows xp as well as windows 8 Systems.<br />
<br />
When i try to compile a Simple Java program. Im getting the following error. <br />
<br />
My code :<br />
<br />
public class hello<br />
<br />
{<br />
<br />
public static void main(string[] args)<br />
<br />
{<br />
<br />
system.out.println(&quot;hello world&quot;);<br />
<br />
}<br />
<br />
<br />
}<br />
<br />
<br />
Error :<br />
<br />
<br />
C:\Java&gt;javac hello.java<br />
hello.java:5: error: cannot find symbol<br />
public static void main(string[] args)<br />
                        ^<br />
  symbol:   class string<br />
  location: class hello<br />
hello.java:9: error: package system does not exist<br />
system.out.println(&quot;hello world&quot;);<br />
      ^<br />
2 errors<br />
<br />
I have added the path to environment variable (both Class path and Path).  Here is my Path<br />
<br />
Class path c:\sybase\ASEP_Win32\3pclass.zip;c:\sybase\ASEP_Win32\monclass.zip;C:\Program Files\Java\jdk1.7.0_21\bin\<br />
<br />
C:\Java&gt;path<br />
PATH=c:\sybase\OLEDB;c:\sybase\ODBC;c:\sybase\ASEP_Win32;c:\sybase\OCS-12_5\dll;<br />
c:\sybase\OCS-12_5\lib3p;c:\sybase\OCS-12_5\bin;C:\Program Files\Reflection;C:\W<br />
INDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\system32\nls;C:\W<br />
INDOWS\system32\nls\ENGLISH;C:\Program Files\IFFtools;C:\Program Files\IBM\Direc<br />
tor\bin;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\Sym<br />
antec\pcAnywhere\;C:\Program Files\Common Files\Hitachi ID\;C:\Program Files\Jav<br />
a\jdk1.7.0_21\bin\;C:\TCWIN45\BIN;C:\Program Files\Java\jdk1.7.0_21\bin\<br />
<br />
<br />
Why am i not able to compile my program. Im really confused. please help.</div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?5-Java-Programming">Java Programming</category>
			<dc:creator>murali89</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?537033-Javac-is-not-compiling-correctly-...-Please-help</guid>
		</item>
		<item>
			<title>Java Image Query Problem</title>
			<link>http://forums.codeguru.com/showthread.php?536981-Java-Image-Query-Problem&amp;goto=newpost</link>
			<pubDate>Tue, 14 May 2013 11:46:20 GMT</pubDate>
			<description><![CDATA[Hello. I am posting here, as I am having a problem, maybe more. What  I am trying to do is to emulate a  *Google Image Search*.
I found a way to do this by using no special APIs as I am completely unfamiliar to this kind of practice. What I am trying to do in order to grab an image query 
is this:
Append my query term to the following link:

 *http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=* 


You can see the actual page here:
http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=panda
This will return a result like:


Code:
---------
{"responseData": {"results":[{"GsearchResultClass":"GimageSearch","width":"640","height":"480","imageId":"ANd9GcQRrzUNljCTG8-I68KUD8-SI2uwG77AYHvCcA50IFu4cs9WDK2DV9zHgnc","tbWidth":"137","tbHeight":"103","unescapedUrl":"http://assets.worldwildlife.org/photos/144/images/hero_small/Giant_Panda_Hero_image_(c)_Michel_Gunther_WWF_Canon.jpg?1345515244","url":"http://assets.worldwildlife.org/photos/144/images/hero_small/Giant_Panda_Hero_image_(c)_Michel_Gunther_WWF_Canon.jpg%3F1345515244","visibleUrl":"worldwildlife.org","title":"Giant \u003cb\u003ePanda\u003c/b\u003e | Species | WWF","titleNoFormatting":"Giant Panda | Species | WWF","originalContextUrl":"http://worldwildlife.org/species/giant-panda","content":"Giant \u003cb\u003ePanda\u003c/b\u003e","contentNoFormatting":"Giant Panda","tbUrl":"http://t0.gstatic.com/images?q\u003dtbn:ANd9GcQRrzUNljCTG8-I68KUD8-SI2uwG77AYHvCcA50IFu4cs9WDK2DV9zHgnc"},{"GsearchResultClass":"GimageSearch","width":"606","height":"387","imageId":"ANd9GcSE2zijRhPrLfVHuzROQrMbd3AXdutJwWiUyqysnDnUK07UjOlWdDJHOZHU","tbWidth":"136","tbHeight":"87","unescapedUrl":"http://www.washingtonpost.com/rf/image_606w/WashingtonPost/Content/Blogs/in-the-loop/Images/2012-09-17T130533Z_01_TOR901_RTRIDSP_3_USA-PANDA-WASHINGTON-218.jpg","url":"http://www.washingtonpost.com/rf/image_606w/WashingtonPost/Content/Blogs/in-the-loop/Images/2012-09-17T130533Z_01_TOR901_RTRIDSP_3_USA-PANDA-WASHINGTON-218.jpg","visibleUrl":"articles.washingtonpost.com","title":"National Zoo welcomes baby \u003cb\u003epanda\u003c/b\u003e - Washington Post","titleNoFormatting":"National Zoo welcomes baby panda - Washington Post","originalContextUrl":"http://articles.washingtonpost.com/2012-09-17/local/35498108_1_panda-cub-panda-reproduction-baby-panda","content":"Zoo welcomes baby \u003cb\u003epanda\u003c/b\u003e","contentNoFormatting":"Zoo welcomes baby panda","tbUrl":"http://t1.gstatic.com/images?q\u003dtbn:ANd9GcSE2zijRhPrLfVHuzROQrMbd3AXdutJwWiUyqysnDnUK07UjOlWdDJHOZHU"},{"GsearchResultClass":"GimageSearch","width":"948","height":"964","imageId":"ANd9GcQnXahbarc0laLmKjf4Rz9JYwVdWPfsWlF1rb_ytZTIzcg2akZaoskVxcCT","tbWidth":"146","tbHeight":"148","unescapedUrl":"http://media.npr.org/assets/img/2012/01/04/ap99121501386_custom-feedbb6efa738efee47e7828e805758dc427fa60-s6-c10.jpg","url":"http://media.npr.org/assets/img/2012/01/04/ap99121501386_custom-feedbb6efa738efee47e7828e805758dc427fa60-s6-c10.jpg","visibleUrl":"www.npr.org","title":"What The \u003cb\u003ePanda\u003c/b\u003e Won\u0026#39;t Tell Us : Krulwich Wonders... : NPR","titleNoFormatting":"What The Panda Won\u0026#39;t Tell Us : Krulwich Wonders... : NPR","originalContextUrl":"http://www.npr.org/blogs/krulwich/2012/01/03/144633582/what-the-panda-won-t-tell-us","content":"Every giant \u003cb\u003epanda\u003c/b\u003e, said","contentNoFormatting":"Every giant panda, said","tbUrl":"http://t1.gstatic.com/images?q\u003dtbn:ANd9GcQnXahbarc0laLmKjf4Rz9JYwVdWPfsWlF1rb_ytZTIzcg2akZaoskVxcCT"},{"GsearchResultClass":"GimageSearch","width":"948","height":"711","imageId":"ANd9GcT3wJ6FzzTa01idfln9jm2pNKC8YJFAJGsMim0KjGR9fztzbIdFhZcvPAA","tbWidth":"148","tbHeight":"111","unescapedUrl":"http://media.npr.org/assets/news/2010/04/11/panda-f8a7c9331bbac776e52b26feeccc53de959f46d1-s6-c10.jpg","url":"http://media.npr.org/assets/news/2010/04/11/panda-f8a7c9331bbac776e52b26feeccc53de959f46d1-s6-c10.jpg","visibleUrl":"www.npr.org","title":"Why The Animal Critic Gives The \u003cb\u003ePanda\u003c/b\u003e An F : NPR","titleNoFormatting":"Why The Animal Critic Gives The Panda An F : NPR","originalContextUrl":"http://www.npr.org/templates/story/story.php?storyId\u003d125773728","content":"A \u003cb\u003epanda\u003c/b\u003e. iStockphoto.com","contentNoFormatting":"A panda. iStockphoto.com","tbUrl":"http://t3.gstatic.com/images?q\u003dtbn:ANd9GcT3wJ6FzzTa01idfln9jm2pNKC8YJFAJGsMim0KjGR9fztzbIdFhZcvPAA"}],"cursor":{"resultCount":"428,000,000","pages":[{"start":"0","label":1},{"start":"4","label":2},{"start":"8","label":3},{"start":"12","label":4},{"start":"16","label":5},{"start":"20","label":6},{"start":"24","label":7},{"start":"28","label":8}],"estimatedResultCount":"428000000","currentPageIndex":0,"moreResultsUrl":"http://www.google.com/images?oe\u003dutf8\u0026ie\u003dutf8\u0026source\u003duds\u0026start\u003d0\u0026hl\u003den\u0026q\u003dpanda","searchResultTime":"0.24"}}, "responseDetails": null, "responseStatus": 200}
---------
 
for Querying the term "panda"

The Result itself might seem confusing at first, but by filtering it with the following regex a much more clear list of results can be displayed.

 *(\"http\\S+?jpg\")* 

After applying this regex a list like the following can be extracted:

"http://t0.gstatic.com/images?q\u003dtbn:ANd9GcQRrzUNljCTG8-I68KUD8-SI2uwG77AYHvCcA50IFu4cs9WDK2DV9zHgnc"},{"GsearchResultClass":"GimageSearch","width":"606","height":"387","imageId":"ANd9GcSE2zijRhPrLfVHuzROQrMbd3AXdutJwWiUyqysnDnUK07UjOlWdDJHOZHU","tbWidth":"136","tbHeight":"87","unescapedUrl":"http://www.washingtonpost.com/rf/image_606w/WashingtonPost/Content/Blogs/in-the-loop/Images/2012-09-17T130533Z_01_TOR901_RTRIDSP_3_USA-PANDA-WASHINGTON-218.jpg"
"http://www.washingtonpost.com/rf/image_606w/WashingtonPost/Content/Blogs/in-the-loop/Images/2012-09-17T130533Z_01_TOR901_RTRIDSP_3_USA-PANDA-WASHINGTON-218.jpg"
"http://t1.gstatic.com/images?q\u003dtbn:ANd9GcSE2zijRhPrLfVHuzROQrMbd3AXdutJwWiUyqysnDnUK07UjOlWdDJHOZHU"},{"GsearchResultClass":"GimageSearch","width":"948","height":"964","imageId":"ANd9GcQnXahbarc0laLmKjf4Rz9JYwVdWPfsWlF1rb_ytZTIzcg2akZaoskVxcCT","tbWidth":"146","tbHeight":"148","unescapedUrl":"http://media.npr.org/assets/img/2012/01/04/ap99121501386_custom-feedbb6efa738efee47e7828e805758dc427fa60-s6-c10.jpg"
"http://media.npr.org/assets/img/2012/01/04/ap99121501386_custom-feedbb6efa738efee47e7828e805758dc427fa60-s6-c10.jpg"
"http://t1.gstatic.com/images?q\u003dtbn:ANd9GcQnXahbarc0laLmKjf4Rz9JYwVdWPfsWlF1rb_ytZTIzcg2akZaoskVxcCT"},{"GsearchResultClass":"GimageSearch","width":"948","height":"711","imageId":"ANd9GcT3wJ6FzzTa01idfln9jm2pNKC8YJFAJGsMim0KjGR9fztzbIdFhZcvPAA","tbWidth":"148","tbHeight":"111","unescapedUrl":"http://media.npr.org/assets/news/2010/04/11/panda-f8a7c9331bbac776e52b26feeccc53de959f46d1-s6-c10.jpg"
"http://media.npr.org/assets/news/2010/04/11/panda-f8a7c9331bbac776e52b26feeccc53de959f46d1-s6-c10.jpg"

As you can easily tell, not all URLs are valid, but there are 2 or 3 that could be used. 
What I am trying to do is extracting a list of "potential valid URLs" and then try to make labels with imageIcons extracted off the valid links.
This is my code so far.

Code:
---------
import java.awt.BorderLayout;


public class browser extends JFrame {

	private JPanel contentPane;
	private JTextField textField;



	/**
	 * Create the frame.
	 */
	public browser() {
		
		setBounds(100, 100, 450, 300);
		setVisible(true);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		textField = new JTextField();
		textField.setBounds(6, 11, 390, 28);
		contentPane.add(textField);
		textField.setColumns(10);
		mainFrame mOb = new mainFrame();
		
		JButton search = new JButton("");
		
		search.setIcon(new ImageIcon("C:\\Users\\Mihai\\Desktop\\search-icon.png"));
		search.setBounds(397, 11, 31, 28);
		contentPane.add(search);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(6, 51, 422, 205);
		contentPane.add(scrollPane);
		scrollPane.getViewport().setOpaque(false);
		final JPanel editorPane = new JPanel();
		scrollPane.setViewportView(editorPane);
		editorPane.setOpaque(false);
		editorPane.setBackground(new Color(0,0,0,0));
		
		JLabel background = new JLabel("");
		background.setBounds(0, 0, 434, 262);
		contentPane.add(background);
		background.setIcon(mOb.BG);
		
		final JEditorPane editorPane_1 = new JEditorPane();
		editorPane_1.setBounds(6, 35, 0, 0);
		contentPane.add(editorPane_1);
		
		
		
		editorPane.setLayout(new FlowLayout());
		//SEARCH LISTENER
		search.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				String query = textField.getText();
				
				// VALID SEARCH
				if(query!=""){
					
					String rawString="";
					
					
					try{
					URL rawURL = new URL("http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q="+query);
					
					editorPane_1.setPage(rawURL);
					 rawString = editorPane_1.getText().replaceAll("\n", System.getProperty("line.separator"));
					editorPane_1.setText("");
					System.out.println(rawString);
	}catch(Exception ex){
						
						ex.printStackTrace();
						System.out.println("FIRST BLOCK ");
					}
					
					
					
//GET NUMBER OF LINKS
 Pattern pattern = Pattern.compile("(\"http\\S+?jpg\")");
Matcher matcher = pattern.matcher(rawString);
int j = 0;
while (matcher.find()) {
	j++;
   
}

String refString[] = new String[j]; 


//ASSIGN LINKS

Pattern pattern2 = Pattern.compile("(\"http\\S+?jpg\")");
Matcher matcher2 = pattern.matcher(rawString);
int k =0;
while (matcher2.find()) {
	refString[k]=matcher2.group().toString();
	System.out.println(refString[k]);
    
}
					
					
					
					
					
					  //INSERT PROPER REGEX
					int i = 0;
					for(i = 0; i<refString.length; i++){
						JLabel label= new JLabel("SUP");
						label.setPreferredSize(new Dimension(200,100));
						try{
						URL url  = new URL(refString[i].trim());
						
						ImageIcon icon = new ImageIcon(ImageIO.read(url));
						 label.setIcon(icon);
							
						}catch(Exception ex){
						ex.printStackTrace();
							continue;
							
							
						}
						System.out.println("\n FINISHED BLOCK!!!! ");
						editorPane.add(new JScrollPane(label));
					}
					
					
					
					
					
					
				
					
					
				}
				
			}
		});
		
		
		
		
		
	}
}
---------
]]></description>
			<content:encoded><![CDATA[<div>Hello. I am posting here, as I am having a problem, maybe more. What  I am trying to do is to emulate a  <font color="#c61818"><b>Google Image Search</b></font>.<br />
I found a way to do this by using no special APIs as I am completely unfamiliar to this kind of practice. What I am trying to do in order to grab an image query <br />
is this:<br />
Append my query term to the following link:<br />
<br />
 <font color="#c61818"><b><a rel="nofollow" href="http://ajax.googleapis.com/ajax/services/search/images?v=1.0&amp;q=" target="_blank">http://ajax.googleapis.com/ajax/serv...mages?v=1.0&amp;q=</a></b></font> <br />
<br />
<br />
You can see the actual page here:<br />
<a rel="nofollow" href="http://ajax.googleapis.com/ajax/services/search/images?v=1.0&amp;q=panda" target="_blank">http://ajax.googleapis.com/ajax/serv...?v=1.0&amp;q=panda</a><br />
This will return a result like:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">{&quot;responseData&quot;: {&quot;results&quot;:[{&quot;GsearchResultClass&quot;:&quot;GimageSearch&quot;,&quot;width&quot;:&quot;640&quot;,&quot;height&quot;:&quot;480&quot;,&quot;imageId&quot;:&quot;ANd9GcQRrzUNljCTG8-I68KUD8-SI2uwG77AYHvCcA50IFu4cs9WDK2DV9zHgnc&quot;,&quot;tbWidth&quot;:&quot;137&quot;,&quot;tbHeight&quot;:&quot;103&quot;,&quot;unescapedUrl&quot;:&quot;http://assets.worldwildlife.org/photos/144/images/hero_small/Giant_Panda_Hero_image_(c)_Michel_Gunther_WWF_Canon.jpg?1345515244&quot;,&quot;url&quot;:&quot;http://assets.worldwildlife.org/photos/144/images/hero_small/Giant_Panda_Hero_image_(c)_Michel_Gunther_WWF_Canon.jpg%3F1345515244&quot;,&quot;visibleUrl&quot;:&quot;worldwildlife.org&quot;,&quot;title&quot;:&quot;Giant \u003cb\u003ePanda\u003c/b\u003e | Species | WWF&quot;,&quot;titleNoFormatting&quot;:&quot;Giant Panda | Species | WWF&quot;,&quot;originalContextUrl&quot;:&quot;http://worldwildlife.org/species/giant-panda&quot;,&quot;content&quot;:&quot;Giant \u003cb\u003ePanda\u003c/b\u003e&quot;,&quot;contentNoFormatting&quot;:&quot;Giant Panda&quot;,&quot;tbUrl&quot;:&quot;http://t0.gstatic.com/images?q\u003dtbn:ANd9GcQRrzUNljCTG8-I68KUD8-SI2uwG77AYHvCcA50IFu4cs9WDK2DV9zHgnc&quot;},{&quot;GsearchResultClass&quot;:&quot;GimageSearch&quot;,&quot;width&quot;:&quot;606&quot;,&quot;height&quot;:&quot;387&quot;,&quot;imageId&quot;:&quot;ANd9GcSE2zijRhPrLfVHuzROQrMbd3AXdutJwWiUyqysnDnUK07UjOlWdDJHOZHU&quot;,&quot;tbWidth&quot;:&quot;136&quot;,&quot;tbHeight&quot;:&quot;87&quot;,&quot;unescapedUrl&quot;:&quot;http://www.washingtonpost.com/rf/image_606w/WashingtonPost/Content/Blogs/in-the-loop/Images/2012-09-17T130533Z_01_TOR901_RTRIDSP_3_USA-PANDA-WASHINGTON-218.jpg&quot;,&quot;url&quot;:&quot;http://www.washingtonpost.com/rf/image_606w/WashingtonPost/Content/Blogs/in-the-loop/Images/2012-09-17T130533Z_01_TOR901_RTRIDSP_3_USA-PANDA-WASHINGTON-218.jpg&quot;,&quot;visibleUrl&quot;:&quot;articles.washingtonpost.com&quot;,&quot;title&quot;:&quot;National Zoo welcomes baby \u003cb\u003epanda\u003c/b\u003e - Washington Post&quot;,&quot;titleNoFormatting&quot;:&quot;National Zoo welcomes baby panda - Washington Post&quot;,&quot;originalContextUrl&quot;:&quot;http://articles.washingtonpost.com/2012-09-17/local/35498108_1_panda-cub-panda-reproduction-baby-panda&quot;,&quot;content&quot;:&quot;Zoo welcomes baby \u003cb\u003epanda\u003c/b\u003e&quot;,&quot;contentNoFormatting&quot;:&quot;Zoo welcomes baby panda&quot;,&quot;tbUrl&quot;:&quot;http://t1.gstatic.com/images?q\u003dtbn:ANd9GcSE2zijRhPrLfVHuzROQrMbd3AXdutJwWiUyqysnDnUK07UjOlWdDJHOZHU&quot;},{&quot;GsearchResultClass&quot;:&quot;GimageSearch&quot;,&quot;width&quot;:&quot;948&quot;,&quot;height&quot;:&quot;964&quot;,&quot;imageId&quot;:&quot;ANd9GcQnXahbarc0laLmKjf4Rz9JYwVdWPfsWlF1rb_ytZTIzcg2akZaoskVxcCT&quot;,&quot;tbWidth&quot;:&quot;146&quot;,&quot;tbHeight&quot;:&quot;148&quot;,&quot;unescapedUrl&quot;:&quot;http://media.npr.org/assets/img/2012/01/04/ap99121501386_custom-feedbb6efa738efee47e7828e805758dc427fa60-s6-c10.jpg&quot;,&quot;url&quot;:&quot;http://media.npr.org/assets/img/2012/01/04/ap99121501386_custom-feedbb6efa738efee47e7828e805758dc427fa60-s6-c10.jpg&quot;,&quot;visibleUrl&quot;:&quot;www.npr.org&quot;,&quot;title&quot;:&quot;What The \u003cb\u003ePanda\u003c/b\u003e Won\u0026#39;t Tell Us : Krulwich Wonders... : NPR&quot;,&quot;titleNoFormatting&quot;:&quot;What The Panda Won\u0026#39;t Tell Us : Krulwich Wonders... : NPR&quot;,&quot;originalContextUrl&quot;:&quot;http://www.npr.org/blogs/krulwich/2012/01/03/144633582/what-the-panda-won-t-tell-us&quot;,&quot;content&quot;:&quot;Every giant \u003cb\u003epanda\u003c/b\u003e, said&quot;,&quot;contentNoFormatting&quot;:&quot;Every giant panda, said&quot;,&quot;tbUrl&quot;:&quot;http://t1.gstatic.com/images?q\u003dtbn:ANd9GcQnXahbarc0laLmKjf4Rz9JYwVdWPfsWlF1rb_ytZTIzcg2akZaoskVxcCT&quot;},{&quot;GsearchResultClass&quot;:&quot;GimageSearch&quot;,&quot;width&quot;:&quot;948&quot;,&quot;height&quot;:&quot;711&quot;,&quot;imageId&quot;:&quot;ANd9GcT3wJ6FzzTa01idfln9jm2pNKC8YJFAJGsMim0KjGR9fztzbIdFhZcvPAA&quot;,&quot;tbWidth&quot;:&quot;148&quot;,&quot;tbHeight&quot;:&quot;111&quot;,&quot;unescapedUrl&quot;:&quot;http://media.npr.org/assets/news/2010/04/11/panda-f8a7c9331bbac776e52b26feeccc53de959f46d1-s6-c10.jpg&quot;,&quot;url&quot;:&quot;http://media.npr.org/assets/news/2010/04/11/panda-f8a7c9331bbac776e52b26feeccc53de959f46d1-s6-c10.jpg&quot;,&quot;visibleUrl&quot;:&quot;www.npr.org&quot;,&quot;title&quot;:&quot;Why The Animal Critic Gives The \u003cb\u003ePanda\u003c/b\u003e An F : NPR&quot;,&quot;titleNoFormatting&quot;:&quot;Why The Animal Critic Gives The Panda An F : NPR&quot;,&quot;originalContextUrl&quot;:&quot;http://www.npr.org/templates/story/story.php?storyId\u003d125773728&quot;,&quot;content&quot;:&quot;A \u003cb\u003epanda\u003c/b\u003e. iStockphoto.com&quot;,&quot;contentNoFormatting&quot;:&quot;A panda. iStockphoto.com&quot;,&quot;tbUrl&quot;:&quot;http://t3.gstatic.com/images?q\u003dtbn:ANd9GcT3wJ6FzzTa01idfln9jm2pNKC8YJFAJGsMim0KjGR9fztzbIdFhZcvPAA&quot;}],&quot;cursor&quot;:{&quot;resultCount&quot;:&quot;428,000,000&quot;,&quot;pages&quot;:[{&quot;start&quot;:&quot;0&quot;,&quot;label&quot;:1},{&quot;start&quot;:&quot;4&quot;,&quot;label&quot;:2},{&quot;start&quot;:&quot;8&quot;,&quot;label&quot;:3},{&quot;start&quot;:&quot;12&quot;,&quot;label&quot;:4},{&quot;start&quot;:&quot;16&quot;,&quot;label&quot;:5},{&quot;start&quot;:&quot;20&quot;,&quot;label&quot;:6},{&quot;start&quot;:&quot;24&quot;,&quot;label&quot;:7},{&quot;start&quot;:&quot;28&quot;,&quot;label&quot;:8}],&quot;estimatedResultCount&quot;:&quot;428000000&quot;,&quot;currentPageIndex&quot;:0,&quot;moreResultsUrl&quot;:&quot;http://www.google.com/images?oe\u003dutf8\u0026ie\u003dutf8\u0026source\u003duds\u0026start\u003d0\u0026hl\u003den\u0026q\u003dpanda&quot;,&quot;searchResultTime&quot;:&quot;0.24&quot;}}, &quot;responseDetails&quot;: null, &quot;responseStatus&quot;: 200}</code><hr />
</div> for Querying the term &quot;panda&quot;<br />
<br />
The Result itself might seem confusing at first, but by filtering it with the following regex a much more clear list of results can be displayed.<br />
<br />
 <font color="#c61818"><b>(\&quot;http\\S+?jpg\&quot;)</b></font> <br />
<br />
After applying this regex a list like the following can be extracted:<br />
<br />
&quot;http://t0.gstatic.com/images?q\u003dtbn:ANd9GcQRrzUNljCTG8-I68KUD8-SI2uwG77AYHvCcA50IFu4cs9WDK2DV9zHgnc&quot;},{&quot;GsearchResultClass&quot;:&quot;GimageSearch&quot;,&quot;width&quot;:&quot;606&quot;,&quot;height&quot;:&quot;387&quot;,&quot;imageId&quot;:&quot;ANd9GcSE2zijRhPrLfVHuzROQrMbd3AXdutJwWiUyqysnDnUK07UjOlWdDJHOZHU&quot;,&quot;tbWidth&quot;:&quot;136&quot;,&quot;tbHeight&quot;:&quot;87&quot;,&quot;unescapedUrl&quot;:&quot;http://www.washingtonpost.com/rf/image_606w/WashingtonPost/Content/Blogs/in-the-loop/Images/2012-09-17T130533Z_01_TOR901_RTRIDSP_3_USA-PANDA-WASHINGTON-218.jpg&quot;<br />
&quot;http://www.washingtonpost.com/rf/image_606w/WashingtonPost/Content/Blogs/in-the-loop/Images/2012-09-17T130533Z_01_TOR901_RTRIDSP_3_USA-PANDA-WASHINGTON-218.jpg&quot;<br />
&quot;http://t1.gstatic.com/images?q\u003dtbn:ANd9GcSE2zijRhPrLfVHuzROQrMbd3AXdutJwWiUyqysnDnUK07UjOlWdDJHOZHU&quot;},{&quot;GsearchResultClass&quot;:&quot;GimageSearch&quot;,&quot;width&quot;:&quot;948&quot;,&quot;height&quot;:&quot;964&quot;,&quot;imageId&quot;:&quot;ANd9GcQnXahbarc0laLmKjf4Rz9JYwVdWPfsWlF1rb_ytZTIzcg2akZaoskVxcCT&quot;,&quot;tbWidth&quot;:&quot;146&quot;,&quot;tbHeight&quot;:&quot;148&quot;,&quot;unescapedUrl&quot;:&quot;http://media.npr.org/assets/img/2012/01/04/ap99121501386_custom-feedbb6efa738efee47e7828e805758dc427fa60-s6-c10.jpg&quot;<br />
&quot;http://media.npr.org/assets/img/2012/01/04/ap99121501386_custom-feedbb6efa738efee47e7828e805758dc427fa60-s6-c10.jpg&quot;<br />
&quot;http://t1.gstatic.com/images?q\u003dtbn:ANd9GcQnXahbarc0laLmKjf4Rz9JYwVdWPfsWlF1rb_ytZTIzcg2akZaoskVxcCT&quot;},{&quot;GsearchResultClass&quot;:&quot;GimageSearch&quot;,&quot;width&quot;:&quot;948&quot;,&quot;height&quot;:&quot;711&quot;,&quot;imageId&quot;:&quot;ANd9GcT3wJ6FzzTa01idfln9jm2pNKC8YJFAJGsMim0KjGR9fztzbIdFhZcvPAA&quot;,&quot;tbWidth&quot;:&quot;148&quot;,&quot;tbHeight&quot;:&quot;111&quot;,&quot;unescapedUrl&quot;:&quot;http://media.npr.org/assets/news/2010/04/11/panda-f8a7c9331bbac776e52b26feeccc53de959f46d1-s6-c10.jpg&quot;<br />
&quot;http://media.npr.org/assets/news/2010/04/11/panda-f8a7c9331bbac776e52b26feeccc53de959f46d1-s6-c10.jpg&quot;<br />
<br />
As you can easily tell, not all URLs are valid, but there are 2 or 3 that could be used. <br />
What I am trying to do is extracting a list of &quot;potential valid URLs&quot; and then try to make labels with imageIcons extracted off the valid links.<br />
This is my code so far.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">import java.awt.BorderLayout;<br />
<br />
<br />
public class browser extends JFrame {<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; private JPanel contentPane;<br />
&nbsp; &nbsp; &nbsp; &nbsp; private JTextField textField;<br />
<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; /**<br />
&nbsp; &nbsp; &nbsp; &nbsp;  * Create the frame.<br />
&nbsp; &nbsp; &nbsp; &nbsp;  */<br />
&nbsp; &nbsp; &nbsp; &nbsp; public browser() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setBounds(100, 100, 450, 300);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setVisible(true);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; contentPane = new JPanel();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setContentPane(contentPane);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; contentPane.setLayout(null);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textField = new JTextField();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textField.setBounds(6, 11, 390, 28);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; contentPane.add(textField);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textField.setColumns(10);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mainFrame mOb = new mainFrame();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JButton search = new JButton(&quot;&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; search.setIcon(new ImageIcon(&quot;C:\\Users\\Mihai\\Desktop\\search-icon.png&quot;));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; search.setBounds(397, 11, 31, 28);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; contentPane.add(search);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JScrollPane scrollPane = new JScrollPane();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scrollPane.setBounds(6, 51, 422, 205);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; contentPane.add(scrollPane);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scrollPane.getViewport().setOpaque(false);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; final JPanel editorPane = new JPanel();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scrollPane.setViewportView(editorPane);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; editorPane.setOpaque(false);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; editorPane.setBackground(new Color(0,0,0,0));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JLabel background = new JLabel(&quot;&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; background.setBounds(0, 0, 434, 262);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; contentPane.add(background);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; background.setIcon(mOb.BG);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; final JEditorPane editorPane_1 = new JEditorPane();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; editorPane_1.setBounds(6, 35, 0, 0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; contentPane.add(editorPane_1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; editorPane.setLayout(new FlowLayout());<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //SEARCH LISTENER<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; search.addActionListener(new ActionListener() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void actionPerformed(ActionEvent e) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String query = textField.getText();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // VALID SEARCH<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(query!=&quot;&quot;){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String rawString=&quot;&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; URL rawURL = new URL(&quot;http://ajax.googleapis.com/ajax/services/search/images?v=1.0&amp;q=&quot;+query);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; editorPane_1.setPage(rawURL);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  rawString = editorPane_1.getText().replaceAll(&quot;\n&quot;, System.getProperty(&quot;line.separator&quot;));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; editorPane_1.setText(&quot;&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(rawString);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }catch(Exception ex){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ex.printStackTrace();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(&quot;FIRST BLOCK &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
//GET NUMBER OF LINKS<br />
&nbsp;Pattern pattern = Pattern.compile(&quot;(\&quot;http\\S+?jpg\&quot;)&quot;);<br />
Matcher matcher = pattern.matcher(rawString);<br />
int j = 0;<br />
while (matcher.find()) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; j++;<br />
&nbsp;  <br />
}<br />
<br />
String refString[] = new String[j]; <br />
<br />
<br />
//ASSIGN LINKS<br />
<br />
Pattern pattern2 = Pattern.compile(&quot;(\&quot;http\\S+?jpg\&quot;)&quot;);<br />
Matcher matcher2 = pattern.matcher(rawString);<br />
int k =0;<br />
while (matcher2.find()) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; refString[k]=matcher2.group().toString();<br />
&nbsp; &nbsp; &nbsp; &nbsp; System.out.println(refString[k]);<br />
&nbsp; &nbsp; <br />
}<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //INSERT PROPER REGEX<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(i = 0; i&lt;refString.length; i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JLabel label= new JLabel(&quot;SUP&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; label.setPreferredSize(new Dimension(200,100));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; URL url&nbsp; = new URL(refString[i].trim());<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ImageIcon icon = new ImageIcon(ImageIO.read(url));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  label.setIcon(icon);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }catch(Exception ex){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ex.printStackTrace();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(&quot;\n FINISHED BLOCK!!!! &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; editorPane.add(new JScrollPane(label));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</code><hr />
</div> </div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?5-Java-Programming">Java Programming</category>
			<dc:creator>cens</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?536981-Java-Image-Query-Problem</guid>
		</item>
		<item>
			<title>OpenAL error with Java Executable Jar File</title>
			<link>http://forums.codeguru.com/showthread.php?536909-OpenAL-error-with-Java-Executable-Jar-File&amp;goto=newpost</link>
			<pubDate>Fri, 10 May 2013 13:13:47 GMT</pubDate>
			<description>I am programming a game in Eclipse using OpenAL for sound, and when I play it within the IDE it runs smoothly.

As soon as I export it as an executable jar file and try to run it from the system, the game locks as soon as a sound is about to be played.

This is how I load the file in my Sound Class which uses OpenAL:


Code:
---------
WaveData waveFile = WaveData.create(Collisions.class.getResource(sentSound));
AL10.alBufferData(buffer.get(0), waveFile.format, waveFile.data, waveFile.samplerate);
waveFile.dispose();
---------
In my game class I have an instance of the sound class called snd, and when I play a sound I run the command:


Code:
---------
snd.execute(sound);
---------
The rest of the code that follows and precedes these statements is pretty much the exact code from the OpenAL tutorial on lwjgl (http://www.lwjgl.org/wiki/index.php?title=OpenAL_Tutorial_1_-_Single_Static_Source). And as I said, this works perfectly within Eclipse.

I am quite new with java and getting as far as I have with this has been a nightmare. Does anyone know what the problem could be here? Is there something I am forgetting to tell Eclipse when creating the .jar file? I have told it to package all external jars within the executable.</description>
			<content:encoded><![CDATA[<div>I am programming a game in Eclipse using OpenAL for sound, and when I play it within the IDE it runs smoothly.<br />
<br />
As soon as I export it as an executable jar file and try to run it from the system, the game locks as soon as a sound is about to be played.<br />
<br />
This is how I load the file in my Sound Class which uses OpenAL:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">WaveData waveFile = WaveData.create(Collisions.class.getResource(sentSound));<br />
AL10.alBufferData(buffer.get(0), waveFile.format, waveFile.data, waveFile.samplerate);<br />
waveFile.dispose();</code><hr />
</div> In my game class I have an instance of the sound class called snd, and when I play a sound I run the command:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">snd.execute(sound);</code><hr />
</div> The rest of the code that follows and precedes these statements is pretty much the exact code from the OpenAL tutorial on <a rel="nofollow" href="http://www.lwjgl.org/wiki/index.php?title=OpenAL_Tutorial_1_-_Single_Static_Source" target="_blank">lwjgl</a>. And as I said, this works perfectly within Eclipse.<br />
<br />
I am quite new with java and getting as far as I have with this has been a nightmare. Does anyone know what the problem could be here? Is there something I am forgetting to tell Eclipse when creating the .jar file? I have told it to package all external jars within the executable.</div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?5-Java-Programming">Java Programming</category>
			<dc:creator>haackeDc</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?536909-OpenAL-error-with-Java-Executable-Jar-File</guid>
		</item>
		<item>
			<title>a little help for a newbie</title>
			<link>http://forums.codeguru.com/showthread.php?536879-a-little-help-for-a-newbie&amp;goto=newpost</link>
			<pubDate>Thu, 09 May 2013 08:16:58 GMT</pubDate>
			<description>I am starting studying Java and it is my first programming language. Well I have a question: in a text component I can use the function getText() that returns a String(but we are talking of a text document).
Should I split it in a string for each line or I am able to use it directly?</description>
			<content:encoded><![CDATA[<div>I am starting studying Java and it is my first programming language. Well I have a question: in a text component I can use the function getText() that returns a String(but we are talking of a text document).<br />
Should I split it in a string for each line or I am able to use it directly?</div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?5-Java-Programming">Java Programming</category>
			<dc:creator>Andreareptile</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?536879-a-little-help-for-a-newbie</guid>
		</item>
		<item>
			<title>start, stop timer in jpanel, please help</title>
			<link>http://forums.codeguru.com/showthread.php?536751-start-stop-timer-in-jpanel-please-help&amp;goto=newpost</link>
			<pubDate>Sun, 05 May 2013 00:59:42 GMT</pubDate>
			<description><![CDATA[I tried to add a timer with a start stop when mouse is clicked, but it is not working at all. Could someone please help me.  it is the If statements for the timer. any help is much appreciate. thank you


Code:
---------
//**********************************************************************
//  ReboundPanel.java               Java Foundations
//
//  Represents the primary panel for the rebound program.
//**********************************************************************

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

//import PP6_10Panel.Handlerclass;

public class ReboundPanel extends JPanel
{
	private final int WIDTH = 300, HEIGHT = 100;
	private final int DELAY = 20, IMAGE_SIZE = 35;
	
	private ImageIcon image;
	private Timer timer;
	private int x, y, moveX, moveY;
	boolean b;
	
	//-------------------------------------------------------------------
	//  Sets up the panel, including the timer for the animation
	//-------------------------------------------------------------------
	
	public ReboundPanel()
	{
		timer = new Timer(DELAY, new ReboundListener(){
			 @Override
			    public void actionPerformed(ActionEvent ae) {
			        // change polygon data
			        // ...

			        repaint();
			    }
		});
		
		image = new ImageIcon ("C:/Users/dstevens/Desktop/happyFace.gif");//.getImage();
		
		
		x = 0;
		y = 40;
		moveX = moveY = 3;
		
		
		setPreferredSize (new Dimension(WIDTH, HEIGHT));
		setBackground (Color.black);
		timer.start();
		
		//Handlerclass handler = new Handlerclass();
	}
	
	
	//--------------------------------------------------------------------
	//  Draw the image in the current location
	//--------------------------------------------------------------------
	
	 @Override
	public void paintComponent(Graphics page)
	{
		super.paintComponent(page);
		image.paintIcon(this,  page, x, y);
	}
	
	//*********************************************************************
	//  Represents the action Listener for the timer
	//*********************************************************************
	
	private class ReboundListener implements ActionListener
	{
		//******************************************************************
		//Updates the position of the image and the possibly the direction
		//of the movement whenever the timer fires an action event.
		//******************************************************************
		public void actionPerformed (ActionEvent event)
		{
			x += moveX;
			y += moveY;
			
			
		if (b) {
			 //timer.start();
					if (x <= 0 || x >= WIDTH-IMAGE_SIZE)
				moveX = moveX * -1;
			
			if (y <= 0 || y >= HEIGHT-IMAGE_SIZE)
				moveY = moveY * -1;
			repaint();
		} else {
			   timer.stop();
						}
						b = !b;
		}
		}
	}
---------
]]></description>
			<content:encoded><![CDATA[<div>I tried to add a timer with a start stop when mouse is clicked, but it is not working at all. Could someone please help me.  it is the If statements for the timer. any help is much appreciate. thank you<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">//**********************************************************************<br />
//&nbsp; ReboundPanel.java&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Java Foundations<br />
//<br />
//&nbsp; Represents the primary panel for the rebound program.<br />
//**********************************************************************<br />
<br />
import java.awt.*;<br />
import java.awt.event.*;<br />
<br />
import javax.swing.*;<br />
<br />
//import PP6_10Panel.Handlerclass;<br />
<br />
public class ReboundPanel extends JPanel<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; private final int WIDTH = 300, HEIGHT = 100;<br />
&nbsp; &nbsp; &nbsp; &nbsp; private final int DELAY = 20, IMAGE_SIZE = 35;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; private ImageIcon image;<br />
&nbsp; &nbsp; &nbsp; &nbsp; private Timer timer;<br />
&nbsp; &nbsp; &nbsp; &nbsp; private int x, y, moveX, moveY;<br />
&nbsp; &nbsp; &nbsp; &nbsp; boolean b;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //-------------------------------------------------------------------<br />
&nbsp; &nbsp; &nbsp; &nbsp; //&nbsp; Sets up the panel, including the timer for the animation<br />
&nbsp; &nbsp; &nbsp; &nbsp; //-------------------------------------------------------------------<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; public ReboundPanel()<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; timer = new Timer(DELAY, new ReboundListener(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  @Override<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void actionPerformed(ActionEvent ae) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // change polygon data<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // ...<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; repaint();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; image = new ImageIcon (&quot;C:/Users/dstevens/Desktop/happyFace.gif&quot;);//.getImage();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y = 40;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; moveX = moveY = 3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setPreferredSize (new Dimension(WIDTH, HEIGHT));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setBackground (Color.black);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; timer.start();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Handlerclass handler = new Handlerclass();<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //--------------------------------------------------------------------<br />
&nbsp; &nbsp; &nbsp; &nbsp; //&nbsp; Draw the image in the current location<br />
&nbsp; &nbsp; &nbsp; &nbsp; //--------------------------------------------------------------------<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  @Override<br />
&nbsp; &nbsp; &nbsp; &nbsp; public void paintComponent(Graphics page)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; super.paintComponent(page);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; image.paintIcon(this,&nbsp; page, x, y);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //*********************************************************************<br />
&nbsp; &nbsp; &nbsp; &nbsp; //&nbsp; Represents the action Listener for the timer<br />
&nbsp; &nbsp; &nbsp; &nbsp; //*********************************************************************<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; private class ReboundListener implements ActionListener<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //******************************************************************<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Updates the position of the image and the possibly the direction<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //of the movement whenever the timer fires an action event.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //******************************************************************<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void actionPerformed (ActionEvent event)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x += moveX;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y += moveY;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (b) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  //timer.start();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (x &lt;= 0 || x &gt;= WIDTH-IMAGE_SIZE)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; moveX = moveX * -1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (y &lt;= 0 || y &gt;= HEIGHT-IMAGE_SIZE)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; moveY = moveY * -1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; repaint();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  timer.stop();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b = !b;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }</code><hr />
</div> </div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?5-Java-Programming">Java Programming</category>
			<dc:creator>dstevens</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?536751-start-stop-timer-in-jpanel-please-help</guid>
		</item>
		<item>
			<title>Animation in GUI</title>
			<link>http://forums.codeguru.com/showthread.php?536713-Animation-in-GUI&amp;goto=newpost</link>
			<pubDate>Fri, 03 May 2013 00:49:38 GMT</pubDate>
			<description><![CDATA[Please Help! Cant figure this out.
I am trying to rewrite a program given to me from my professor. I have a few days to figure this out. Time is running out. A program out of our books called REBOUND.java and our objective is to have the happyface to start and stop onclick. I rewrote the program and is as follows...

Code:
---------
//**********************************************************************
//  ReboundPanel.java               Java Foundations
//
//  Represents the primary panel for the rebound program.
//**********************************************************************

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ReboundPanel extends JPanel
{
	private final int WIDTH = 300, HEIGHT = 100;
	private final int DELAY = 20, IMAGE_SIZE = 35;
	
	private ImageIcon image;
	private Timer timer;
	private int x, y, moveX, moveY;
	
	//-------------------------------------------------------------------
	//  Sets up the panel, including the timer for the animation
	//-------------------------------------------------------------------
	
	public ReboundPanel()
	{
		timer = new Timer(DELAY, new ReboundListener());
		
		image = new ImageIcon ("happyface.gif");
		
		x = 0;
		y = 40;
		moveX = moveY = 3;
		
		setPreferredSize (new Dimension(WIDTH, HEIGHT));
		setBackground (Color.black);
		timer.start();
	}
	
	//--------------------------------------------------------------------
	//  Draw the image in the current location
	//--------------------------------------------------------------------
	
	public void paintComponent(Graphics page)
	{
		super.paintComponent(page);
		image.paintIcon(this,  page, x, y);
	}
	
	//*********************************************************************
	//  Represents the action Listener for the timer
	//*********************************************************************
	
	private class ReboundListener implements ActionListener
	{
		//******************************************************************
		//Updates the position of the image and the possibly the direction
		//of the movement whenever the timer fires an action event.
		//******************************************************************
		public void actionPerformed (ActionEvent event)
		{
			x += moveX;
			y += moveY;
			
			if (x <= 0 || x >= WIDTH-IMAGE_SIZE)
				moveX = moveX * -1;
			
			if (y <= 0 || y >= HEIGHT-IMAGE_SIZE)
				moveY = moveY * -1;
			repaint();
		}
	}
}
---------

I cant seem to see the happyface it is suppose to have in the GUI. can some one please help me get this figured out.
Thanks in advance]]></description>
			<content:encoded><![CDATA[<div>Please Help! Cant figure this out.<br />
I am trying to rewrite a program given to me from my professor. I have a few days to figure this out. Time is running out. A program out of our books called REBOUND.java and our objective is to have the happyface to start and stop onclick. I rewrote the program and is as follows...<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">//**********************************************************************<br />
//&nbsp; ReboundPanel.java&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Java Foundations<br />
//<br />
//&nbsp; Represents the primary panel for the rebound program.<br />
//**********************************************************************<br />
<br />
import java.awt.*;<br />
import java.awt.event.*;<br />
import javax.swing.*;<br />
<br />
public class ReboundPanel extends JPanel<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; private final int WIDTH = 300, HEIGHT = 100;<br />
&nbsp; &nbsp; &nbsp; &nbsp; private final int DELAY = 20, IMAGE_SIZE = 35;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; private ImageIcon image;<br />
&nbsp; &nbsp; &nbsp; &nbsp; private Timer timer;<br />
&nbsp; &nbsp; &nbsp; &nbsp; private int x, y, moveX, moveY;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //-------------------------------------------------------------------<br />
&nbsp; &nbsp; &nbsp; &nbsp; //&nbsp; Sets up the panel, including the timer for the animation<br />
&nbsp; &nbsp; &nbsp; &nbsp; //-------------------------------------------------------------------<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; public ReboundPanel()<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; timer = new Timer(DELAY, new ReboundListener());<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; image = new ImageIcon (&quot;happyface.gif&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y = 40;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; moveX = moveY = 3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setPreferredSize (new Dimension(WIDTH, HEIGHT));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setBackground (Color.black);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; timer.start();<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //--------------------------------------------------------------------<br />
&nbsp; &nbsp; &nbsp; &nbsp; //&nbsp; Draw the image in the current location<br />
&nbsp; &nbsp; &nbsp; &nbsp; //--------------------------------------------------------------------<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; public void paintComponent(Graphics page)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; super.paintComponent(page);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; image.paintIcon(this,&nbsp; page, x, y);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //*********************************************************************<br />
&nbsp; &nbsp; &nbsp; &nbsp; //&nbsp; Represents the action Listener for the timer<br />
&nbsp; &nbsp; &nbsp; &nbsp; //*********************************************************************<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; private class ReboundListener implements ActionListener<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //******************************************************************<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Updates the position of the image and the possibly the direction<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //of the movement whenever the timer fires an action event.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //******************************************************************<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void actionPerformed (ActionEvent event)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x += moveX;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y += moveY;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (x &lt;= 0 || x &gt;= WIDTH-IMAGE_SIZE)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; moveX = moveX * -1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (y &lt;= 0 || y &gt;= HEIGHT-IMAGE_SIZE)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; moveY = moveY * -1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; repaint();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</code><hr />
</div> <br />
I cant seem to see the happyface it is suppose to have in the GUI. can some one please help me get this figured out.<br />
Thanks in advance</div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?5-Java-Programming">Java Programming</category>
			<dc:creator>dstevens</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?536713-Animation-in-GUI</guid>
		</item>
		<item>
			<title>populating authorizations using cookie</title>
			<link>http://forums.codeguru.com/showthread.php?536661-populating-authorizations-using-cookie&amp;goto=newpost</link>
			<pubDate>Tue, 30 Apr 2013 21:20:19 GMT</pubDate>
			<description><![CDATA[package com.comdata.fis.presentation.actions; 

import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 
import javax.servlet.http.HttpSession; 

import org.apache.log4j.Logger; 
import org.apache.struts.action.ActionForm; 
import org.apache.struts.action.ActionForward; 
import org.apache.struts.action.ActionMapping; 

import com.comdata.core.fis.constants.AppConfigKeys; 
import com.comdata.core.fis.constants.AppContextKeys; 
import com.comdata.core.fis.util.systemhelpers.SecurityHelper; 
import com.comdata.fis.web.WebUtils; 
import com.svs.core.constants.SystemConstants; 
import com.svs.security.helper.ApplicationSecurityHelper; 
import com.svs.security.model.PortalSecurityPrincipal; 

public class InitAction extends BaseAction { 

private static Logger log = Logger.getLogger(InitAction.class); 

public ActionForward appExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) 
{	
log.info("This is the initial action - Portal will send you here with a Portal Cookie..."); 

try { 
HttpSession session = request.getSession(false) 
if (ApplicationSecurityHelper.getInstance().checkValidUser(request, SystemConstants.getApplicationCode(AppConfigKeys.APPLICATION_ABREV))) 
{ 

log.info("User validated successfully!"); 
PortalSecurityPrincipal principal = WebUtils.getSecurityPrincipal(request); 
SecurityHelper iSec = new SecurityHelper(); 
if (principal.getTmFatypes().contains(AppContextKeys.ADDCLIENT_FATYPE)) 
iSec.setAddClient(true); 

if (principal.getTmFatypes().contains(AppContextKeys.EDITCLIENT_FATYPE)) { 
iSec.setEditClient(true); 

} 

if (principal.getTmFatypes().contains(AppContextKeys.VIEWCONFIG_FATYPE)) 
iSec.setViewClient(true); 
if (principal.getTmFatypes().contains(AppContextKeys.VIEWAUDIT_FATYPE)) 
iSec.setViewAudit(true); 
if (principal.getTmFatypes().contains(AppContextKeys.VIEWINVOICE_FATYPE)) 
iSec.setViewInvoice(true); 
if (principal.getTmFatypes().contains(AppContextKeys.PAYMENTREVERSAL_FATYPE)) 
iSec.setPaymentReversal(true); 
if (principal.getTmFatypes().contains(AppContextKeys.TEMPCREDITEDIT_FATYPE)) 
iSec.setTempCreditEdit(true); 

WebUtils.setSecurityRights(request, iSec); 
return mapping.findForward(AppContextKeys.ACTION_CLIENT_LIST);	
}	

} catch (Exception e) {	
log.error(e.getStackTrace()); 
log.error("Something unexpected happened : " + e.toString()); 
} 

log.info("You failed validation...go back to default page...."); 
return mapping.findForward(AppContextKeys.PAGE_NOTAUTH);	
}	

}]]></description>
			<content:encoded><![CDATA[<div>package com.comdata.fis.presentation.actions; <br />
<br />
import javax.servlet.http.HttpServletRequest; <br />
import javax.servlet.http.HttpServletResponse; <br />
import javax.servlet.http.HttpSession; <br />
<br />
import org.apache.log4j.Logger; <br />
import org.apache.struts.action.ActionForm; <br />
import org.apache.struts.action.ActionForward; <br />
import org.apache.struts.action.ActionMapping; <br />
<br />
import com.comdata.core.fis.constants.AppConfigKeys; <br />
import com.comdata.core.fis.constants.AppContextKeys; <br />
import com.comdata.core.fis.util.systemhelpers.SecurityHelper; <br />
import com.comdata.fis.web.WebUtils; <br />
import com.svs.core.constants.SystemConstants; <br />
import com.svs.security.helper.ApplicationSecurityHelper; <br />
import com.svs.security.model.PortalSecurityPrincipal; <br />
<br />
public class InitAction extends BaseAction { <br />
<br />
private static Logger log = Logger.getLogger(InitAction.class); <br />
<br />
public ActionForward appExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) <br />
{	<br />
log.info(&quot;This is the initial action - Portal will send you here with a Portal Cookie...&quot;); <br />
<br />
try { <br />
HttpSession session = request.getSession(false) <br />
if (ApplicationSecurityHelper.getInstance().checkValidUser(request, SystemConstants.getApplicationCode(AppConfigKeys.APPLICATION_ABREV))) <br />
{ <br />
<br />
log.info(&quot;User validated successfully!&quot;); <br />
PortalSecurityPrincipal principal = WebUtils.getSecurityPrincipal(request); <br />
SecurityHelper iSec = new SecurityHelper(); <br />
if (principal.getTmFatypes().contains(AppContextKeys.ADDCLIENT_FATYPE)) <br />
iSec.setAddClient(true); <br />
<br />
if (principal.getTmFatypes().contains(AppContextKeys.EDITCLIENT_FATYPE)) { <br />
iSec.setEditClient(true); <br />
<br />
} <br />
<br />
if (principal.getTmFatypes().contains(AppContextKeys.VIEWCONFIG_FATYPE)) <br />
iSec.setViewClient(true); <br />
if (principal.getTmFatypes().contains(AppContextKeys.VIEWAUDIT_FATYPE)) <br />
iSec.setViewAudit(true); <br />
if (principal.getTmFatypes().contains(AppContextKeys.VIEWINVOICE_FATYPE)) <br />
iSec.setViewInvoice(true); <br />
if (principal.getTmFatypes().contains(AppContextKeys.PAYMENTREVERSAL_FATYPE)) <br />
iSec.setPaymentReversal(true); <br />
if (principal.getTmFatypes().contains(AppContextKeys.TEMPCREDITEDIT_FATYPE)) <br />
iSec.setTempCreditEdit(true); <br />
<br />
WebUtils.setSecurityRights(request, iSec); <br />
return mapping.findForward(AppContextKeys.ACTION_CLIENT_LIST);	<br />
}	<br />
<br />
} catch (Exception e) {	<br />
log.error(e.getStackTrace()); <br />
log.error(&quot;Something unexpected happened : &quot; + e.toString()); <br />
} <br />
<br />
log.info(&quot;You failed validation...go back to default page....&quot;); <br />
return mapping.findForward(AppContextKeys.PAGE_NOTAUTH);	<br />
}	<br />
<br />
}</div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?5-Java-Programming">Java Programming</category>
			<dc:creator>nikhil411</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?536661-populating-authorizations-using-cookie</guid>
		</item>
		<item>
			<title>java code</title>
			<link>http://forums.codeguru.com/showthread.php?536641-java-code&amp;goto=newpost</link>
			<pubDate>Tue, 30 Apr 2013 16:31:46 GMT</pubDate>
			<description>how do i code using java for android development?</description>
			<content:encoded><![CDATA[<div>how do i code using java for android development?</div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?5-Java-Programming">Java Programming</category>
			<dc:creator>j_smith882</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?536641-java-code</guid>
		</item>
		<item>
			<title>java code</title>
			<link>http://forums.codeguru.com/showthread.php?536639-java-code&amp;goto=newpost</link>
			<pubDate>Tue, 30 Apr 2013 16:28:29 GMT</pubDate>
			<description>hi, im new to the java world and looking to start android development.But i need to know how to code, using java any one has suggestions on what to know or  learn?</description>
			<content:encoded><![CDATA[<div>hi, im new to the java world and looking to start android development.But i need to know how to code, using java any one has suggestions on what to know or  learn?</div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?5-Java-Programming">Java Programming</category>
			<dc:creator>j_smith882</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?536639-java-code</guid>
		</item>
		<item>
			<title>AM new to Programming, I need help with my Program</title>
			<link>http://forums.codeguru.com/showthread.php?536615-AM-new-to-Programming-I-need-help-with-my-Program&amp;goto=newpost</link>
			<pubDate>Mon, 29 Apr 2013 19:29:16 GMT</pubDate>
			<description><![CDATA[Hello, 

 I'm in a beginning class for java programming and I can't seem to understand how to use the array and for loop together. I keep getting this message when I compile my program.

 Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
 at GradeList.main(GradeList.java:40).


Here is my Program,


import java.util.*;
public class GradeList2
{ 
	// This Program accumulates and create grades and class average
        public static void main(String[] args)
        {	 // Tell the user this program calculates grades for a class
      		 System.out.println("This program calculates grades for a class of students");
          	 
		 // input scanner
      	  	 Scanner input = new Scanner(System.in);

			// declare variables
          		int numStudents; 
     	  		int totalpts; 
      			int studentpts;
      			int k;
     		 	double percent;
      			char grade;
      	
 
      	         // ask and get users input number of students and total possible points
     	  	 System.out.print("Please Enter the Number of students: ");
     		 numStudents = input.nextInt();
     		 System.out.print("Please enter the Total Possible Points: ");
     		 totalpts = input.nextInt();
 
      		// tell user to enter each students points
     		System.out.println("Please Enter Each Students Points");
      		
 
      		// declare array
      		int [] studentList = new int [numStudents];
 
      			// input for loop
     			 for (k=1; k <= numStudents; k++)
     				 {
         				 System.out.print("Points for Student " +k+ " ");
          			         	studentList[k] = input.nextInt();
 
      					// If Points is greater that Total_Points, tell the user Invalid Student Points
					while (studentList[k] > totalpts || studentList[k] < 0)
			  	 	{ System.out.println("Sorry that is over the total possible point, try again");
					// Get students total points again
          				System.out.print("Points for student " +k+ " ");
         					 studentList[k] = input.nextInt();
     					}
					
				
      				}

			 System.out.println(" ");

			 
 
      			// print formatted output for headings
      			String formathd= "CLASS OF " +numStudents+ " STUDENTS              POINTS     PERCENT     GRADE  ";
 
      			// format lines
      			String formatDashes= "                                 ------     -------     -----  ";
 
      			// show variables and lines
      			System.out.println(formathd);
			// Print Dashes
      			System.out.println(formatDashes);
 
          		// calculate percent and grade for each student points and store into percent array
      			for (k=1; k < numStudents; k++)
      			{
         			// Get Student Points
		    		System.out.print("Student"[k]);

			       	percent = ((studentList[k])/(totalpts)) *100;
      				
			 		 if (percent >= 90.00){
      						grade = 'A';
       						 }
     					 else if (percent >= 80.00)
        				{
          					grade = 'B';
        				}
      					 else if (percent >= 70.00)
        				{
          					grade = 'C';
        				}
     					 else if (percent >= 60.00)
            				{
          					grade = 'D';
       					 }
      					 else
       					 {
        					grade= 'F';
       					 }
      				String format= "%25s      %11d     %11.2f     %9c";
      				System.out.printf(format, studentList[k], percent, grade);
     			       }// End of for loop
						
					 
   
        } // end of main method
} // end of class]]></description>
			<content:encoded><![CDATA[<div>Hello, <br />
<br />
 I'm in a beginning class for java programming and I can't seem to understand how to use the array and for loop together. I keep getting this message when I compile my program.<br />
<br />
 Exception in thread &quot;main&quot; java.lang.ArrayIndexOutOfBoundsException: 5<br />
 at GradeList.main(GradeList.java:40).<br />
<br />
<br />
Here is my Program,<br />
<br />
<br />
import java.util.*;<br />
public class GradeList2<br />
{ <br />
	// This Program accumulates and create grades and class average<br />
        public static void main(String[] args)<br />
        {	 // Tell the user this program calculates grades for a class<br />
      		 System.out.println(&quot;This program calculates grades for a class of students&quot;);<br />
          	 <br />
		 // input scanner<br />
      	  	 Scanner input = new Scanner(System.in);<br />
<br />
			// declare variables<br />
          		int numStudents; <br />
     	  		int totalpts; <br />
      			int studentpts;<br />
      			int k;<br />
     		 	double percent;<br />
      			char grade;<br />
      	<br />
 <br />
      	         // ask and get users input number of students and total possible points<br />
     	  	 System.out.print(&quot;Please Enter the Number of students: &quot;);<br />
     		 numStudents = input.nextInt();<br />
     		 System.out.print(&quot;Please enter the Total Possible Points: &quot;);<br />
     		 totalpts = input.nextInt();<br />
 <br />
      		// tell user to enter each students points<br />
     		System.out.println(&quot;Please Enter Each Students Points&quot;);<br />
      		<br />
 <br />
      		// declare array<br />
      		int [] studentList = new int [numStudents];<br />
 <br />
      			// input for loop<br />
     			 for (k=1; k &lt;= numStudents; k++)<br />
     				 {<br />
         				 System.out.print(&quot;Points for Student &quot; +k+ &quot; &quot;);<br />
          			         	studentList[k] = input.nextInt();<br />
 <br />
      					// If Points is greater that Total_Points, tell the user Invalid Student Points<br />
					while (studentList[k] &gt; totalpts || studentList[k] &lt; 0)<br />
			  	 	{ System.out.println(&quot;Sorry that is over the total possible point, try again&quot;);<br />
					// Get students total points again<br />
          				System.out.print(&quot;Points for student &quot; +k+ &quot; &quot;);<br />
         					 studentList[k] = input.nextInt();<br />
     					}<br />
					<br />
				<br />
      				}<br />
<br />
			 System.out.println(&quot; &quot;);<br />
<br />
			 <br />
 <br />
      			// print formatted output for headings<br />
      			String formathd= &quot;CLASS OF &quot; +numStudents+ &quot; STUDENTS              POINTS     PERCENT     GRADE  &quot;;<br />
 <br />
      			// format lines<br />
      			String formatDashes= &quot;                                 ------     -------     -----  &quot;;<br />
 <br />
      			// show variables and lines<br />
      			System.out.println(formathd);<br />
			// Print Dashes<br />
      			System.out.println(formatDashes);<br />
 <br />
          		// calculate percent and grade for each student points and store into percent array<br />
      			for (k=1; k &lt; numStudents; k++)<br />
      			{<br />
         			// Get Student Points<br />
		    		System.out.print(&quot;Student&quot;[k]);<br />
<br />
			       	percent = ((studentList[k])/(totalpts)) *100;<br />
      				<br />
			 		 if (percent &gt;= 90.00){<br />
      						grade = 'A';<br />
       						 }<br />
     					 else if (percent &gt;= 80.00)<br />
        				{<br />
          					grade = 'B';<br />
        				}<br />
      					 else if (percent &gt;= 70.00)<br />
        				{<br />
          					grade = 'C';<br />
        				}<br />
     					 else if (percent &gt;= 60.00)<br />
            				{<br />
          					grade = 'D';<br />
       					 }<br />
      					 else<br />
       					 {<br />
        					grade= 'F';<br />
       					 }<br />
      				String format= &quot;%25s      %11d     %11.2f     %9c&quot;;<br />
      				System.out.printf(format, studentList[k], percent, grade);<br />
     			       }// End of for loop<br />
						<br />
					 <br />
   <br />
        } // end of main method<br />
} // end of class</div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?5-Java-Programming">Java Programming</category>
			<dc:creator>Ominitobi</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?536615-AM-new-to-Programming-I-need-help-with-my-Program</guid>
		</item>
	</channel>
</rss>
