Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamic textfield creation

 
cha kio
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I woold like to ask how can i create dynamicly textfields, and how to handle the content of them after the creation???
i have a variable which says how many textfields i will have.



I have i JFrame,Jbutton and Jpanel created with the netbeans GUI (WITH THE PALLET ).

I need to press the Jbutton and to appear the 10 Jtexfields in the Jpanel, But sometimes maybe will be more than 10 it depends of the counttextfields variable.

I have try something like this but doesn't worked.


Thank you in advanced

ki_ha1984
 
Maneesh Godbole
Saloon Keeper
Posts: 11184
15
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch


Does this even compile? Please PostRealCode (<=This is a link. Click to read)

Whenever you add/remove components from a container which is already being displayed, the best way to refresh the UI is to call a revalidate() and repaint() on the container.
 
cha kio
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok the first and main class is:

JavaAppDemos.java


The secind class is NewJFrame.java (Created by the NETBENAS GUI)


Sorry for the log code but it is created from the netbeans.


 
cha kio
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is thay o want to prees the jbutton and auto add the textfields in the JPanell

Iam PHP programmer and it is very difficult to me to umake something like this.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're new to Java, why are you using the NetBeans visual designer? That's an advanced tool.

Learn Swing coding from the tutorial.
 
cha kio
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i read that Netbeans is very good tool.
I know about this tutorial.
Bu t the problem is that i didnt found something about that i need.
Dynamic variable names and dynamic textfield creation and handling.
I s there any example about those???
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cha kio wrote:i read that Netbeans is very good tool.

If you're referring to the NetBeans visual designer, sure it's a good tool. And like any good tool, it has a fairly steep learning curve.

Learning to use the visual designer effectively is greatly facilitated once you already know how to hand-code a GUI. Trying to learn both Swing coding and the quirks of a visual designer simultaneously, now that I wouldn't recommend.

cha kio wrote:I know about this tutorial.
Bu t the problem is that i didnt found something about that i need.
Dynamic variable names and dynamic textfield creation and handling.

Try going through some other sections of the Oracle tutorial. Like the ones that deal with arrays and collections. Those are more fundamental topics than Swing, so you need to learn them first.

cha kio wrote:I s there any example about those???

One question mark is enough.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cha kio, please BeForthrightWhenCrossPostingToOtherSites <-- link
http://www.java-forums.org/new-java/58087-dynamic-textfield-creation.html
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dynamic variable names? Not a Java feature. Looks to me like you might want to use an array, or something like that.
 
cha kio
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you give me an example of the array that you say?
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even better: here's a link to the part of the Oracle tutorial which covers arrays: Arrays. Java has plenty of good tutorials and they are easy to find on the web. If you're looking for a tutorial about concept X in the Java language then your Google keywords are "java X tutorial". If you see an Oracle tutorial in the list, you should read that one in preference to others which might appear.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic