• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TextField类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.newdawn.slick.gui.TextField的典型用法代码示例。如果您正苦于以下问题:Java TextField类的具体用法?Java TextField怎么用?Java TextField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: init

import org.newdawn.slick.gui.TextField; //导入依赖的package包/类
@Override
	public void init(GameContainer container) throws SlickException {
		this.container = container;
		this.map = new TiledMap("/home/enzo/newmap.tmx");

		SpriteSheet spriteSheet = new SpriteSheet("/home/enzo/SpriteSheetAnim.png", 64, 64);
		this.animations[0] = loadAnimation(spriteSheet, 0, 1, 0);
		this.animations[1] = loadAnimation(spriteSheet, 0, 1, 1);
		this.animations[2] = loadAnimation(spriteSheet, 0, 1, 2);
		this.animations[3] = loadAnimation(spriteSheet, 0, 1, 3);
		this.animations[4] = loadAnimation(spriteSheet, 1, 9, 0);
		this.animations[5] = loadAnimation(spriteSheet, 1, 9, 1);
		this.animations[6] = loadAnimation(spriteSheet, 1, 9, 2);
		this.animations[7] = loadAnimation(spriteSheet, 1, 9, 3);
	
		Font font = new Font("Verdana", Font.BOLD, 20);
		UnicodeFont uFont = new UnicodeFont(font, font.getSize(), font.isBold(), font.isItalic());
		nameInput = new TextField(container, uFont, 150,20,500,35, new ComponentListener()
	        {
	         public void componentActivated(AbstractComponent source) {
	            message = "Entered1: "+nameInput.getText();
	            nameInput.setFocus(true);
	         }

	    });
		
//		ComponentListener listener = new ComponentListener();
//		TextField nameInput = new TextField(arg0, truetypefont, 150,20,500,35, listener);
//		
//		{
//	        public void componentActivated(AbstractComponent source) {
//	           System.out.println("Entered1: "+nameInput.getText());
//	        }
//	   });
	
	}
 
开发者ID:EnzoMolion,项目名称:Projet-PLA,代码行数:37,代码来源:WindowGame.java


示例2: init

import org.newdawn.slick.gui.TextField; //导入依赖的package包/类
@Override
public void init(final GameContainer paramGameContainer, final StateBasedGame paramStateBasedGame) throws SlickException {
    game = paramStateBasedGame;

    font = Resources.INSTANCE.font;

    textField = new TextField(paramGameContainer, font, 100, 540, 1720 , 140);
    textField.setBackgroundColor(Color.white);
    textField.setBorderColor(Color.black);
    textField.setText(Map.INSTANCE.getMapName());

    TITLE_WIDTH = font.getWidth(TITLE);

    SAVE_WIDTH = font.getWidth(SAVE);
    SAVE_HEIGHT = font.getHeight(SAVE);

    BACK_WIDTH = font.getWidth(BACK);
    BACK_HEIGHT = font.getHeight(BACK);

    save = new Rectangle(430 - (SAVE_WIDTH / 2), 800, SAVE_WIDTH, SAVE_HEIGHT);
    back = new Rectangle(1290 - (BACK_WIDTH / 2), 800, BACK_WIDTH, BACK_HEIGHT);
}
 
开发者ID:MichaelJ2,项目名称:big-buum-man,代码行数:23,代码来源:SaveScreen.java


示例3: init

