aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Dynamic textfield creation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Dynamic textfield creation" Watch "Dynamic textfield creation" New topic
Author

Dynamic textfield creation

cha kio
Greenhorn

Joined: Apr 11, 2012
Posts: 5
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

Joined: Jul 26, 2007
Posts: 10523
    
    9

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.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
cha kio
Greenhorn

Joined: Apr 11, 2012
Posts: 5
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

Joined: Apr 11, 2012
Posts: 5
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

Joined: May 03, 2008
Posts: 4658
    
    5

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.


luck, db
There are no new questions, but there may be new answers.
cha kio
Greenhorn

Joined: Apr 11, 2012
Posts: 5
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

Joined: May 03, 2008
Posts: 4658
    
    5

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

Joined: May 03, 2008
Posts: 4658
    
    5

cha kio, please BeForthrightWhenCrossPostingToOtherSites <-- link
http://www.java-forums.org/new-java/58087-dynamic-textfield-creation.html
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

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

Joined: Apr 11, 2012
Posts: 5
can you give me an example of the array that you say?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dynamic textfield creation