int n = e.getView().getSelectedIndex();
setSelectedFill(patternList.getModel().get(n));
popup.setVisible(false);
}
});
Button addButton = new Button("add image");
addButton.onClicked(new Callback<ActionEvent>() {
public void call(ActionEvent actionEvent) throws Exception {
FileDialog fd = new FileDialog((Frame) null);
fd.setMode(FileDialog.LOAD);
fd.setTitle("Open Pattern Image");
fd.setVisible(true);
if (fd.getFile() != null) {
File file = new File(fd.getDirectory(), fd.getFile());
u.p("opening a file" + file);
try {
PatternPaint pat = PatternPaint.create(file);
manager.patternManager.addPattern(pat);
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
});
Button createButton = new Button("create new");
createButton.onClicked(new Callback<ActionEvent>() {
public void call(ActionEvent event) throws Exception {
final PatternBuilder builder = new PatternBuilder();
final Stage stage = Stage.createStage();
Callback<ActionEvent> closeAction = new Callback<ActionEvent>() {
public void call(ActionEvent event) throws Exception {
PatternPaint pattern = builder.getPattern();
manager.patternManager.addPattern(pattern);
stage.hide();
}
};
Callback<ActionEvent> cancelAction = new Callback<ActionEvent>() {
public void call(ActionEvent event) throws Exception {
stage.hide();
}
};
stage.setContent(new VFlexBox()
.add(builder, 1)
.add(new HFlexBox()
.add(new Button("cancel").onClicked(cancelAction), 0)
.add(new Button("save").onClicked(closeAction), 0)
,0)
);
stage.setWidth(600);
stage.setHeight(350);
stage.centerOnScreen();