import org.newdawn.slick.gui.TextField; //导入依赖的package包/类
/**
 * @see org.newdawn.slick.Game#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
	state = new SavedState("testdata");
	nameValue = state.getString("name","DefaultName");
	ageValue = (int) state.getNumber("age",64);
	
	name = new TextField(container,container.getDefaultFont(),100,100,300,20,this);
	age = new TextField(container,container.getDefaultFont(),100,150,201,20,this);
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:12,代码来源:SavedStateTest.java


示例4: OptionsOverlay

import org.newdawn.slick.gui.TextField; //导入依赖的package包/类
public OptionsOverlay(DisplayContainer displayContainer, OptionTab[] sections) {
	this.displayContainer = displayContainer;

	this.sections = sections;

	dropdownMenus = new HashMap<>();
	visibleDropdownMenus = new LinkedList<>();

	searchField = new TextField(null, 0, 0, 0, 0);
	searchField.setMaxLength(20);

	scrollHandler = new KineticScrolling();
	scrollHandler.setAllowOverScroll(true);
}
 
开发者ID:yugecin,项目名称:opsu-dance,代码行数:15,代码来源:OptionsOverlay.java


示例5: set

import org.newdawn.slick.gui.TextField; //导入依赖的package包/类
void set(int typeID, GUI gui){
    this.typeID = typeID;
    this.gui = gui;

    gui.clear();

    gc = gui.gc;
    bgWidth = 600;
    bgHeight = 400;
    bgPosX = gc.getWidth()/2-bgWidth/2;
    bgPosY = gc.getHeight()/2-bgHeight/2;
    this.bg = new Rectangle(bgPosX, bgPosY, bgWidth, bgHeight);
    this.border = new Rectangle(gc.getWidth()/2-(bgWidth+5)/2, gc.getHeight()/2-(bgHeight+5)/2, bgWidth, bgHeight);

    si = items.get(typeID);
    cats = si.getCategories();

    int strHeight = fontSmall.getHeight("A"),
        titleHeight = fontTitle.getHeight("A"),
        x = bgPosX+10,
        y = bgPosY+titleHeight+15;
    for (String cat : cats){
        gui.drawText(cat, x, y, fontSmall, Color.white);
        y+=strHeight;
    }
    gui.drawText("X", bgPosX+bgWidth-20, bgPosY+5, fontSmall, Color.white);

    amount = new TextField(gc, fontSmall, 0, 0, 150, 40);
    amount.setBackgroundColor(new Color(0, 0, 0, 50));
    amount.setBorderColor(Color.transparent);
    amount.setTextColor(Color.white);
    amount.setMaxLength(253);
    amount.setFocus(true);
    amount.isAcceptingInput();

    closeChooseAmount();

    isSet = true;
}
 
开发者ID:Piratkopia13,项目名称:Pixel-Planet,代码行数:40,代码来源:Shop.java


示例6: init

import org.newdawn.slick.gui.TextField; //导入依赖的package包/类
@Override
public void init(GameContainer gc, final StateBasedGame sbg) throws SlickException {
	bg = new Image("res/bg.png");
	logo = new Image("res/logo.png");
     
	try {
		awtFontTitle = Game.awtFontTitle.deriveFont(40f); // set font size
		titleFont = new TrueTypeFont(awtFontTitle, true);
		
		awtFont = Game.awtFont.deriveFont(30f); // set font size
		font = new TrueTypeFont(awtFont, true);
 
	} catch (Exception e) {
		e.printStackTrace();
	}
	
	IPinput = new TextField(gc, font, 0, 0, 350, 50);
	IPinput.setBackgroundColor(new Color(0, 0, 0, 50));
	IPinput.setBorderColor(Color.transparent);
	IPinput.setTextColor(Color.white);
	IPinput.setMaxLength(253);
	IPinput.setText(Game.prefs.get(Game.pref_lastip, ""));
	IPinput.setCursorPos(IPinput.getText().length());
	nameField = new TextField(gc, font, 0, 0, 350, 50);
	nameField.setBackgroundColor(new Color(0, 0, 0, 50));
	nameField.setBorderColor(Color.transparent);
	nameField.setTextColor(Color.white);
	nameField.setMaxLength(20);
	nameField.setText(Game.prefs.get(Game.pref_playername, Game.default_username));
	nameField.setCursorPos(nameField.getText().length());
	
	// Net
	Game.network = new Network(gc, sbg);
	
}
 
开发者ID:Piratkopia13,项目名称:Pixel-Planet,代码行数:36,代码来源:Menu.java


示例7: init

import org.newdawn.slick.gui.TextField; //导入依赖的package包/类
@Override
public void init(final GameContainer paramGameContainer, final StateBasedGame paramStateBasedGame) throws SlickException {
    game = paramStateBasedGame;

    font = Resources.INSTANCE.font;
    font2 = paramGameContainer.getDefaultFont();

    xField = new TextField(paramGameContainer, font2, 510, 540, 300 , 140);
    xField.setBackgroundColor(Color.black);
    xField.setBorderColor(Color.white);
    xField.setText("22");
    xField.setMaxLength(2);

    yField = new TextField(paramGameContainer, font, 1060, 540, 300 , 140);
    yField.setBackgroundColor(Color.black);
    yField.setBorderColor(Color.white);
    yField.setText("22");
    yField.setMaxLength(2);

    TITLE_X = font.getWidth(TITLE) / 2;

    OK_X = font.getWidth(OK);
    OK_Y = font.getHeight(OK);

    BACK_X = font.getWidth(BACK);
    BACK_Y = font.getHeight(BACK);

    X_X = font.getWidth(X) / 2;

    REASON_X = font.getWidth(reason) / 2;

    ok = new Rectangle(1260 - (OK_X / 2), 800, OK_X, OK_Y);
    back = new Rectangle(660 - (BACK_X / 2), 800, BACK_X, BACK_Y);
}
 
开发者ID:MichaelJ2,项目名称:big-buum-man,代码行数:35,代码来源:NewMapScreen.java


示例8: init

import org.newdawn.slick.gui.TextField; //导入依赖的package包/类
@Override
public void init(GameContainer container, StateBasedGame game) throws SlickException {
	loadProperties();

	// background = RessourceManager.loadImage("night.jpg");

	connectButton = new Button(this, container, RessourceManager.loadImage("button.png"), 64, 160, () -> {
		try {
			SaboteurGame.instance.setUpConnection(ipTextField.getText(), 5000, pwTextField.getText(),
					nameTextField.getText());
			if (playMusic)
				openingMenuMusic.fade(5000, 0, true);
			StateManager.changeState(1, new FadeOutTransition(Color.black, 1000),
					new FadeInTransition(Color.black, 1000));
		} catch (Exception e) {
			System.out.println("Verbindung zum Server konnte nicht hergestellt werden.");
			e.printStackTrace();
		}
	});

	connectButton.setText("Verbinden");
	connectButton.setMouseDownImage(RessourceManager.loadImage("buttonShadow.png"));

	exitButton =
			new Button(this, container, RessourceManager.loadImage("button.png"), 1024, 512, () -> System.exit(0));
	exitButton.setText("Spiel beenden");
	exitButton.setSound(RessourceManager.loadSound("button.wav"));

	ipTextField =
			new TextField(container, new TrueTypeFont(new Font("Verdana", Font.BOLD, 16), false), 64, 64, 300, 25);
	ipTextField.setTextColor(Color.black);
	ipTextField.setBackgroundColor(Color.white);
	ipTextField.setText("localhost");

	pwTextField =
			new TextField(container, new TrueTypeFont(new Font("Verdana", Font.BOLD, 16), false), 64, 96, 300, 25);
	pwTextField.setTextColor(Color.black);
	pwTextField.setBackgroundColor(Color.white);
	pwTextField.setText("");
	pwTextField.deactivate();

	nameTextField =
			new TextField(container, new TrueTypeFont(new Font("Verdana", Font.BOLD, 16), false), 64, 128, 300, 25);
	nameTextField.setTextColor(Color.black);
	nameTextField.setBackgroundColor(Color.white);
	nameTextField.setText("");
	nameTextField.setMaxLength(10);

	if (playMusic) {
		openingMenuMusic = new Music("res/music/Kool Kats.ogg");
		openingMenuMusic.loop();
	}
}
 
开发者ID:JavaJumperStudios,项目名称:Saboteur,代码行数:54,代码来源:SaboteurMenu.java


示例9: UserSelectOverlay

import org.newdawn.slick.gui.TextField; //导入依赖的package包/类
/**
 * Creates the user selection overlay.
 * @param container the game container
 * @param listener the event listener
 */
