Solved

Japplet jbutton icon

Posted on 2006-07-05
5
208 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses

623 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