Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  Text field.  (Read 751 times)
0 Members and 2 Guests are viewing this topic.
Offline SkyAphid

Full Member
**

Posts: 156
Medals: 1



« on: 2012-01-21 17:26:28 »

1  
TextField firstnamebox = new TextField(gc, new Font("Arial", Font.ITALIC, 16), 150, 245, 450, 40);


Eclipse says that the constructor for TextField is undefined.

What's wrong?

"God grant me the serenity, to accept the things I cannot change; courage to change the things I can; and wisdom to know the difference."
Offline GabrielBailey74

Full Member
**

Posts: 157
Medals: 2


Owner of Elite Demons R.I.P


« Reply #1 on: 2012-01-21 17:29:09 »

Would it be:
JTextField?
same as
JTextArea?

Not as in the same purpose, but in the same meaning with a "J" infront.

Offline ra4king

JGO Kernel
*****

Posts: 3160
Medals: 196


I'm the King!


« Reply #2 on: 2012-01-21 17:29:35 »

That means it can't find that constructor.....

EDIT: @GabrielBailey74 I see the "gc", which reminds of GameContainer, which means this is Slick.

EDIT2: @OP After a bit of digging, I found the TextField class in Slick: http://slick.cokeandcode.com/javadoc/org/newdawn/slick/gui/TextField.html

Games published by our own members! Go get 'em!
Offline SkyAphid

Full Member
**

Posts: 156
Medals: 1



« Reply #3 on: 2012-01-21 17:30:22 »

1  
import org.newdawn.slick.gui.*;


At the top of the code.

"God grant me the serenity, to accept the things I cannot change; courage to change the things I can; and wisdom to know the difference."
Offline ra4king

JGO Kernel
*****

Posts: 3160
Medals: 196


I'm the King!


« Reply #4 on: 2012-01-21 17:32:27 »

It looks like your code is fine, since it matches up to the first TextField constructor specified.

Offline SkyAphid

Full Member
**

Posts: 156
Medals: 1



« Reply #5 on: 2012-01-21 17:32:57 »

Yup. I use it in the TrueTypeFont constructor right above it.

Edit. Oh! Okay.

"God grant me the serenity, to accept the things I cannot change; courage to change the things I can; and wisdom to know the difference."
Offline ra4king

JGO Kernel
*****

Posts: 3160
Medals: 196


I'm the King!


« Reply #6 on: 2012-01-21 17:34:08 »

OH! It looks like you're using the java.awt.Font! You cannot use AWT at all here, instead you need an instance of a class that implements org.newdawn.slick.Font. You can only use AngelCodeFont, SpriteSheetFont, TrueTypeFont, or UnicodeFont.

Offline Shazer2

Jr. Member
**

Posts: 66
Medals: 3



« Reply #7 on: 2012-01-21 18:12:54 »

You can still use a Java font as a parameter in TrueTypeFont if need be. I've done it a few times myself.
1  
2  
font = new TrueTypeFont(new java.awt.Font("Verdana",
            java.awt.Font.PLAIN, 14), true);


Then you would set the font the same as you would any other way.

~Shazer2

"When you want to be successful as bad as you want to breathe, then you will be successful." - Eric Thomas
Offline ReBirth

JGO Wizard
****

Posts: 1279
Medals: 19



« Reply #8 on: 2012-01-22 00:14:48 »

@ra4king
no theagentd here~

Follow me, your mastah, on TWITTAH!
Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.101 seconds with 19 queries.