Button
@Deprecated public class Button extends ButtonWrapper
It is simply a button composite that contains a label.
This example shows a simple button:
Button button = new Button("Press Me");
This example shows a styled button (be aware that the label is drawn over the button, so its background must be transparent in order to see the button background):
Button button = new Button("Press Me"); EditableStyle buttonStyle = new EditableStyle(); buttonStyle.setBackgroundColor(Colors.SILVER); buttonStyle.setBorder(new SimpleRectangularBorder(1)); buttonStyle.setFontProfile(new FontProfile("", 23, Font.STYLE_PLAIN)); button.mergeStyle(buttonStyle); EditableStyle buttonLabelStyle = new EditableStyle(); buttonLabelStyle.setBackground(NoBackground.NO_BACKGROUND); button.getLabel().mergeStyle(buttonLabelStyle);
This example shows a styled button with its background color changing on a press action:
Button button = new Button("Press Me"); Stylesheet stylesheet = StyleHelper.getStylesheet(); EditableStyle buttonStyle = new EditableStyle(); buttonStyle.setBackgroundColor(Colors.SILVER); buttonStyle.setBorder(new SimpleRectangularBorder(1)); buttonStyle.setFontProfile(new FontProfile("", 23, Font.STYLE_PLAIN)); stylesheet.addRule(new TypeSelector(Button.class), buttonStyle); EditableStyle pressedButtonStyle = new EditableStyle(); pressedButtonStyle.setBackgroundColor(Colors.GRAY); stylesheet.addRule(new AndCombinator(new TypeSelector(Button.class), new StateSelector(State.Active)), pressedButtonStyle); EditableStyle buttonLabelStyle = new EditableStyle(); buttonLabelStyle.setBackground(NoBackground.NO_BACKGROUND); stylesheet.addRule(new ChildCombinator(new TypeSelector(Button.class), new TypeSelector(Label.class)), buttonLabelStyle);
Label
EMPTY_ELEMENT_ARRAY
Constructor and Description |
---|
Button()
Deprecated.
Creates a button with an empty text.
|
Button(java.lang.String text)
Deprecated.
Creates a button with the given text to display.
|
Modifier and Type | Method and Description |
---|---|
Label |
getLabel()
Deprecated.
Gets the label contained in the button.
|
java.lang.String |
getText()
Deprecated.
Gets the text displayed by this button.
|
void |
setText(java.lang.String text)
Deprecated.
Sets the text displayed by this button.
|
void |
setWidget(ej.mwt.Widget widget)
Deprecated.
Sets the only child of this composite.
|
addOnClickListener, handleEvent, isInState, onClick, performClick, removeOnClickListener, requestFocus, requestFocus
contains, isAdjustedToChild, setAdjustedToChild, setBoundsContent, validateContent
add, addClassSelector, gainFocus, getAttribute, getChild, getChildrenCount, getChildrenElements, getParentElement, getStyle, hasClassSelector, isTransparent, lostFocus, mergeStyle, removeAllClassSelectors, removeClassSelector, removeInstanceStyle, render, renderContent, setBounds, setClassSelectors, setEnabled, updateStyle, updateStyleOnly, validate
getFocus, getFocusIndex, getNext, getWidget, getWidgetAt, getWidgets, getWidgetsCount, hideNotify, iterator, remove, removeAllWidgets, requestFocusFrom, showNotify
getAbsoluteX, getAbsoluteX, getAbsoluteY, getAbsoluteY, getEventHandler, getHeight, getPanel, getParent, getPreferredHeight, getPreferredWidth, getRelativeX, getRelativeY, getWidth, getX, getY, hasFocus, invalidate, isEnabled, isShown, isValid, isVisible, repaint, repaint, revalidate, revalidateSubTree, setEventHandler, setLocation, setPreferredSize, setSize, setVisible
public Button()
public Button(java.lang.String text)
null
.text
- the text to display.java.lang.NullPointerException
- if the text is null
.public void setWidget(ej.mwt.Widget widget)
Wrapper
public Label getLabel()
public void setText(java.lang.String text)
text
- the text to display.java.lang.NullPointerException
- if the text is null
.Label.setText(String)
public java.lang.String getText()
The text is hold by the inner label.
Label.getText()