public UserSelectOverlay(GameContainer container, UserSelectOverlayListener listener) {
	super(container);
	this.listener = listener;

	this.input = container.getInput();
	this.containerWidth = container.getWidth();
	this.containerHeight = container.getHeight();

	// overlay positions
	this.x = containerWidth / 3;
	this.y = 0;
	this.width = containerWidth / 3;
	this.height = containerHeight;

	// user positions
	this.titleY = Fonts.LARGE.getLineHeight() * 2;
	this.usersStartX = (width - UserButton.getWidth()) / 2;
	this.usersStartY = (int) (titleY + Fonts.XLARGE.getLineHeight() * 1.5f);
	this.usersPaddingY = UserButton.getHeight() / 10;

	// new user
	this.newUser = new User("", UserList.DEFAULT_ICON);
	this.newUserButton = new UserButton(
		(int) (this.x + usersStartX),
		(int) (this.y + usersStartY + Fonts.MEDIUMBOLD.getLineHeight()),
		Color.white
	);
	newUserButton.setUser(newUser);
	newUserButton.setHoverAnimationDuration(400);
	newUserButton.setHoverAnimationEquation(AnimationEquation.LINEAR);

	// new user text field
	this.textField = new TextField(container, null, 0, 0, 0, 0);
	textField.setMaxLength(UserList.MAX_USER_NAME_LENGTH);

	// new user icons
	this.newUserIcons = new MenuButton[UserButton.getIconCount()];
	for (int i = 0; i < newUserIcons.length; i++) {
		newUserIcons[i] = new MenuButton(UserButton.getIconImage(i), 0, 0);
		newUserIcons[i].setHoverFade(0.5f);
	}

	// kinetic scrolling
	this.scrolling = new KineticScrolling();
	scrolling.setAllowOverScroll(true);
}
 
