ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
URL imageURL = classLoader.getResource(imageName);
// If the image has not been added to the resource cache yet,
// add it
Image image = (Image)ApplicationContext.getResourceCache().get(imageURL);
if (image == null) {
image = Image.load(imageURL);
ApplicationContext.getResourceCache().put(imageURL, image);
}
// Update the image
menuImageView.setImage(image);
}
};
ListView iconListView = (ListView)wtkxSerializer.getObjectByName("lists.iconListView");
iconListView.setItemDisabled(3, true);
iconListView.setItemDisabled(4, true);
ListView checkedListView = (ListView)wtkxSerializer.getObjectByName("lists.checkedListView");
checkedListView.setItemChecked(0, true);
checkedListView.setItemChecked(2, true);
checkedListView.setItemChecked(3, true);
menuImageView = (ImageView)wtkxSerializer.getObjectByName("menus.imageView");
menuImageView.getComponentMouseButtonListeners().add(new ComponentMouseButtonListener() {
public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {
if (button == Mouse.Button.RIGHT) {
menuPopup.open(display, component.mapPointToAncestor(display, x, y));
}
return false;
}
public boolean mouseUp(Component component, Mouse.Button button, int x, int y) {
return false;
}
public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
return false;
}
});
// Spinners
Spinner numericSpinner = (Spinner)wtkxSerializer.getObjectByName("spinners.numericSpinner");
initializeNumericSpinner(numericSpinner);
Spinner dateSpinner = (Spinner)wtkxSerializer.getObjectByName("spinners.dateSpinner");
initializeDateSpinner(dateSpinner);
// Sliders
SliderValueListener sliderValueListener = new SliderValueListener() {
public void valueChanged(Slider slider, int previousValue) {
Color color = new Color(redSlider.getValue(), greenSlider.getValue(),
blueSlider.getValue());
colorBorder.getStyles().put("backgroundColor", color);
}
};
redSlider = (Slider)wtkxSerializer.getObjectByName("spinners.redSlider");
redSlider.getSliderValueListeners().add(sliderValueListener);
greenSlider = (Slider)wtkxSerializer.getObjectByName("spinners.greenSlider");
greenSlider.getSliderValueListeners().add(sliderValueListener);
blueSlider = (Slider)wtkxSerializer.getObjectByName("spinners.blueSlider");
blueSlider.getSliderValueListeners().add(sliderValueListener);
Color color = new Color(redSlider.getValue(), greenSlider.getValue(),
blueSlider.getValue());
colorBorder = (Border)wtkxSerializer.getObjectByName("spinners.colorBorder");
colorBorder.getStyles().put("backgroundColor", color);
sortableTableView = (TableView)wtkxSerializer.getObjectByName("tables.sortableTableView");
sortableTableViewHeader = (TableViewHeader)wtkxSerializer.getObjectByName("tables.sortableTableViewHeader");
customTableView = (TableView)wtkxSerializer.getObjectByName("tables.customTableView");
initializeTableViews();
DragSource imageDragSource = new DragSource() {
private Image image = null;
private Point offset = null;
private LocalManifest content = null;
public boolean beginDrag(Component component, int x, int y) {
ImageView imageView = (ImageView)component;
image = imageView.getImage();
if (image != null) {
imageView.setImage((Image)null);
content = new LocalManifest();
content.putImage(image);
offset = new Point(x - (imageView.getWidth() - image.getWidth()) / 2,
y - (imageView.getHeight() - image.getHeight()) / 2);
}
return (image != null);
}