Search in sources :

Example 11 with PushButton

use of org.apache.pivot.wtk.PushButton in project pivot by apache.

the class Pivot686 method initializeFields.

private void initializeFields(BXMLSerializer serializer) {
    System.out.println("initializeFields: start");
    textInput = (TextInput) serializer.getNamespace().get("textInput");
    // note that this has no effect here
    textInput.requestFocus();
    System.out.println("textInput has focus: " + textInput.isFocused());
    pushButton = (PushButton) serializer.getNamespace().get("pushButton");
    pushButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button button) {
            String msg = "You clicked me!";
            System.out.println(msg);
            // Alert.alert(MessageType.INFO, msg, window);
            textInput.setText("");
            textInput.requestFocus();
        }
    });
    System.out.println("initializeFields: end");
}
Also used : ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button)

Example 12 with PushButton

use of org.apache.pivot.wtk.PushButton in project pivot by apache.

the class PushButtonSkin method mouseClick.

@Override
public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
    boolean consumed = super.mouseClick(component, button, x, y, count);
    PushButton pushButton = (PushButton) getComponent();
    pushButton.press();
    return consumed;
}
Also used : PushButton(org.apache.pivot.wtk.PushButton)

Example 13 with PushButton

use of org.apache.pivot.wtk.PushButton in project pivot by apache.

the class PushButtonSkin method keyReleased.

/**
 * {@link KeyCode#SPACE SPACE} 'presses' the button.
 */
@Override
public boolean keyReleased(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
    boolean consumed = false;
    PushButton pushButton = (PushButton) getComponent();
    if (keyCode == Keyboard.KeyCode.SPACE) {
        pressed = false;
        repaintComponent();
        pushButton.press();
    } else {
        consumed = super.keyReleased(component, keyCode, keyLocation);
    }
    return consumed;
}
Also used : PushButton(org.apache.pivot.wtk.PushButton)

Example 14 with PushButton

use of org.apache.pivot.wtk.PushButton in project pivot by apache.

the class SheetSlideDirectionWindow method initialize.

@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
    // Populate the ListButton with values from the enum
    listButton.setListData(new ArrayList<>(SheetPlacement.values()));
    listButton = null;
    // Populate the form with data from the Sheet's styles
    form.load(sheet.getStyles());
    // Common ButtonPressListener to be applied to all four of
    // the PushButtons representing a slide direction
    ButtonPressListener openSheetButtonPressListener = new ButtonPressListener() {

        @Override
        public void buttonPressed(Button button) {
            StyleDictionary sheetStyles = sheet.getStyles();
            form.store(sheetStyles);
            button.store(sheetStyles);
            form.load(sheetStyles);
            sheet.load(sheetStyles);
            sheet.open(button.getWindow());
        }
    };
    // Apply the common ButtonPressListener to the PushButtons
    for (Iterator<Component> it = tablePane.iterator(); it.hasNext(); ) {
        Component component = it.next();
        if (component instanceof PushButton) {
            PushButton button = (PushButton) component;
            button.getButtonPressListeners().add(openSheetButtonPressListener);
            button.setTooltipText("Press me!");
        }
    }
    tablePane = null;
    // Mouse handler to enable users to quickly close the sheet
    final ContainerMouseListener displayMouseHandler = new ContainerMouseListener() {

        @Override
        public boolean mouseDown(Container container, Mouse.Button button, int x, int y) {
            Display display = (Display) container;
            Component component = display.getComponentAt(x, y);
            // Close the sheet by clicking away from it.
            // This allows resizing etc to work without requiring
            // a close button or similar on the sheet.
            boolean consumed = (component != sheet);
            if (consumed) {
                sheet.close();
            }
            return consumed;
        }
    };
    // Add/remove the mouse handler based on the Sheet's state
    sheet.getWindowStateListeners().add(new WindowStateListener() {

        @Override
        public void windowOpened(Window window) {
            window.getDisplay().getContainerMouseListeners().add(displayMouseHandler);
        }

        @Override
        public void windowClosed(Window window, Display display, Window owner) {
            display.getContainerMouseListeners().remove(displayMouseHandler);
        }
    });
}
Also used : Window(org.apache.pivot.wtk.Window) WindowStateListener(org.apache.pivot.wtk.WindowStateListener) ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) Container(org.apache.pivot.wtk.Container) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) ListButton(org.apache.pivot.wtk.ListButton) ContainerMouseListener(org.apache.pivot.wtk.ContainerMouseListener) Component(org.apache.pivot.wtk.Component) PushButton(org.apache.pivot.wtk.PushButton) Display(org.apache.pivot.wtk.Display)

Example 15 with PushButton

use of org.apache.pivot.wtk.PushButton in project pivot by apache.

the class PushButtonTest method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    window = new Window();
    BoxPane boxPane = new BoxPane();
    boxPane.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.RIGHT);
    PushButton uploadButton = new PushButton("Upload");
    uploadButton.getStyles().put(Style.minimumAspectRatio, 3.0f);
    boxPane.add(uploadButton);
    window.setContent(boxPane);
    window.setMaximized(true);
    window.open(display);
}
Also used : Window(org.apache.pivot.wtk.Window) BoxPane(org.apache.pivot.wtk.BoxPane) PushButton(org.apache.pivot.wtk.PushButton)

Aggregations

PushButton (org.apache.pivot.wtk.PushButton)39 Button (org.apache.pivot.wtk.Button)29 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)23 Window (org.apache.pivot.wtk.Window)9 BoxPane (org.apache.pivot.wtk.BoxPane)8 Component (org.apache.pivot.wtk.Component)6 GradientPaint (java.awt.GradientPaint)5 ListButton (org.apache.pivot.wtk.ListButton)5 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)4 Path (org.apache.pivot.collections.Sequence.Tree.Path)3 Checkbox (org.apache.pivot.wtk.Checkbox)3 Frame (org.apache.pivot.wtk.Frame)3 ListView (org.apache.pivot.wtk.ListView)3 Sheet (org.apache.pivot.wtk.Sheet)3 TreeView (org.apache.pivot.wtk.TreeView)3 TreeViewSelectionListener (org.apache.pivot.wtk.TreeViewSelectionListener)3 TreeBranch (org.apache.pivot.wtk.content.TreeBranch)3 File (java.io.File)2 TaskExecutionException (org.apache.pivot.util.concurrent.TaskExecutionException)2 Alert (org.apache.pivot.wtk.Alert)2