use of com.codename1.ui.layouts.BorderLayout in project CodenameOne by codenameone.
the class MenuBar method adaptTitleLayoutBackCommandStructure.
void adaptTitleLayoutBackCommandStructure() {
Container t = getTitleAreaContainer();
if (t.getComponentCount() - componentCountOffset(t) == 3) {
return;
}
BorderLayout titleLayout = (BorderLayout) t.getLayout();
if (Display.COMMAND_BEHAVIOR_ICS == getCommandBehavior()) {
titleLayout.setCenterBehavior(BorderLayout.CENTER_BEHAVIOR_SCALE);
getTitleComponent().getUnselectedStyle().setAlignment(Component.LEFT, true);
} else {
titleLayout.setCenterBehavior(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE);
}
t.removeAll();
t.addComponent(BorderLayout.CENTER, getTitleComponent());
Container leftContainer = new Container(new BoxLayout(BoxLayout.X_AXIS));
Container rightContainer = new Container(new BoxLayout(BoxLayout.X_AXIS));
t.addComponent(BorderLayout.EAST, rightContainer);
t.addComponent(BorderLayout.WEST, leftContainer);
initTitleBarStatus();
}
use of com.codename1.ui.layouts.BorderLayout in project CodenameOne by codenameone.
the class EmailShare method share.
/**
* {@inheritDoc}
*/
public void share(final String toShare, final String image, final String mimeType) {
final Form currentForm = Display.getInstance().getCurrent();
final Form contactsForm = new Form("Contacts");
contactsForm.setLayout(new BorderLayout());
contactsForm.setScrollable(false);
contactsForm.addComponent(BorderLayout.CENTER, new Label("Please wait..."));
contactsForm.show();
Display.getInstance().startThread(new Runnable() {
public void run() {
String[] ids = ContactsManager.getAllContacts();
if (ids == null || ids.length == 0) {
Display.getInstance().callSerially(new Runnable() {
public void run() {
Dialog.show("Failed to Share", "No Contacts Found", "Ok", null);
currentForm.showBack();
}
});
return;
}
ContactsModel model = new ContactsModel(ids);
final List contacts = new List(model);
contacts.setRenderer(createListRenderer());
Display.getInstance().callSerially(new Runnable() {
public void run() {
contacts.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
final ShareForm[] f = new ShareForm[1];
Hashtable contact = (Hashtable) contacts.getSelectedItem();
if (image == null) {
f[0] = new ShareForm(contactsForm, "Send Email", (String) contact.get("email"), toShare, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
String[] recieptents = new String[1];
recieptents[0] = f[0].getTo();
Message msg = new Message(toShare);
Message.sendMessage(recieptents, "share", msg);
finish();
}
});
f[0].show();
} else {
f[0] = new ShareForm(contactsForm, "Send Email", (String) contact.get("email"), toShare, image, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
String[] recieptents = new String[1];
recieptents[0] = f[0].getTo();
Message msg = new Message(toShare);
msg.setAttachment(image);
msg.setMimeType(mimeType);
Message.sendMessage(recieptents, "share", msg);
finish();
}
});
f[0].show();
}
}
});
contactsForm.addComponent(BorderLayout.CENTER, contacts);
Command back = new Command("Back") {
public void actionPerformed(ActionEvent evt) {
currentForm.showBack();
}
};
contactsForm.addCommand(back);
contactsForm.setBackCommand(back);
contactsForm.revalidate();
}
});
}
}, "Email Thread").start();
}
use of com.codename1.ui.layouts.BorderLayout in project CodenameOne by codenameone.
the class TestComponent method testNestedScrollingLabels.
private void testNestedScrollingLabels() {
int w = Display.getInstance().getDisplayWidth();
int h = Display.getInstance().getDisplayHeight();
Form f = new Form("Scrolling Labels");
Toolbar tb = new Toolbar();
f.setToolbar(tb);
final Form backForm = Display.getInstance().getCurrent();
tb.addCommandToSideMenu(new Command("Back") {
@Override
public void actionPerformed(ActionEvent e) {
if (backForm != null) {
backForm.showBack();
}
}
});
f.setTitle("Scrolling Labels");
Container cnt = new Container(BoxLayout.y());
cnt.setScrollableY(true);
for (String l : new String[] { "Red", "Green", "Blue", "Orange", "Indigo" }) {
for (int i = 0; i < 20; i++) {
cnt.add(l + i);
}
}
f.setLayout(new BorderLayout());
f.add(BorderLayout.CENTER, LayeredLayout.encloseIn(new Button("Press me"), BorderLayout.center(BorderLayout.center(cnt))));
f.show();
TestUtils.waitForFormTitle("Scrolling Labels", 2000);
Component res = f.getComponentAt(w / 2, h / 2);
assertTrue(res == cnt || res.getParent() == cnt, "getComponentAt(x,y) should return scrollable container on top of button when in layered pane.");
}
use of com.codename1.ui.layouts.BorderLayout in project CodenameOne by codenameone.
the class TestComponent method getComponentAt_int_int_button.
private void getComponentAt_int_int_button() {
log("Testing getComponentAt(x, y) with button");
int w = Display.getInstance().getDisplayWidth();
int h = Display.getInstance().getDisplayHeight();
Form f = new Form("My Form", new BorderLayout());
Label l = new Button("Hello");
f.add(BorderLayout.CENTER, l);
f.show();
TestUtils.waitForFormTitle("My Form");
Component middleComponent = f.getComponentAt(w / 2, h / 2);
assertEqual(l, middleComponent, "Found wrong component");
}
use of com.codename1.ui.layouts.BorderLayout in project CodenameOne by codenameone.
the class TestComponent method getComponentAt_int_int_label.
private void getComponentAt_int_int_label() {
log("Testing getComponentAt(x, y) with label");
int w = Display.getInstance().getDisplayWidth();
int h = Display.getInstance().getDisplayHeight();
Form f = new Form("My Form", new BorderLayout());
Label l = new Label("Hello");
f.add(BorderLayout.CENTER, l);
f.show();
TestUtils.waitForFormTitle("My Form", 2000);
Component middleComponent = f.getComponentAt(w / 2, h / 2);
assertEqual(l, middleComponent, "Found wrong component");
}
Aggregations