use of org.apache.pivot.wtk.Frame in project pivot by apache.
the class Pivot714 method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
frame = new Frame();
frame.setTitle("Pivot714");
result = (Dialog) getWindow(frame.getRootOwner());
frame.setPreferredSize(640, 480);
frame.open(display);
result.open(owner, dcl);
}
use of org.apache.pivot.wtk.Frame in project pivot by apache.
the class MenuBarTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
boxPane.add(new TextInput());
boxPane.add(new TextInput());
boxPane.add(new TextInput());
frame1 = new Frame(boxPane);
frame1.setLocation(50, 50);
frame1.setPreferredSize(320, 240);
frame1.setTitle("Frame 1");
// put this before loading the related bxml, or an
// IllegalArgumentException will be thrown
Action.getNamedActions().put("about", new Action() {
@Override
public void perform(Component source) {
String msg = "Hello from Pivot-" + ApplicationContext.getPivotVersion().toString() + ", running from Java " + // + ApplicationContext.getJVMVersion().toString()
System.getProperty("java.version");
// frame2);
Alert.alert(msg, frame2.getRootOwner());
System.out.println("Help triggered");
}
});
BXMLSerializer bxmlSerializer = new BXMLSerializer();
frame2 = (Frame) bxmlSerializer.readObject(MenuBarTest.class, "menu_bar_test.bxml");
frame2.setTitle("Frame 2, from bxml");
bxmlSerializer.bind(this, MenuBarTest.class);
MenuHandler menuHandler = new MenuHandler() {
@Override
public void configureMenuBar(Component component, MenuBar menuBar) {
System.out.println("Configure menu bar: got focus on " + component.getName());
}
@Override
public void cleanupMenuBar(Component component, MenuBar menuBar) {
System.out.println("Clean up menu bar: lost focus on " + component.getName());
}
};
textInput1.setMenuHandler(menuHandler);
textInput2.setMenuHandler(menuHandler);
textInput3.setMenuHandler(menuHandler);
frame1.open(display);
frame2.open(display);
}
use of org.apache.pivot.wtk.Frame in project pivot by apache.
the class PanoramaTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
frame1 = new Frame();
frame1.setTitle("Panorama Test 1");
Panorama panorama = new Panorama();
frame1.setContent(panorama);
frame1.setPreferredSize(240, 320);
ImageView imageView = new ImageView();
imageView.setImage(getClass().getResource("IMG_0767_2.jpg"));
panorama.setView(imageView);
frame1.open(display);
BXMLSerializer bxmlSerializer = new BXMLSerializer();
frame2 = new Frame((Component) bxmlSerializer.readObject(getClass().getResource("panorama_test.bxml")));
frame2.setTitle("Panorama Test 2");
frame2.setPreferredSize(480, 360);
frame2.open(display);
}
use of org.apache.pivot.wtk.Frame in project pivot by apache.
the class SheetTest method startup.
@SuppressWarnings("unused")
@Override
public void startup(final Display display, Map<String, String> properties) throws Exception {
Picture picture = (Picture) Image.load(getClass().getResource("IMG_0767_2.jpg"));
picture.resample(120);
BoxPane windowContent = new BoxPane();
PushButton button = new PushButton(picture);
button.getStyles().put(Style.toolbar, true);
windowContent.add(button);
frame = new Frame(windowContent);
frame.setPreferredSize(480, 360);
frame.getStyles().put(Style.padding, 0);
frame.open(display);
final TablePane tablePane = new TablePane();
tablePane.setPreferredSize(320, 240);
new TablePane.Column(tablePane, 1, true);
TablePane.Row row0 = new TablePane.Row(tablePane, 1, true);
TablePane.Row row1 = new TablePane.Row(tablePane, -1);
final Label sheetContent = new Label("Sheet Content");
sheetContent.getStyles().put(Style.wrapText, true);
sheetContent.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.CENTER);
sheetContent.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
row0.add(sheetContent);
Label promptBody = new Label("Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
promptBody.getStyles().put(Style.wrapText, true);
final Prompt prompt = new Prompt(MessageType.INFO, "Prompt", new ArrayList<>("OK"), promptBody);
prompt.setTitle("Prompt");
prompt.getStyles().put(Style.resizable, true);
prompt.getComponentMouseListeners().add(new ComponentMouseListener() {
@Override
public void mouseOver(Component component) {
System.out.println("Mouse Over");
}
@Override
public void mouseOut(Component component) {
System.out.println("Mouse out");
}
});
Label alertBody = new Label("Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
alertBody.getStyles().put(Style.wrapText, true);
final Alert alert = new Alert(MessageType.INFO, "Alert", new ArrayList<>("OK"), alertBody);
alert.setTitle("Alert");
BoxPane boxPane = new BoxPane();
row1.add(boxPane);
boxPane.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.RIGHT);
final PushButton closeButton = new PushButton("Close");
closeButton.getStyles().put(Style.minimumAspectRatio, 3);
boxPane.add(closeButton);
sheet = new Sheet(tablePane);
closeButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button buttonArgument) {
buttonArgument.getWindow().close();
}
});
button.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button buttonArgument) {
prompt.open(frame);
Display displayLocal = DesktopApplicationContext.createDisplay(640, 480, 100, 100, true, true, false, buttonArgument.getDisplay().getHostWindow(), null);
Window window = new Window();
window.setTitle("New Secondary Window");
window.setMaximized(true);
window.setContent(new Label("I am a secondary window!"));
window.open(displayLocal);
}
});
sheet.getWindowStateListeners().add(new WindowStateListener() {
@Override
public void windowOpened(Window window) {
closeButton.requestFocus();
}
});
DesktopApplicationContext.sizeHostToFit(frame);
}
use of org.apache.pivot.wtk.Frame in project pivot by apache.
the class NativeDragDropTest method startup.
@Override
public void startup(final Display display, Map<String, String> properties) throws Exception {
final Label label = new Label("http://pivot.apache.org/");
label.getStyles().put(Style.font, new Font("Arial", Font.PLAIN, 24));
label.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.CENTER);
label.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
label.setDragSource(new DragSource() {
private LocalManifest content = null;
@Override
public boolean beginDrag(Component component, int x, int y) {
content = new LocalManifest();
content.putText(label.getText());
return true;
}
@Override
public void endDrag(Component component, DropAction dropAction) {
content = null;
}
@Override
public boolean isNative() {
return true;
}
@Override
public LocalManifest getContent() {
return content;
}
@Override
public Visual getRepresentation() {
return null;
}
@Override
public Point getOffset() {
return null;
}
@Override
public int getSupportedDropActions() {
return DropAction.COPY.getMask();
}
});
label.setDropTarget(new DropTarget() {
@Override
public DropAction dragEnter(Component component, Manifest dragContent, int supportedDropActions, DropAction userDropAction) {
DropAction dropAction = null;
if (dragContent.containsText()) {
frame.getStyles().put(Style.backgroundColor, "#ffcccc");
dropAction = DropAction.COPY;
}
return dropAction;
}
@Override
public void dragExit(Component component) {
frame.getStyles().put(Style.backgroundColor, "#ffffff");
}
@Override
public DropAction dragMove(Component component, Manifest dragContent, int supportedDropActions, int x, int y, DropAction userDropAction) {
return (dragContent.containsText() ? DropAction.COPY : null);
}
@Override
public DropAction userDropActionChange(Component component, Manifest dragContent, int supportedDropActions, int x, int y, DropAction userDropAction) {
return (dragContent.containsText() ? DropAction.COPY : null);
}
@Override
public DropAction drop(Component component, Manifest dragContent, int supportedDropActions, int x, int y, DropAction userDropAction) {
DropAction dropAction = null;
if (dragContent.containsText()) {
Label labelLocal = (Label) component;
try {
labelLocal.setText(dragContent.getText());
} catch (IOException exception) {
System.err.println(exception);
}
}
dragExit(component);
return dropAction;
}
});
frame = new Frame(label);
frame.open(display);
}
Aggregations