aspose file tools*
The moose likes Beginning Java and the fly likes dynamic swing screen generator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "dynamic swing screen generator" Watch "dynamic swing screen generator" New topic
Author

dynamic swing screen generator

Mindy Wu
Ranch Hand

Joined: Jan 12, 2001
Posts: 121
Hello there,
I am developing a software which can create swing interface dynamically. For example, you can input label name, default value, tooltip, and object type(JButton, JLabel, JComboBox...), then my program can create swing script dynamically. I am stuck, as I don't know how to get the user's input value or selection value upon clicks the command button.
Mindy!
I will appreciate for your reply.
Sean Casey
Ranch Hand

Joined: Dec 16, 2000
Posts: 625
I imagine the program would be running from a gui. If you are using textfields, then when someone enters text use the event handler to get the text with the String getText(). If you are running from a prompt, then use collect the program arguments in args[] and then iterate through args to get what you're looking for. I would need more info though. Your description is a bit vague.
Mindy Wu
Ranch Hand

Joined: Jan 12, 2001
Posts: 121
Thank you sean! Let me explain it in more detail.
My program is quite complicated: my logic is as follow
User input form components into a database table ( label, tooltips, object type...), then I get the record from the table and store them into an array and create a script file (has class, constructor, methods...), then user can just complie the script and create a xx.class. Normally, most swing interface has one or more JTextField and a Execute button.
My question is: I can create an action listener when user click the execute button, however, i have no idea how to create the script to get those value as everything is generated dynamically.
I hope this is clear enough! Let me know as I can show you my script next time!
Thanks a lot for your reply!
Mindy


[This message has been edited by Mindy Wu (edited July 05, 2001).]
Sean Casey
Ranch Hand

Joined: Dec 16, 2000
Posts: 625
Okay, I think I see what you're getting at. So at the end of it all, your program returns a xxx.java file (it can't return a .class file unless you know how to compile files on the fly).
First of all you've come up with an idea and you know what you want to do. I'd take a step back and think of some design issues. My suggestions (this is only my opinion there may be alternatives).
I don't think you need a database. Databases are nice, but in this example it's unecessary. I would use an html-form on the front end and use a servlet on the back end. The form collects the specified data and sends it on to the servlet. The servlet then processes the data and then writes it to disk as a xxx.java file. I believe servlets are the best answer here. I think it would be foolish not to use them. If you're not familiar with them, this is a perfect little project to get acquainted with them. This wouldn't take very long to do with a servlet, and forget about the database. Let me know what you think. I'm sure there are alternatives, and since I've been studying servlets, I may be biased.
- Sean
[This message has been edited by Sean Casey (edited July 05, 2001).]
Mindy Wu
Ranch Hand

Joined: Jan 12, 2001
Posts: 121
Hi Sean, I absoultely agree with your idea, however I have never learned servlet at all. Is it same as JSP(I don't know JSP either)? Can you give a some tutorials links so that I can study it!
Cheers! I really appreciate for your suggestion!
Mindy
[This message has been edited by Mindy Wu (edited July 06, 2001).]
Sean Casey
Ranch Hand

Joined: Dec 16, 2000
Posts: 625
I would go to the Servlet/JSP forum and do a search on servlet resources. You'll find a lot of links. Servlets and JSP are related but yet they are still very different. If you need some more help let me know.
- Sean
Mindy Wu
Ranch Hand

Joined: Jan 12, 2001
Posts: 121
Thank again Sean! I found tons of tutorials in the servlet forum, now i am ready to learn servlet.
You are so nice! Can we make a friend?
Mindy
Sean Casey
Ranch Hand

Joined: Dec 16, 2000
Posts: 625
Glad I could help. We're all friends here at javaranch.

- Sean
Mindy Wu
Ranch Hand

Joined: Jan 12, 2001
Posts: 121
Yeah, we are all Java friends here!
Cheers!
Happy programmer!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: dynamic swing screen generator