How to make a simple textbox in java

How to make a simple textbox in java

Page 1 of 1

10 Replies - 62720 Views - Last Post: 02 March 2009 - 06:53 PM Rate Topic: -----

#1 webeinater  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 11-February 09

How to make a simple textbox in java

Post icon  Posted 02 March 2009 - 03:35 PM

Hey there,
I'm not doing a project or anything like that but I'm just playing around on java and was wondering how to make a simple textbox that I can use to enter numbers.

Thanks
Is This A Good Question/Topic? 0
  • +

Replies To: How to make a simple textbox in java

#2 Public Designs  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 145
  • Joined: 08-November 08

Re: How to make a simple textbox in java

Posted 02 March 2009 - 03:38 PM

JTextField numberEnter = new JTextField("Enter numbers here", 20);
Was This Post Helpful? 0
  • +
  • -

#3 webeinater  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 11-February 09

Re: How to make a simple textbox in java

Posted 02 March 2009 - 04:05 PM

View PostPublic Designs, on 2 Mar, 2009 - 02:38 PM, said:

JTextField numberEnter = new JTextField("Enter numbers here", 20);


Does this code work in Ready To Program (the compiler I'm using).
Also what is more of the code to make a textbox
Was This Post Helpful? 0
  • +
  • -

#4 Public Designs  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 145
  • Joined: 08-November 08

Re: How to make a simple textbox in java

Posted 02 March 2009 - 04:07 PM

You need to import the class.
import javax.swing.JTextField;

And then it should run fine once you add it to the frame or panel
Was This Post Helpful? 0
  • +
  • -

#5 webeinater  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 11-February 09

Re: How to make a simple textbox in java

Posted 02 March 2009 - 04:16 PM

View PostPublic Designs, on 2 Mar, 2009 - 03:07 PM, said:

You need to import the class.
import javax.swing.JTextField;

And then it should run fine once you add it to the frame or panel


Sorry, It's still not working. In Ready To Program what template should I be using for this. Thanks
Was This Post Helpful? 0
  • +
  • -

#6 DR490N5  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 25-February 09

Re: How to make a simple textbox in java

Posted 02 March 2009 - 04:20 PM

View Postwebeinater, on 2 Mar, 2009 - 03:16 PM, said:

View PostPublic Designs, on 2 Mar, 2009 - 03:07 PM, said:

You need to import the class.
import javax.swing.JTextField;

And then it should run fine once you add it to the frame or panel


Sorry, It's still not working. In Ready To Program what template should I be using for this. Thanks



you can do JOptionPane.showInputDialog("Input Text Here"). but u need to have javax.swing.* Maybe its not what you are looking for, maybe it is. Just my 2 [pennies].

This post has been edited by DR490N5: 02 March 2009 - 04:29 PM

Was This Post Helpful? 0
  • +
  • -

#7 Public Designs  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 145
  • Joined: 08-November 08

Re: How to make a simple textbox in java

Posted 02 March 2009 - 04:47 PM

Can you paste the code you have and post it here so I can see what you are doing? Thanks
Was This Post Helpful? 0
  • +
  • -

#8 BigAnt  Icon User is offline

  • May Your Swords Stay Sharp
  • member icon

Reputation: 101
  • View blog
  • Posts: 2,392
  • Joined: 16-August 08

Re: How to make a simple textbox in java

Posted 02 March 2009 - 04:52 PM

Have you done any GUI coding in Java before?

If not you should look into GUI programming with Java.
Was This Post Helpful? 0
  • +
  • -

#9 webeinater  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 11-February 09

Re: How to make a simple textbox in java

Posted 02 March 2009 - 05:49 PM

View PostBigAnt, on 2 Mar, 2009 - 03:52 PM, said:

Have you done any GUI coding in Java before?

If not you should look into GUI programming with Java.


Here is the code I have so far:
[code]
// The "T" class.
import javax.swing.*;

public class T
{
public static void main (String[] args)
{
// Place your code here
JOptionPane.showInputDialog ("Input Text Here");



} // main method
} // T class
[code/]
It comes up with the text field that I input with but how do I use what I input to the field in a program. I have to be able to print out a row of numbers like this:
1=4
2=5
3=6
4=7
5=8
6=9
7=10
8=11
9=12
10=13
then I want to be able to edit the value on the right(4-13). Is there a way to do this by using the text boxes or any similar easy ways???
Was This Post Helpful? 0
  • +
  • -

#10 Public Designs  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 145
  • Joined: 08-November 08

Re: How to make a simple textbox in java

Posted 02 March 2009 - 05:50 PM

Store the user input as string variables and then use the parseint method to change them into numbers. you can then reassign the values of those variables as needed
Was This Post Helpful? 0
  • +
  • -

#11 webeinater  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 11-February 09

Re: How to make a simple textbox in java

Posted 02 March 2009 - 06:53 PM

View PostPublic Designs, on 2 Mar, 2009 - 04:50 PM, said:

Store the user input as string variables and then use the parseint method to change them into numbers. you can then reassign the values of those variables as needed


Sorry...I'm new to using textboxes in java so how do I take the number inputted into the textboxes and assign it to a number on the left. Just a little side not the left side numbers above(1-10) will actually go from 1-320 when I'm done. Thanks again for all the great help.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1