use of org.apache.pivot.wtk.ComponentMouseListener 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.ComponentMouseListener 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.ComponentMouseListener in project pivot by apache.
the class DecoratorDemo method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BXMLSerializer bxmlSerializer = new BXMLSerializer();
reflectionWindow = (Window) bxmlSerializer.readObject(DecoratorDemo.class, "reflection_window.bxml");
translucentFrame = (Frame) bxmlSerializer.readObject(DecoratorDemo.class, "translucent_frame.bxml");
final FadeDecorator fadeDecorator = new FadeDecorator();
translucentFrame.getDecorators().insert(fadeDecorator, 0);
translucentFrame.getComponentMouseListeners().add(new ComponentMouseListener() {
@Override
public void mouseOver(Component component) {
fadeDecorator.setOpacity(0.9f);
component.repaint();
}
@Override
public void mouseOut(Component component) {
fadeDecorator.setOpacity(0.5f);
component.repaint();
}
});
reflectionWindow.open(display);
translucentFrame.open(reflectionWindow);
}
Aggregations