use of org.apache.pivot.wtk.Window in project pivot by apache.
the class PromptTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BoxPane boxPane = new BoxPane();
boxPane.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.CENTER);
boxPane.getStyles().put(Style.verticalAlignment, VerticalAlignment.BOTTOM);
helloButton = new PushButton("Say Hello");
boxPane.add(helloButton);
helloButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
String text = button.getButtonData().toString();
if (window.isBlocked()) {
System.out.println("I'm already saying \"" + text + "\" !");
} else {
Prompt.prompt(text, window);
}
}
});
Border border = new Border(boxPane);
border.getStyles().put(Style.color, 7);
border.getStyles().put(Style.padding, 5);
window = new Window(border);
window.setMaximized(true);
window.open(display);
}
use of org.apache.pivot.wtk.Window in project pivot by apache.
the class LabelAntialiasTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) {
window = new Window();
showFontDesktopHints();
showFontFamilies();
TablePane content = new TablePane();
new TablePane.Column(content, 1, true);
BoxPane topBox = new BoxPane(Orientation.HORIZONTAL);
topBox.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
topBox.add(new Label("Rotation angle:"));
rotationAngleSpinner = new Spinner(new NumericSpinnerData(0, 359));
rotationAngleSpinner.setCircular(true);
rotationAngleSpinner.setPreferredWidth(40);
topBox.add(rotationAngleSpinner);
TablePane.Row topRow = new TablePane.Row(content, -1);
topRow.add(topBox);
labelRow = new TablePane.Row(content, 1, true);
window.setContent(content);
window.setTitle("Label Antialiasing Test");
window.setMaximized(true);
rotationAngleSpinner.getSpinnerSelectionListeners().add(new SpinnerSelectionListener() {
@Override
public void selectedItemChanged(Spinner spinner, Object previousSelectedItem) {
currentRotationAngle = (Integer) spinner.getSelectedItem();
if (labelRow.getLength() > 0) {
labelRow.remove(0, labelRow.getLength());
}
labelRow.add(buildLabel(currentRotationAngle));
}
});
rotationAngleSpinner.setSelectedItem(45);
window.open(display);
}
use of org.apache.pivot.wtk.Window in project pivot by apache.
the class JavascriptConsoleTest method loadWindowFromURL.
/**
* Load (and returns) a Window, given its URL and serializer to use <p> Note
* that if public this method could be called even from JS in a bxml file
* (but a reference to the current application has to be put in serializer
* namespace). <p> Note that all Exceptions are catched inside this method,
* to not expose them to JS code.
*
* @param urlString the URL of the bxml file to load, as a String
* @param bxmlSerializer the serializer to use, or if null a new one will be created
* @return the Window instance
*/
public Window loadWindowFromURL(String urlString, final BXMLSerializer bxmlSerializer) {
logObject("loadWindow from \"" + urlString + "\", with the serializer " + bxmlSerializer);
BXMLSerializer serializer = bxmlSerializer;
if (serializer == null) {
serializer = new BXMLSerializer();
}
Window loadedWindow = null;
try {
URL url = new URL(urlString);
// force the location, so it will be possible to decode resources
// like labels ...
serializer.setLocation(url);
loadedWindow = (Window) serializer.readObject(url);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (SerializationException e) {
e.printStackTrace();
}
return loadedWindow;
}
use of org.apache.pivot.wtk.Window in project pivot by apache.
the class Pivot894 method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
System.out.println("public startup(...)");
System.out.println("\n" + "Attention: now the application will go in an infinite loop, to be able to see the memory leak.\n" + "Note that probably you'll have to kill the application from outside (kill the Java process).\n" + "\n");
// add some sleep to let users see the warning messages in console ...
Thread.sleep(2000);
final CardPane cardPane = new CardPane();
cardPane.getStyles().put(Style.selectionChangeEffect, CardPaneSkin.SelectionChangeEffect.HORIZONTAL_SLIDE);
final Window window = new Window(cardPane);
window.open(display);
ApplicationContext.scheduleRecurringCallback(new Runnable() {
@Override
public void run() {
Thread.currentThread().setName("switcher-thread");
// temp
System.out.println("Run num " + num++);
//
try {
// Before the fixes for PIVOT-861 (part two) it was causing
// out of memory ...
//
// Note that this has been moved to another issue, but the
// problem is due to the usage
// of dataRenderer tags (and then instancing
// ButtonDataRenderer) in the loaded bxml,
// so probably even this test will be updated ...
//
final GridPane grid = (GridPane) new BXMLSerializer().readObject(Pivot894.class, "btn_grid.bxml");
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
Iterator<Component> iterator = cardPane.iterator();
List<Component> componentList = new ArrayList<>();
while (iterator.hasNext()) {
Component card = iterator.next();
if (!card.isShowing()) {
componentList.add(card);
}
}
for (Component card : componentList) {
cardPane.remove(card);
}
cardPane.setSelectedIndex(cardPane.add(grid));
System.out.println(cardPane.getSelectedIndex());
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
@SuppressWarnings("unused")
private Row createGridRow() {
Row row = new Row();
try {
// note that this method doesn't use ApplicationContext
// cache for images ...
row.add(new PushButton(new ButtonData(Image.load(new File("clock_icon.png").toURI().toURL()), "Clock")));
row.add(new PushButton(new ButtonData(Image.load(new File("clock_icon.png").toURI().toURL()), "Clock")));
row.add(new PushButton(new ButtonData(Image.load(new File("clock_icon.png").toURI().toURL()), "Clock")));
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (TaskExecutionException e) {
e.printStackTrace();
}
return row;
}
}, 100);
}
use of org.apache.pivot.wtk.Window in project pivot by apache.
the class Pivot835 method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BXMLSerializer bxmlSerializer = new BXMLSerializer();
Window window = (Window) bxmlSerializer.readObject(getClass().getResource("pivot_835.bxml"));
window.open(display);
}
Aggregations