nxt's place

Tag: resource

JNA: Java Native Access

by on Dec.09, 2007, under Java

If you use JNI to access native code you'll quickly find yourself writing some glue in c/c++ to access the native library. With JNA you can write nice clean code in Java without the need to glue your java code to the native library. This is all done by JNA.

All you need to do is define an interface that  (extends the Library interface and) exposes the methods in the library that you want to access:
import com.sun.jna.*;
// kernel32.dll uses the __stdcall calling convention
// Most C libraries will just extend com.sun.jna.Library
public interface Kernel32 extends StdCallLibrary {
// Method declarations, constant and structure definitions go here
}

Next you load the library using the following code:
Kernel32 kernel32Instance = (Kernel32)
    Native.loadLibrary("kernel32", Kernel32.class);

That's all there is to it, you can now access all methods you defined in the interface.
 Checkout the project page

Comments Off on JNA: Java Native Access :, , , more...

Fuse 0.1

by on Feb.10, 2006, under Java

Fuse 0.1 has been released

A brief overview of the features in this release:
* Multiple ResourceInjector instance support
* TypeLoader property support
* Global resource syntax
* SWT support
* Fully modular architecture (/Core, /Swing, and /SWT)
* Documentation (both javadoc and TypeLoader specific)
* A brand new build system and instructions on how to use it

Comments Off on Fuse 0.1 :, , more...

Fuse, UI Oriented Resource Injection

by on Feb.04, 2006, under Java

With Fuse you can easily inject data in your application at runtime by specifying them in a properties file,
for example using an background image
you used to do something like this:
class CustomComponent extends JComponent {
 private Image background;
 CustomComponent() {
  try {
   background = ImageIO.read(getClass()
    .getResource("/resources/background.png"));
  } catch (IOException e) { }
 }
}

With fuse the code would look like this
class CustomComponent extends JComponent {
 @InjectedResource
 private Image background;
 CustomComponent() {
  ResourceInjector.get().inject(this);
 }
}

Ofcourse you must load a properties file before calling inject using:
ResourceInjector rInjector=
 ResourceInjector.get().load("/resources/fuse.theme");

For more information about Fuse see this entry in the Romain Guy's blog. or take a look at the project page
 

Comments Off on Fuse, UI Oriented Resource Injection :, , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...