Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9145311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:28:58+00:00 2026-06-17T10:28:58+00:00

I’ve tested TextField on a clean BasicGame and it worked. (I see the border

  • 0

I’ve tested TextField on a clean BasicGame and it worked. (I see the border and i can type.)

The code:

            TextField lanText;  
            TrueTypeFont font;

            public void init(........)
        {
            font = new TrueTypeFont(new java.awt.Font(java.awt.Font.SERIF,java.awt.Font.BOLD,8),false);
            lanText = new TextField(gc, font, 50, 100, 350, 25);

}

    public void render(.....)
        {  
            lanText.render(gc, g);
        }

But when i try it on my game with BasicGameState it doesn’t work. What’s wrong? (I can see the border but I cant type)

I have 4 states. Menu 0. Game 1. Coop 2. Options 3.

Im trying to add it to the state 2(Coop).

public class Game
extends StateBasedGame
{
    public final int menu = 0;
    public final int game = 1;
    public final int option = 2;
    public final int coop = 3;

    public Game(String gamename)
    {
        super(gamename);
        this.addState(new Menu(menu));
        this.addState(new Game(game));
        this.addState(new Option(option));
        this.addState(new Coop(coop));
    }

public void initStatesList(GameContainer gc)
    throws SlickException
    {
    this.getState(menu).init(gc, this);
    this.getState(game).init(gc, this);
    this.getState(option).init(gc, this);
    this.getState(coop).init(gc, this);
    this.enterState(menu);
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:28:59+00:00Added an answer on June 17, 2026 at 10:28 am

    Ok, I figured it out. Here is the code for anyone who will have the same problem.

    import java.awt.Font;
    import org.newdawn.slick.GameContainer;
    import org.newdawn.slick.Graphics;
    import org.newdawn.slick.SlickException;
    import org.newdawn.slick.UnicodeFont;
    import org.newdawn.slick.font.effects.ColorEffect;
    import org.newdawn.slick.gui.ComponentListener;
    import org.newdawn.slick.gui.TextField;
    import org.newdawn.slick.state.BasicGameState;
    import org.newdawn.slick.state.StateBasedGame;
    
    public class Coop
            extends BasicGameState
    {
        TextField text;
        UnicodeFont font;
    
        public Coop(int state)
        {
        }
    
        public void init(GameContainer gc , StateBasedGame sbg)
                throws SlickException
        {
            font = getNewFont("Arial" , 16);
        }
    
        public void render(GameContainer gc , StateBasedGame sbg , Graphics g)
                throws SlickException
        {
            text.render(gc , g);
            g.setFont(font);
        }
    
        public void update(GameContainer gc , StateBasedGame sbg , int delta)
                throws SlickException
        {
            font.loadGlyphs();
        }
    
        public int getID()
        {
            return 3;
        }
    
        public void enter(GameContainer gc , StateBasedGame sbg)
                throws SlickException
        {
            text = new TextField(gc , font , 150 , 270 , 200 , 35);
        }
    
        public UnicodeFont getNewFont(String fontName , int fontSize)
        {
            font = new UnicodeFont(new Font(fontName , Font.PLAIN , fontSize));
            font.addGlyphs("@");
            font.getEffects().add(new ColorEffect(java.awt.Color.white));
            return (font);
        }
    }
    

    I don’t know why it needs to use font.loadGlyphs(); but without it, it wont work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Does anyone know how can I replace this 2 symbol below from the string
I need a function that will clean a strings' special characters. I do NOT
I need to clean up various Word 'smart' characters in user input, including but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.