Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision |
student:java:resources [2022/11/18 14:52] – bernstdh | student:java:resources [2024/05/05 19:42] (current) – bernstdh |
---|
==== Icons ==== | ==== Icons ==== |
| |
To easiest way to refer to icons in a protable fashion is to use a ''%%URL%%'' object (from the ''%%java.net%%'' package), and the easiest way to get the appropriate ''%%URL%%'' object is to use a ''%%Class%%'' object. For example, if you want to get the ''%%URL%%'' for a resource named ''%%logo.png%%'' that is in the ''%%icons%%'' directory **under the top-level directory containing the class of the object referred to by ''%%this%%''** then you would do the following: | To easiest way to refer to icons in a portable fashion is to use a ''%%URL%%'' object (from the ''%%java.net%%'' package), and the easiest way to get the appropriate ''%%URL%%'' object is to use a ''%%Class%%'' object. For example, if you want to get the ''%%URL%%'' for a resource named ''%%logo.png%%'' that is in the ''%%icons%%'' directory **under the top-level directory containing the class of the object referred to by ''%%this%%''** then you would do the following: |
| |
<code java> | <code java> |
| |
<code java> | <code java> |
InputStream is = this.getClass().getResource("/configurations/config.txt"). | InputStream is = this.getClass().getResourceAsStream("/configurations/config.txt"). |
</code> | </code> |
| |