Solved

Japplet jbutton icon

Posted on 2006-07-05
5
205 Views
Last Modified: 2010-03-31
On the following line:

Image = new URL(getDocumentBase(),String.valueOf(i+1)+ ".jpg");

Why does it throw a 'MalformedURLException'?  Is there a way to set the
image on a jbutton using a japplet without a try,catch block?
0
Comment
Question by:List244
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 17048120
The URL constructor will throw that exception if you provide an invalid url

try:

Image = getClass().getResource("/"+String.valueOf(i+1)+ ".jpg");
0
 
LVL 8

Author Comment

by:List244
ID: 17048137
That works, so is java incapable of throwing an exception without catching it?
0
 
LVL 92

Expert Comment

by:objects
ID: 17048178
correct, if a method declares that it throws a (checked) exception the calling method must catch it or declare that it may throw it.(RuntimeExceptions are nopt checked)
0
 
LVL 8

Author Comment

by:List244
ID: 17048186
Haha wow, that will take some getting used to, thanks again Objects.
0
 
LVL 8

Author Comment

by:List244
ID: 17048190
Have to say though, I am missing C++ right now...
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
servlet example 11 76
Tomcat: Unable to run tomcat service. 2 34
ejb entity bean example 2 57
batch vs regular insert in spring DAO 2 51
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question