开发者ID:itdelatrisu,项目名称:opsu,代码行数:52,代码来源:UserSelectOverlay.java


示例10: init

import org.newdawn.slick.gui.TextField; //导入依赖的package包/类
@Override
public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
	font = new SimpleFont("data/space age.ttf", gc.getHeight()/54);
	width = gc.getWidth();
	height = gc.getHeight();
	
   multiplayerFont = new SimpleFont("data/space age.ttf", gc.getHeight()/25);
	multiplayerMenu = new String[] {"Spieler 1 hat gewonnen!", "Spieler 2 hat gewonnen!", "Unentschieden!"};
	multiplayer = (boolean)status.get(0).getData();

	playerSpeed = (float) width/3491; //0.55f @ 1080p
	int playerHeight = gc.getHeight()/22;
	int playerWidth = gc.getWidth()/96;
	playerOne = new Rectangle(width/2 + playerWidth/2, height - playerHeight, playerWidth, playerHeight);
	playerTwo = new Rectangle(width/2 - playerWidth, height - playerHeight, playerWidth, playerHeight);
	pOne = new Image("data/Spaceship1.png").getScaledCopy(playerWidth, playerHeight);
	pTwo = new Image("data/Spaceship2.png").getScaledCopy(playerWidth, playerHeight);
	spOne = (SensorParser) status.get(2).getData();
	spTwo = (SensorParser) status.get(3).getData();
	
	notHit = true;
	speedStep = 100;
	score = 0;
	startTime = System.currentTimeMillis(); //The Highscore is time based
	
	obstacleSpeed = (float) height/10800; //0.01f @ 1080p
	obstacleGap = height / 4;
	sectorWidth = width / 10;
	obstacles = new ArrayDeque<ObstacleRow>();
	obstacles.add(new ObstacleRow(sectorWidth, 10, -40));
	
	int fieldWidth = gc.getWidth() / 6;
	int fieldHeight = gc.getHeight() / 36;
	nameField = new TextField(gc, font.get(), width/2 - fieldWidth/2, 
	    height/2 - fieldHeight/2, fieldWidth, fieldHeight);
	nameField.setFocus(true);
	selection = false; //true is right; false is left
	enteredName = false;
	
   menu = new String[] {"Nochmal", "Abbrechen"};
   menuX = new int[2];
   menuY = new int[2];
   menuX[0] = nameField.getX() - font.get().getWidth(menu[0]) - 10;
   menuX[1] = nameField.getX() + nameField.getWidth() + 10;
   menuY[0] = nameField.getY() + font.get().getHeight(menu[0]) + 10;
   menuY[1] = nameField.getY() + font.get().getHeight(menu[1]) + 10;

   stars = new StarBackground(gc.getWidth(), gc.getHeight(), (int)(gc.getHeight() * gc.getWidth() / 4147));
}
 
开发者ID:mtzstngl,项目名称:Spacerun,代码行数:50,代码来源:GameState.java



注:本文中的org.newdawn.slick.gui.TextField类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PermissionGrantedResponse类代码示例发布时间:2022-05-21
下一篇:
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap