001 // This file is part of AceWiki.
002 // Copyright 2008-2012, AceWiki developers.
003 //
004 // AceWiki is free software: you can redistribute it and/or modify it under the terms of the GNU
005 // Lesser General Public License as published by the Free Software Foundation, either version 3 of
006 // the License, or (at your option) any later version.
007 //
008 // AceWiki is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
009 // even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
010 // Lesser General Public License for more details.
011 //
012 // You should have received a copy of the GNU Lesser General Public License along with AceWiki. If
013 // not, see http://www.gnu.org/licenses/.
014
015 package ch.uzh.ifi.attempto.echocomp;
016
017 import nextapp.echo.app.Border;
018 import nextapp.echo.app.Color;
019 import nextapp.echo.app.Extent;
020 import nextapp.echo.app.Font;
021 import nextapp.echo.app.event.ActionListener;
022
023 /**
024 * This is a convenience class for easy creation of text fields.
025 *
026 * @author Tobias Kuhn
027 */
028 public class TextField extends nextapp.echo.app.TextField {
029
030 private static final long serialVersionUID = 8965038167453278878L;
031
032 /**
033 * Creates a new text field.
034 *
035 * @param width The width of the text field.
036 * @param actionListener The action-listener of the text field.
037 * @param style The style of the text.
038 */
039 public TextField(int width, ActionListener actionListener, int style) {
040 setWidth(new Extent(width));
041 setHeight(new Extent(17));
042 setFont(new Font(Style.fontTypeface, style, new Extent(13)));
043 setBackground(Style.lightBackground);
044 setBorder(new Border(1, Color.BLACK, Border.STYLE_INSET));
045 setDisabledBackground(Style.lightDisabled);
046 if (actionListener != null) {
047 addActionListener(actionListener);
048 }
049 }
050
051 /**
052 * Creates a new text field.
053 *
054 * @param width The width of the text field.
055 * @param actionListener The action-listener of the text field.
056 */
057 public TextField(int width, ActionListener actionListener) {
058 this(width, actionListener, Font.PLAIN);
059 }
060
061 /**
062 * Creates a new text field.
063 *
064 * @param width The width of the text field.
065 */
066 public TextField(int width) {
067 this(width, null, Font.PLAIN);
068 }
069
070 /**
071 * Creates a new text field.
072 *
073 * @param actionListener The action-listener of the text field.
074 */
075 public TextField(ActionListener actionListener) {
076 this(500, actionListener, Font.PLAIN);
077 }
078
079 /**
080 * Creates a new text field.
081 */
082 public TextField() {
083 this(500, null, Font.PLAIN);
084 }
085
086 }