use of org.apache.pivot.wtk.TextInput in project pivot by apache.
the class ComponentInspectorSkin method updateIntControl.
private void updateIntControl(Dictionary<String, Object> dictionary, String key) {
TextInput textInput = (TextInput) controls.get(key);
if (textInput != null) {
int value = dictionary.getInt(key);
textInput.setText(String.valueOf(value));
}
}
use of org.apache.pivot.wtk.TextInput in project pivot by apache.
the class Pivot965Main method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BXMLSerializer bxmlSerializer = new BXMLSerializer();
window = (Window) bxmlSerializer.readObject(Window.class, "/org/apache/pivot/tests/issues/pivot965/Window965.bxml");
window.open(display);
TextInput textInput = (TextInput) bxmlSerializer.getNamespace().get("textInput");
textInput.requestFocus();
}
use of org.apache.pivot.wtk.TextInput in project pivot by apache.
the class Pivot811 method startup.
@Override
public void startup(final Display displayArgument, Map<String, String> properties) throws Exception {
this.display = displayArgument;
Frame listFrame = new Frame();
listFrame.setTitle("List Frame");
listFrame.setPreferredSize(400, 300);
listFrame.setLocation(20, 20);
listFrame.getStyles().put(Style.padding, Insets.NONE);
BoxPane boxPane = new BoxPane();
boxPane.getStyles().put(Style.fill, true);
boxPane.setOrientation(Orientation.VERTICAL);
listFrame.setContent(boxPane);
Label infoLabel = new Label("Double click on a list item to open a detail frame");
boxPane.add(infoLabel);
ScrollPane scrollPane = new ScrollPane();
scrollPane.setHorizontalScrollBarPolicy(ScrollBarPolicy.FILL);
scrollPane.setVerticalScrollBarPolicy(ScrollBarPolicy.FILL_TO_CAPACITY);
// workaround for pivot-738,
scrollPane.setRepaintAllViewport(true);
// needed only in in some cases
boxPane.add(scrollPane);
final ListView listView = new ListView();
List<String> listData = new ArrayList<>();
for (int i = 0; i < 50; ++i) {
listData.add("List Item " + i);
}
listView.setListData(listData);
scrollPane.setView(listView);
listView.getListViewSelectionListeners().add(new ListViewSelectionListener() {
@Override
public void selectedItemChanged(ListView listViewArgument, Object previousSelectedItem) {
System.out.println("selectedItemChanged : " + listViewArgument.getSelectedItem());
}
});
listView.getComponentMouseButtonListeners().add(new ComponentMouseButtonListener() {
@Override
public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
System.out.println("mouseClick : " + count);
if (count == 2) {
System.out.println("double click, now open a detail frame");
Frame detailFrame = new Frame();
detailFrame.setTitle("Detail Frame");
detailFrame.setPreferredSize(400, 300);
int selectedIndex = listView.getSelectedIndex();
detailFrame.setLocation(80 + (selectedIndex * 10), 80 + (selectedIndex * 10));
detailFrame.getStyles().put(Style.padding, Insets.NONE);
BoxPane boxPaneLocal = new BoxPane();
boxPaneLocal.getStyles().put(Style.fill, true);
boxPaneLocal.setOrientation(Orientation.VERTICAL);
detailFrame.setContent(boxPaneLocal);
String selectedItem = listView.getSelectedItem().toString();
Label label = new Label("Selected Item is \"" + selectedItem + "\"");
boxPaneLocal.add(label);
// spacer
boxPaneLocal.add(new Label(""));
boxPaneLocal.add(new Label("Click inside the text input to focus it"));
TextInput textInput = new TextInput();
textInput.setText("Focusable component");
// workaround for pivot-811:
boxPaneLocal.add(textInput);
// add a focusable element
// inside the frame
detailFrame.open(displayArgument);
// workaround for pivot-811: force the focus on the first
// focusable element inside the frame
detailFrame.requestFocus();
// textInput.requestFocus(); // or use this ...
}
return true;
}
});
listFrame.open(displayArgument);
listView.setSelectedIndex(0);
listView.requestFocus();
}
use of org.apache.pivot.wtk.TextInput in project pivot by apache.
the class SuggestionPopupTest method startup.
@Override
public void startup(final Display display, final Map<String, String> properties) throws Exception {
BXMLSerializer bxmlSerializer = new BXMLSerializer();
window = (Window) bxmlSerializer.readObject(SuggestionPopupTest.class, "suggestion_popup_test.bxml");
bxmlSerializer.bind(this);
textInput.getTextInputContentListeners().add(new TextInputContentListener() {
@Override
public void textInserted(final TextInput textInputArgument, final int index, final int count) {
ArrayList<String> suggestions = new ArrayList<>("One", "Two", "Three", "Four", "Five");
suggestionPopup.setSuggestionData(suggestions);
suggestionPopup.open(textInputArgument, new SuggestionPopupCloseListener() {
@Override
public void suggestionPopupClosed(final SuggestionPopup suggestionPopupArgument) {
if (suggestionPopupArgument.getResult()) {
selectedIndexLabel.setText("You selected suggestion number " + suggestionPopupArgument.getSelectedIndex() + ".");
} else {
selectedIndexLabel.setText("You didn't select anything.");
}
}
});
}
@Override
public void textRemoved(final TextInput textInputArgument, final int index, final int count) {
suggestionPopup.close();
}
});
window.open(display);
}
use of org.apache.pivot.wtk.TextInput in project pivot by apache.
the class WindowFocusTest method startup.
@Override
public void startup(final Display display, final Map<String, String> properties) throws Exception {
BoxPane boxPane1 = new BoxPane(Orientation.VERTICAL);
TextInput textInput1 = new TextInput();
textInput1.setText("ABCD");
boxPane1.add(textInput1);
boxPane1.add(new TextInput());
boxPane1.add(new TextInput());
frame1 = new Frame(boxPane1);
frame1.setPreferredSize(320, 240);
frame1.open(display);
BoxPane boxPane2 = new BoxPane(Orientation.VERTICAL);
TextInput textInput2 = new TextInput();
textInput2.setText("1234");
boxPane2.add(textInput2);
boxPane2.add(new TextInput());
boxPane2.add(new TextInput());
frame2 = new Frame(boxPane2);
frame2.setPreferredSize(320, 240);
frame2.open(display);
frame2.requestFocus();
}
Aggregations