Monday, July 23, 2007

Demo sources

All source for demos in previous blog entries is now available via SVN on SourceForge. The project page is here.

All sources are provided under the LGPL.

3 comments:

Anonymous said...

Great work! This can be used as a significant leap for designing Java GUIs. I really didn't get a chance but I will get down and dirty with the source sometime soon.
Do you experience a black flickering when dragging the shaped window?
Anyway, good job, thank you!

technomage said...

Any transparent/shaped window comments should be directed to the JNA user's list (users at jna dot dev dot java dot net). Be sure to indicate your platform (os and machine) specifics, since the implementations differ.

Unknown said...

If you like the ability to scroll during dnd here is a simple navigator that does that.



import java.awt.Component;
import java.awt.Point;

import javax.swing.BoundedRangeModel;
import javax.swing.JScrollBar;

import furbelow.DropTargetNavigator;
import furbelow.DropTargetNavigator.AbstractNavigator;

public class JScrollBarNavigator extends AbstractNavigator {
public static void install() {
DropTargetNavigator.register(JScrollBar.class,
new JScrollBarNavigator());
}

public Runnable navigate(Component c, Point where, Runnable previousUndo) {
JScrollBar scrollbar = (JScrollBar) c;
BoundedRangeModel model = scrollbar.getModel();

double quotient = scrollbar.getOrientation() == JScrollBar.VERTICAL ? where
.getY()
/ (double) c.getHeight()
: where.getX() / (double) c.getWidth();

double newValue = (model.getMaximum() - model.getMinimum()) * quotient
+ model.getMinimum();
model.setValue((int) (newValue));

return previousUndo;
}
}