Search in sources :

Example 11 with Label

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

the class LabelSkin method install.

@Override
public void install(Component component) {
    super.install(component);
    Label label = (Label) getComponent();
    label.getLabelListeners().add(this);
}
Also used : Label(org.apache.pivot.wtk.Label)

Example 12 with Label

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

the class ColorSchemeBuilderWindow method createColorPaletteCell.

private static Component createColorPaletteCell(int index) {
    Border border = new Border();
    border.getStyles().put(Style.backgroundColor, index);
    Theme theme = Theme.getTheme();
    Label label = new Label();
    label.setText(Integer.toString(index));
    label.getStyles().put(Style.font, "{size:'80%'}");
    label.getStyles().put(Style.backgroundColor, 4);
    label.getStyles().put(Style.padding, 1);
    BoxPane boxPane = new BoxPane();
    boxPane.getStyles().put(Style.padding, 2);
    boxPane.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.CENTER);
    boxPane.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
    boxPane.add(new Border(label));
    border.setContent(boxPane);
    return border;
}
Also used : BoxPane(org.apache.pivot.wtk.BoxPane) Label(org.apache.pivot.wtk.Label) Theme(org.apache.pivot.wtk.Theme) Border(org.apache.pivot.wtk.Border)

Example 13 with Label

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

the class XMLViewer method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    bxmlSerializer.getNamespace().put(APPLICATION_KEY, this);
    window = (Window) bxmlSerializer.readObject(XMLViewer.class, "xml_viewer.bxml");
    bxmlSerializer.bind(this);
    Label prompt = new Label("Drag or paste XML here");
    prompt.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.CENTER);
    prompt.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
    promptDecorator.setOverlay(prompt);
    treeView.getDecorators().add(promptDecorator);
    window.setTitle(WINDOW_TITLE);
    window.open(display);
    window.requestFocus();
    if (System.in.available() > 0) {
        XMLSerializer xmlSerializer = new XMLSerializer();
        try {
            setDocument(xmlSerializer.readObject(System.in));
        } catch (Exception exception) {
        // No-op
        }
    }
}
Also used : BXMLSerializer(org.apache.pivot.beans.BXMLSerializer) XMLSerializer(org.apache.pivot.xml.XMLSerializer) Label(org.apache.pivot.wtk.Label) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer) IOException(java.io.IOException)

Example 14 with Label

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

the class BuilderExample method buildWindow.

private static MyWindow buildWindow() {
    final HashMap<String, Object> namespace = new HashMap<>();
    return new MyWindow() {

        {
            setContent(new TabPane() {

                {
                    namespace.put("tabPane", this);
                    getTabs().add(new Label() {

                        {
                            setText("Label 1");
                            TabPane.setTabData(this, "Label 1");
                        }
                    });
                    getTabs().add(new Label() {

                        {
                            setText("Label 2");
                            TabPane.setTabData(this, "Label 2");
                        }
                    });
                    getTabs().add(new Label() {

                        {
                            setText("Label 3");
                            TabPane.setTabData(this, "Label 3");
                        }
                    });
                    setSelectedIndex(2);
                }
            });
            setTitle("Builder Example");
            setMaximized(true);
            initialize(namespace, null, null);
        }
    };
}
Also used : TabPane(org.apache.pivot.wtk.TabPane) HashMap(org.apache.pivot.collections.HashMap) Label(org.apache.pivot.wtk.Label)

Example 15 with Label

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

the class LabelTest method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    frame = new Frame();
    frame.setTitle("Label Test");
    String line1 = "There's a lady who's sure all that glitters is gold, and " + "she's buying a stairway to heaven. When she gets there she knows, " + "if the stores are closed, with a word she can get what she came " + "for. Woe oh oh oh oh oh and she's buying a stairway to heaven. " + "There's a sign on the wall, but she wants to be sure, and you know " + "sometimes words have two meanings. In a tree by the brook there's " + "a songbird who sings, sometimes all of our thoughts are misgiven. " + "Woe oh oh oh oh oh and she's buying a stairway to heaven.";
    String line2 = "And as we wind on down the road, our shadows taller than " + "our souls, there walks a lady we all know who shines white light " + "and wants to show how everything still turns to gold; and if you " + "listen very hard the tune will come to you at last when all are " + "one and one is all:\nto be a rock and not to roll.";
    BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
    Label label1 = new Label(line1);
    label1.getStyles().put(Style.wrapText, true);
    label1.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.LEFT);
    boxPane.add(label1);
    // strikethrough
    Label label2 = new Label(line2);
    label2.getStyles().put(Style.wrapText, true);
    label2.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.LEFT);
    label2.getStyles().put(Style.textDecoration, TextDecoration.STRIKETHROUGH);
    boxPane.add(label2);
    // disabled
    Label label3 = new Label(line2);
    label3.getStyles().put(Style.wrapText, true);
    label3.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.LEFT);
    label3.setEnabled(false);
    boxPane.add(label3);
    boxPane.getStyles().put(Style.fill, true);
    boxPane.getStyles().put(Style.padding, new Insets(10));
    frame.setContent(boxPane);
    frame.setPreferredSize(340, 400);
    frame.open(display);
}
Also used : Frame(org.apache.pivot.wtk.Frame) Insets(org.apache.pivot.wtk.Insets) BoxPane(org.apache.pivot.wtk.BoxPane) Label(org.apache.pivot.wtk.Label)

Aggregations

Label (org.apache.pivot.wtk.Label)44 Component (org.apache.pivot.wtk.Component)20 BoxPane (org.apache.pivot.wtk.BoxPane)15 Point (org.apache.pivot.wtk.Point)13 Form (org.apache.pivot.wtk.Form)10 TextInput (org.apache.pivot.wtk.TextInput)8 ComponentStateListener (org.apache.pivot.wtk.ComponentStateListener)7 FlowPane (org.apache.pivot.wtk.FlowPane)7 IntValidator (org.apache.pivot.wtk.validation.IntValidator)7 TablePane (org.apache.pivot.wtk.TablePane)6 FontRenderContext (java.awt.font.FontRenderContext)5 Rectangle2D (java.awt.geom.Rectangle2D)5 Dimensions (org.apache.pivot.wtk.Dimensions)5 Frame (org.apache.pivot.wtk.Frame)5 Separator (org.apache.pivot.wtk.Separator)5 Color (java.awt.Color)3 Font (java.awt.Font)3 LineMetrics (java.awt.font.LineMetrics)3 IOException (java.io.IOException)3 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)3