use of com.vaadin.v7.ui.ComboBox in project CodenameOne by codenameone.
the class PasswordManagerTestCase2741 method start.
public void start() {
if (current != null) {
current.show();
return;
}
Form f = new Form("Form 1", BoxLayout.y());
TextField tf1 = new TextField();
tf1.setConstraint(TextField.PASSWORD);
f.add(tf1);
Button b = new Button("Login");
b.addActionListener(e -> {
Form f2 = new Form("F2", BoxLayout.y());
TextField t2 = new TextField();
ComboBox cb = new ComboBox("Red", "Green", "Blue");
f2.addAll(t2, cb);
Button b2 = new Button("Submit");
f2.add(b2);
f2.show();
});
f.add(b);
f.show();
}
use of com.vaadin.v7.ui.ComboBox in project CodenameOne by codenameone.
the class DefaultLookAndFeel method getComboBoxPreferredSize.
/**
* {@inheritDoc}
*/
public Dimension getComboBoxPreferredSize(List cb) {
Dimension d = getListPreferredSize(cb);
Image comboBoxImage = ((ComboBox) cb).getComboBoxImage() != null ? ((ComboBox) cb).getComboBoxImage() : comboImage;
if (comboBoxImage != null) {
d.setWidth(d.getWidth() + comboBoxImage.getWidth());
d.setHeight(Math.max(d.getHeight(), comboBoxImage.getHeight()));
}
return d;
}
use of com.vaadin.v7.ui.ComboBox in project CodenameOne by codenameone.
the class DefaultLookAndFeel method drawComboBox.
/**
* {@inheritDoc}
*/
public void drawComboBox(Graphics g, List cb) {
int border = 2;
Style style = cb.getStyle();
int leftPadding = style.getPaddingLeft(cb.isRTL());
int rightPadding = style.getPaddingRight(cb.isRTL());
setFG(g, cb);
ListModel model = cb.getModel();
ListCellRenderer renderer = cb.getRenderer();
Object value = model.getItemAt(model.getSelectedIndex());
Image comboBoxImage = ((ComboBox) cb).getComboBoxImage() != null ? ((ComboBox) cb).getComboBoxImage() : comboImage;
int comboImageWidth;
if (comboBoxImage != null) {
comboImageWidth = comboBoxImage.getWidth();
} else {
comboImageWidth = style.getFont().getHeight();
}
int cellX = cb.getX() + style.getPaddingTop();
if (cb.isRTL()) {
cellX += comboImageWidth;
}
if (model.getSize() > 0) {
Component cmp = renderer.getListCellRendererComponent(cb, value, model.getSelectedIndex(), cb.hasFocus());
cmp.setX(cellX);
cmp.setY(cb.getY() + style.getPaddingTop());
cmp.setWidth(cb.getWidth() - comboImageWidth - rightPadding - leftPadding);
cmp.setHeight(cb.getHeight() - style.getPaddingTop() - style.getPaddingBottom());
cmp.paint(g);
}
g.setColor(style.getBgColor());
int y = cb.getY();
int height = cb.getHeight();
int width = comboImageWidth + border;
int x = cb.getX();
if (cb.isRTL()) {
x += leftPadding;
} else {
x += cb.getWidth() - comboImageWidth - rightPadding;
}
if (comboBoxImage != null) {
g.drawImage(comboBoxImage, x, y + height / 2 - comboBoxImage.getHeight() / 2);
} else {
int color = g.getColor();
// brighten or darken the color slightly
int destColor = findDestColor(color);
if (style.getBgTransparency() > 0) {
g.fillLinearGradient(g.getColor(), destColor, x, y, width, height, false);
}
g.setColor(color);
int alpha = g.concatenateAlpha(style.getFgAlpha());
g.drawRect(x, y, width, height - 1);
g.setAlpha(alpha);
width--;
height--;
// g.drawRect(x, y, width, height);
g.translate(x + 1, y + 1);
g.setColor(0x111111);
int x1 = scaleCoordinate(2.5652081f, 16, width);
int y1 = scaleCoordinate(4.4753664f, 16, height);
int x2 = scaleCoordinate(8.2872691f, 16, width);
int y2 = scaleCoordinate(10f, 16, height);
int x3 = scaleCoordinate(13.516078f, 16, width);
int y3 = y1;
g.fillTriangle(x1, y1, x2, y2, x3, y3);
g.translate(-1, -1);
g.setColor(style.getFgColor());
alpha = g.concatenateAlpha(style.getFgAlpha());
g.fillTriangle(x1, y1, x2, y2, x3, y3);
g.setAlpha(alpha);
g.translate(-x, -y);
}
}
use of com.vaadin.v7.ui.ComboBox in project CodenameOne by codenameone.
the class HTMLForm method reset.
/**
* Called when a form reset is needed and resets all the form fields to their default values.
*/
void reset() {
for (Enumeration e = defaultValues.keys(); e.hasMoreElements(); ) {
Object input = e.nextElement();
if (input instanceof TextArea) {
// catches both textareas and text input fields
String defVal = (String) defaultValues.get(input);
if (defVal == null) {
defVal = "";
}
((TextArea) input).setText(defVal);
} else if (input instanceof ComboBox) {
OptionItem defVal = (OptionItem) defaultValues.get(input);
ComboBox combo = ((ComboBox) input);
if (defVal != null) {
combo.setSelectedItem(defVal);
} else if (combo.size() > 0) {
combo.setSelectedIndex(0);
}
}
}
for (Enumeration e = defaultCheckedButtons.elements(); e.hasMoreElements(); ) {
Button b = (Button) e.nextElement();
if (!b.isSelected()) {
setButton(b, true);
}
}
for (Enumeration e = defaultUncheckedButtons.elements(); e.hasMoreElements(); ) {
Button b = (Button) e.nextElement();
if (b.isSelected()) {
setButton(b, false);
}
}
}
use of com.vaadin.v7.ui.ComboBox in project ANNIS by korpling.
the class FlatQueryBuilderTest method setup.
@BeforeEach
public void setup() {
UIScopeImpl.setBeanStoreRetrievalStrategy(new SingletonBeanStoreRetrievalStrategy());
this.ui = beanFactory.getBean(AnnisUI.class);
MockVaadin.setup(() -> this.ui);
ui.getQueryState().setSelectedCorpora(Sets.newSet("pcc2"));
// Click on the query builder button and select the flat query builder
_click(_get(Button.class, spec -> spec.withCaption("Query<br />Builder")));
ComboBox queryBuilderChooser = _get(_get(QueryBuilderChooser.class), ComboBox.class);
queryBuilderChooser.select("Word sequences and meta information");
this.queryBuilder = _get(FlatQueryBuilder.class);
}
Aggregations