Search in sources :

Example 1 with LinkButton

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

the class BXMLExplorerDocument method setComponentIconOnTreeNode.

private static void setComponentIconOnTreeNode(TreeNode treeNode, Object comp) {
    String resource = null;
    if (comp instanceof Label) {
        resource = "label.png";
    }
    if (comp instanceof ImageView) {
        resource = "/org/apache/pivot/tutorials/IMG_0725_2.jpg";
    }
    if (comp instanceof PushButton) {
        resource = "pushbutton.png";
    }
    if (comp instanceof RadioButton) {
        resource = "radiobutton.png";
    }
    if (comp instanceof Checkbox) {
        resource = "checkbox.png";
    }
    if (comp instanceof LinkButton) {
        resource = "linkbutton.png";
    }
    if (comp instanceof TablePane) {
        resource = "tablepane.png";
    }
    if (resource != null) {
        URL url = BXMLExplorerDocument.class.getResource(resource);
        if (url == null) {
            throw new IllegalStateException("could not load resource " + resource);
        }
        treeNode.setIcon(url);
    }
}
Also used : Checkbox(org.apache.pivot.wtk.Checkbox) Label(org.apache.pivot.wtk.Label) ImageView(org.apache.pivot.wtk.ImageView) RadioButton(org.apache.pivot.wtk.RadioButton) PushButton(org.apache.pivot.wtk.PushButton) LinkButton(org.apache.pivot.wtk.LinkButton) URL(java.net.URL) TablePane(org.apache.pivot.wtk.TablePane)

Example 2 with LinkButton

use of org.apache.pivot.wtk.LinkButton 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);
}
Also used : BoxPane(org.apache.pivot.wtk.BoxPane) ButtonData(org.apache.pivot.wtk.content.ButtonData) Component(org.apache.pivot.wtk.Component) Image(org.apache.pivot.wtk.media.Image) ComponentMouseListener(org.apache.pivot.wtk.ComponentMouseListener) LinkButton(org.apache.pivot.wtk.LinkButton)

Example 3 with LinkButton

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

the class TerraLinkButtonSkin method paint.

@Override
public void paint(Graphics2D graphics) {
    LinkButton linkButton = (LinkButton) getComponent();
    Dimensions size = getSize();
    Button.DataRenderer dataRenderer = linkButton.getDataRenderer();
    dataRenderer.render(linkButton.getButtonData(), linkButton, highlighted);
    dataRenderer.setSize(size);
    dataRenderer.paint(graphics);
}
Also used : LinkButton(org.apache.pivot.wtk.LinkButton) Button(org.apache.pivot.wtk.Button) Dimensions(org.apache.pivot.wtk.Dimensions) LinkButton(org.apache.pivot.wtk.LinkButton)

Example 4 with LinkButton

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

the class LinkButtonSkin 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);
    if (button == Mouse.Button.LEFT) {
        LinkButton linkButton = (LinkButton) getComponent();
        linkButton.press();
    }
    return consumed;
}
Also used : LinkButton(org.apache.pivot.wtk.LinkButton)

Example 5 with LinkButton

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

the class TerraLinkButtonSkin method getBaseline.

@Override
public int getBaseline(int width, int height) {
    LinkButton linkButton = (LinkButton) getComponent();
    Button.DataRenderer dataRenderer = linkButton.getDataRenderer();
    dataRenderer.render(linkButton.getButtonData(), linkButton, false);
    return dataRenderer.getBaseline(width, height);
}
Also used : LinkButton(org.apache.pivot.wtk.LinkButton) Button(org.apache.pivot.wtk.Button) LinkButton(org.apache.pivot.wtk.LinkButton)

Aggregations

LinkButton (org.apache.pivot.wtk.LinkButton)9 Button (org.apache.pivot.wtk.Button)6 RadioButton (org.apache.pivot.wtk.RadioButton)2 URL (java.net.URL)1 BoxPane (org.apache.pivot.wtk.BoxPane)1 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)1 ButtonStateListener (org.apache.pivot.wtk.ButtonStateListener)1 CardPane (org.apache.pivot.wtk.CardPane)1 CardPaneListener (org.apache.pivot.wtk.CardPaneListener)1 Checkbox (org.apache.pivot.wtk.Checkbox)1 Component (org.apache.pivot.wtk.Component)1 ComponentMouseListener (org.apache.pivot.wtk.ComponentMouseListener)1 Dimensions (org.apache.pivot.wtk.Dimensions)1 ImageView (org.apache.pivot.wtk.ImageView)1 Label (org.apache.pivot.wtk.Label)1 PushButton (org.apache.pivot.wtk.PushButton)1 TablePane (org.apache.pivot.wtk.TablePane)1 ButtonData (org.apache.pivot.wtk.content.ButtonData)1 Image (org.apache.pivot.wtk.media.Image)1