Solved

Japplet jbutton icon

Posted on 2006-07-05
5
192 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
  • 3
  • 2
5 Comments
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
Comment Utility
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
Comment Utility
That works, so is java incapable of throwing an exception without catching it?
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
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
Comment Utility
Haha wow, that will take some getting used to, thanks again Objects.
0
 
LVL 8

Author Comment

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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now