public AddFeedDialog(ObjectListField list) { super( new VerticalFieldManager(VERTICAL_SCROLLBAR | VERTICAL_SCROLL), DEFAULT_MENU | Field.FOCUSABLE); this.list = list; // title label to sit at top of screen LabelField titleLbl = new LabelField("Add a Feed", Field.FIELD_HCENTER); titleLbl.setFont(titleLbl.getFont().derive(Font.BOLD)); titleLbl.setMargin(new XYEdges(0, 0, 10, 0)); // top,right,bottom,left // set up fields.. LabelField nameLbl = new LabelField("Name"); nameTxt = new TextField(500); LabelField urlLbl = new LabelField("Address"); urlTxt = new TextField(500, EditField.FILTER_URL); addBtn = new ButtonField("Add", ButtonField.CONSUME_CLICK | Field.FIELD_HCENTER); cancelBtn = new ButtonField("Cancel", ButtonField.CONSUME_CLICK | Field.FIELD_HCENTER); // add everything to the screen.. HorizontalFieldManager buttonsManager = new HorizontalFieldManager(Field.FIELD_HCENTER); buttonsManager.setMargin(new XYEdges(10, 0, 5, 0)); // top,right,bottom,left buttonsManager.add(addBtn); buttonsManager.add(cancelBtn); this.add(titleLbl); this.add(nameLbl); this.add(nameTxt); this.add(urlLbl); this.add(urlTxt); this.add(buttonsManager); // add action listeners to buttons.. addBtn.setChangeListener( new FieldChangeListener() { public void fieldChanged(Field field, int context) { add(); } }); cancelBtn.setChangeListener( new FieldChangeListener() { public void fieldChanged(Field field, int context) { cancel(); } }); }
/** * Create a LabelField that spans the entire width of the container with gray text and a single * pixel gray border at the bottom. * * @param title * @return */ public static LabelField createGroupLabel(String title) { LabelField titleField = new LabelField(title, LabelField.USE_ALL_WIDTH) { protected void paint(Graphics graphics) { graphics.setColor(COLOR_GROUP_LABEL_FOREGROUND); super.paint(graphics); } }; Font font = titleField.getFont(); titleField.setFont(font.derive(Font.BOLD, font.getHeight() - 3)); titleField.setPadding(new XYEdges(0, 0, 4, 0)); titleField.setBorder( BorderFactory.createSimpleBorder( new XYEdges(0, 0, 1, 0), new XYEdges(0, 0, COLOR_GROUP_LABEL_BORDER, 0), Border.STYLE_SOLID)); titleField.setMargin(new XYEdges(0, 0, 4, 0)); return titleField; }