use of org.apache.pivot.wtk.content.ButtonData in project pivot by apache.
the class LinkButtonTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BoxPane boxPane = new BoxPane();
boxPane.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
boxPane.getStyles().put(Style.spacing, 8);
boxPane.getComponentMouseListeners().add(new ComponentMouseListener() {
@Override
public boolean mouseMove(Component component, int x, int y) {
System.out.println("BOX PANE " + x + ", " + y);
return false;
}
@Override
public void mouseOver(Component component) {
// empty block
}
@Override
public void mouseOut(Component component) {
// empty block
}
});
Image image = Image.load(getClass().getResource("go-home.png"));
LinkButton linkButton = null;
linkButton = new LinkButton("ABCDE");
boxPane.add(linkButton);
linkButton.getComponentMouseListeners().add(new ComponentMouseListener() {
@Override
public boolean mouseMove(Component component, int x, int y) {
return true;
}
@Override
public void mouseOver(Component component) {
// empty block
}
@Override
public void mouseOut(Component component) {
// empty block
}
});
linkButton = new LinkButton(image);
boxPane.add(linkButton);
linkButton = new LinkButton(new ButtonData(image, "12345"));
boxPane.add(linkButton);
window.setContent(boxPane);
window.open(display);
}
use of org.apache.pivot.wtk.content.ButtonData 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);
}
Aggregations