• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Dynamic textfield creation

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
cha kio, please BeForthrightWhenCrossPostingToOtherSites <-- link
http://www.java-forums.org/new-java/58087-dynamic-textfield-creation.html
 
Sheriff
Posts: 28407
101
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you give me an example of the array that you say?
 
Paul Clapham
Sheriff
Posts: 28407
101
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic