当前位置: 首页>>代码示例>>Java>>正文


Java TextField.addListener方法代码示例

本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.ui.TextField.addListener方法的典型用法代码示例。如果您正苦于以下问题:Java TextField.addListener方法的具体用法?Java TextField.addListener怎么用?Java TextField.addListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.scenes.scene2d.ui.TextField的用法示例。


在下文中一共展示了TextField.addListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTextField

import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
private TextField getTextField(VisualSettingManager visualSettingManager) {
  final TextField textField = new TextField(i + "", visualSettingManager.getSkin());
  textField.addListener(new EventListener() {
    @Override
    public boolean handle(Event event) {
      if (!(event instanceof SettingsMenu.SaveEvent)) return false;
      try {
        int n = Integer.parseInt(textField.getText());
        if (hasRange && (n < rangeStart || n > rangeEnd)) {
          throw new NumberFormatException();
        } else {
          set(n);
          return true;
        }
      } catch (Exception e) {
        textField.setText(i + "");
        return false;
      }
    }
  });
  textField.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter());
  if (hasRange) textField.setMessageText("(" + rangeStart + "-" + rangeEnd + ")");
  return textField;
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:25,代码来源:IntegerSetting.java

示例2: createButton

import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
private void createButton() {

		Skin skin = getGameObject().getComponentInParent(JCanvas.class).getSkin();
//		TextFieldStyle style = new TextFieldStyle(skin.get("default", TextFieldStyle.class));
		
		int realSize = (int) (((getTransform().getScale().x + getTransform().getScale().y) / 2) * fontSize);
		SmartFontGenerator fontGen = new SmartFontGenerator();
		FileHandle exoFile = Gdx.files.internal(fontResource.getResourcePath());
		BitmapFont fontBitmap = fontGen.createFont(exoFile, fontResource.getResourcePath() + realSize, realSize);
	
		TextFieldStyle styleDefault = skin.get("default", TextFieldStyle.class);
		TextFieldStyle style = new TextFieldStyle(fontBitmap, fontColor, styleDefault.cursor, styleDefault.selection, styleDefault.background);
		
		style.fontColor = fontColor;
		textField = new TextField(text, style);
		textField.addListener(new ChangeListener() {

			@Override
			public void changed(ChangeEvent event, Actor actor) {
				text = textField.getText();				
			}

		});

	}
 
开发者ID:Radomiej,项目名称:JavityEngine,代码行数:26,代码来源:JTextField.java

示例3: addEntry

import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public void addEntry(final String name, int width) {
	final TextField textField = new TextField("", getSkin());
	nameToTextField.put(name, textField);
	add(new Label(name, getSkin())).fill().left();
	if (width != -1) {
		add(textField).fill().right().width(width);
	} else {
		add(textField).fill().right();
	}

	textField.addListener(new ChangeListener() {
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			if (listener != null) {
				listener.onChange(name, textField.getText());
			}
		}
	});

	row();
	pack();
}
 
开发者ID:aphex-,项目名称:Opus-Prototype,代码行数:23,代码来源:InputTable.java

示例4: SaveAsDialog

import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public SaveAsDialog(Skin skin) {
	super("save as..", skin);
	getContentTable().pad(15);

	Label nameLabel = new Label("Name:", skin);
	getContentTable().add(nameLabel);

	final TextField textField = new TextField("", skin);
	textField.addListener(new ChangeListener() {
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			resultValue = textField.getText();
		}
	});
	getContentTable().add(textField);

	button("save", true);
	button("cancel", false);
	pack();
}
 
开发者ID:aphex-,项目名称:Opus-Prototype,代码行数:21,代码来源:SaveAsDialog.java

示例5: buildSearchButton

import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
protected LinearLayout buildSearchButton() {
	LinearLayout searchActor = new LinearLayout(true);

	IconButton icon = WidgetBuilder.toolbarIcon(SkinConstants.IC_SEARCH,
			i18N.m("search"));

	search = new TextField("", skin);
	search.addListener(new InputListener() {
		@Override
		public boolean keyUp(InputEvent event, int keycode) {
			if (keycode == Input.Keys.ENTER) {
				loadContents();
				return true;
			}
			return false;
		}
	});

	searchActor.add(icon);
	searchActor.add(search).marginRight(WidgetBuilder.dpToPixels(16));

	return searchActor;
}
 
开发者ID:e-ucm,项目名称:ead,代码行数:24,代码来源:TabsGallery.java

示例6: getActor

import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
@Override
public Actor getActor(VisualSettingManager visualSettingManager) {
	final TextField textField = new TextField(s, visualSettingManager.getSkin());
	textField.addListener(new EventListener() {
		@Override
		public boolean handle(Event event) {
			if (!(event instanceof SettingsMenu.SaveEvent))
				return false;
			set(textField.getText());
			return true;
		}
	});
	return textField;
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:15,代码来源:StringSetting.java

示例7: ConsoleDialog

import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public ConsoleDialog(UserInterface linkedInterface)
{
	super("Console", Settings.DEFAULT_SKIN);
	this.linkedInterface = linkedInterface;
	setBounds(400, 700, 600, 150);
	Button closeButton = new CloseButton(this); 
	getTitleTable().add(closeButton).size(15, 15).padRight(-5).top().right();
	
	Table table = getContentTable(); 
	inputTextField = new TextField("", getSkin());
	inputTextField.addListener(new InputListener(){

		@Override
		public boolean keyDown(InputEvent event, int keycode)
		{
			if(!ConsoleDialog.this.isVisible())
				inputTextField.setDisabled(true);
			if(keycode == Keys.ENTER)
			{
				addMessageToList();
				sendCommandToExecute();
			}
			return false;
		}

	});

	consolePane = new ConsolePane();
	table.add(consolePane).fillX();

	table.row();
	table.add(inputTextField).width(570).align(Align.bottom);
	table.align(Align.bottom);
}
 
开发者ID:MMORPG-Prototype,项目名称:MMORPG_Prototype,代码行数:35,代码来源:ConsoleDialog.java

示例8: ChatDialog

import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public ChatDialog(UserInterface linkedInterface)
{
	super("Chat", Settings.DEFAULT_SKIN);
	this.linkedInterface = linkedInterface;
	setBounds(0, 0, 400, 200);
	Button closeButton = new CloseButton(this); 
	getTitleTable().add(closeButton).size(15, 15).padRight(-5).top().right();
	
	Table table = getContentTable(); 
	chatTextField = new TextField("", getSkin());
	
	chatTextField.addListener(new InputListener(){

		@Override
		public boolean keyDown(InputEvent event, int keycode)
		{
			if(!ChatDialog.this.isVisible())
				chatTextField.setDisabled(true);
			
			if(keycode == Keys.ENTER)
				sendMessage();
			return false;
		}
	});

	chatPane = new ChatPane();
	table.add(chatPane).fillX();

	table.row();
	table.add(chatTextField).fillX().align(Align.bottom);
	table.align(Align.bottom);
}
 
开发者ID:MMORPG-Prototype,项目名称:MMORPG_Prototype,代码行数:33,代码来源:ChatDialog.java

示例9: getActor

import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
@Override
public Actor getActor(VisualSettingManager visualSettingManager) {
  final TextField textField = new TextField(s, visualSettingManager.getSkin());
  textField.addListener(new EventListener() {
    @Override
    public boolean handle(Event event) {
      if (!(event instanceof SettingsMenu.SaveEvent)) return false;
      set(textField.getText());
      return true;
    }
  });
  return textField;
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:14,代码来源:StringSetting.java

示例10: InputDialog

import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public InputDialog(String title, String message, InputDialogStyle style, OkCancelCallback<String> callback) {
	super(title, style);
	
	this.callback = callback;
	
	messageLabel = new Label(message, style.messageStyle);
	messageLabel.setWrap(true);
	
	textField = new TextField("", style.textFieldStyle);
	textField.addListener(new InputListener() {
		@Override
		public boolean keyUp(InputEvent event, int keycode) {
			if (KeyBindings.CONFIRM.is(keycode)) {
				if (textField.getText().trim().length() < 1) {
					return false;
				}
				okButton.toggle();
				return true;
			} else if (KeyBindings.CANCEL.is(keycode)) {
				cancelButton.toggle();
			}
			
			return false;
		}
	});
	
	add(messageLabel).fill().width(style.messageWidth);
	row();
	add(textField).fill().width(style.messageWidth).padTop(style.textFieldMarginTop);
	row();
	Table buttonsTable = new Table();
	createButtons(buttonsTable, style);
	add(buttonsTable).center().padTop(style.buttonsMarginTop);
	pack();
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:36,代码来源:InputDialog.java

示例11: RenameDialog

import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public RenameDialog(Skin skin, String oldName) {
	super("Rename", skin);
	getContentTable().defaults().pad(14);
	final TextField renameTextField = new TextField(oldName, skin);
	renameTextField.addListener(new ChangeListener() {
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			resultValue = renameTextField.getText();
		}
	});
	getContentTable().add(renameTextField);

	button("OK", true);
	button("cancel", false);
}
 
开发者ID:aphex-,项目名称:Opus-Prototype,代码行数:16,代码来源:RenameDialog.java

示例12: CommandLineService

import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public CommandLineService(ConsoleView consoleView, TextField inputField, JsScriptManager scriptManager, AliasManager aliasManager) {
	this.consoleView = consoleView;
	this.inputField = inputField;
	this.scriptManager = scriptManager;
	this.aliasManager = aliasManager;

	history = new CommandHistory();

	inputField.addListener(new KeyListener());
}
 
开发者ID:Namek,项目名称:TheConsole_POC,代码行数:11,代码来源:CommandLineService.java

示例13: RoomChatPanel

import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public RoomChatPanel (float w, float h) {
	super();
	
	content = new StringBuilder();
	chatprint= new Label(content,Resources._skin);
	
	inputfield = new TextField("",Resources._skin);
	inputfield.setWidth(w);
	inputfield.setMaxLength(max_char_per_mess);
	inputfield.setMessageText("Enter to send ...");
	inputfield.addListener(new InputListener() {
		RoomChat__ chat = new RoomChat__();
		public boolean keyTyped(InputEvent event, char character) {
			if ( character == 13) {
				chat.content = inputfield.getText().getBytes();
				Resources._nclient.sendRoomChat(chat);
				inputfield.setText("");
			}
			return false;
		};
	} );
	
	scrpane = new ScrollPane(chatprint, Resources._skin);
	scrpane.setSize(w,h-inputfield.getHeight()-1);
	scrpane.setFadeScrollBars(false);
	scrpane.setPosition(0,inputfield.getHeight()+1);

	addActor(scrpane);
	addActor(inputfield);
	
	
	this.h = h;
	this.w = w;
}
 
开发者ID:s76,项目名称:zesp2013,代码行数:35,代码来源:RoomChatPanel.java

示例14: FilesListWidget

import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public FilesListWidget(Skin skin) {
	super(false);

	style = skin.get(FilesListWidgetStyle.class);
	folderStyle = new FileIconWidgetStyle(style.folderIcon, style.font,
			style.fontColor, style.selected, style.over);
	fileStyle = new FileIconWidgetStyle(style.fileIcon, style.font,
			style.fontColor, style.selected, style.over);

	filesContainer = new Group();

	ScrollPaneStyle scrollStyle = skin.get(ScrollPaneStyle.class);
	scrollPane = new ScrollPane(filesContainer, scrollStyle);
	scrollPane.setFlickScroll(false);
	scrollPane.setFlingTime(0);
	scrollPane.setSmoothScrolling(false);

	currentPath = new TextField("", skin);
	currentPath.addListener(new InputListener() {
		@Override
		public boolean keyDown(InputEvent event, int keycode) {
			switch (keycode) {
			case Keys.ENTER:
				String path = currentPath.getText();
				FileHandle fileHandle = Gdx.files.absolute(path);
				if (fileHandle.exists()) {
					setSelectedFile(fileHandle, true);
				}
				return true;
			}
			return false;
		}
	});

	add(currentPath).expandX();
	add(scrollPane).expand(true, true);

}
 
开发者ID:e-ucm,项目名称:ead,代码行数:39,代码来源:FilesListWidget.java

示例15: DialogCustomProperty

import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public DialogCustomProperty(Main main, String title, String propertyName, PropertyType propertyType, boolean allowSameName) {
    super(title, main.getSkin(), "bg");
    
    this.allowSameName = allowSameName;
    oldName = propertyName;
    
    getTitleLabel().setAlignment(Align.center);
    
    this.main = main;
    
    Label label = new Label("What is the property name?", getSkin());
    getContentTable().add(label).pad(10.0f).padBottom(0.0f);
    
    getContentTable().row();
    label = new Label("(ex. up)", getSkin());
    getContentTable().add(label).pad(10.0f).padTop(0.0f).padBottom(5.0f);
    
    getContentTable().row();
    nameField = new TextField("", getSkin());
    nameField.setFocusTraversal(false);
    nameField.setText(propertyName);
    nameField.selectAll();
    nameField.addListener(main.getIbeamListener());
    getContentTable().add(nameField).growX().padLeft(10.0f).padRight(10.0f);
    
    getContentTable().row();
    label = new Label("What is the property type?", getSkin());
    getContentTable().add(label).pad(10.0f).padBottom(5.0f);

    getContentTable().row();
    propertyTypeBox = new SelectBox<>(getSkin());
    propertyTypeBox.setItems(PropertyType.TEXT, PropertyType.RAW_TEXT, PropertyType.NUMBER, PropertyType.BOOL, PropertyType.FONT, PropertyType.DRAWABLE, PropertyType.COLOR);
    propertyTypeBox.addListener(main.getHandListener());
    propertyTypeBox.getList().addListener(main.getHandListener());
    if (propertyType != null && propertyType != PropertyType.NONE) {
        propertyTypeBox.setSelected(propertyType);
    }
    getContentTable().add(propertyTypeBox).growX().padLeft(10.0f).padRight(10.0f);

    getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f);
    button("OK", true).key(Keys.ENTER, true);
    button("Cancel", false).key(Keys.ESCAPE, false);
    
    okButton = (TextButton) getButtonTable().getCells().first().getActor();
    updateOkButton();
    
    getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
    
    nameField.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {                
            updateOkButton();
        }
    });
}
 
开发者ID:raeleus,项目名称:skin-composer,代码行数:56,代码来源:DialogCustomProperty.java


注:本文中的com.badlogic.gdx.scenes.scene2d.ui.TextField.addListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。