File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Netbeans and backends? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Netbeans and backends?" Watch "Netbeans and backends?" New topic
Author

Netbeans and backends?

Sam Bluesman
Ranch Hand

Joined: Nov 21, 2004
Posts: 191
Hello.

I have a question concerning netbeans...

I know how to take in a string from a user and process it using code that is placed in the same place as the code for the jframes etc. but does anyone know of a tutorial that can tell me how i can take a string froma JTextfield and pass that to some java class, process it, and pass the result back into the form.

Purely as an example, say a user types in their name and i want to return their name with the letters placed in the order of last to first i.e. i revese the letters in thir name. As oppsed to writing that code in the same class that contains the code for the jTextField, JFrame etc, can i pass the string to an external class that processes the data and passes it back to the main class that allows me represent it in a jLabel or jT3extField?

Get my drift?

Cheers


Moosey knows best
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37936
    
  22
I think I know what you mean. You want to reverse a String.
Try its toCharArray method and Arrays.reverse.
Sam Bluesman
Ranch Hand

Joined: Nov 21, 2004
Posts: 191
Hi there.

Thanks for the response, but I dont really. I want to know how you pass things from the class containing the code for the forms etc to a completely sepate class file that processes it and returns it back to the class contining the form code so that it can be disaplyed in a jTextBox or jLabel in Netbeans
[ April 19, 2007: Message edited by: Sam Bluesman ]
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Originally posted by Sam Bluesman:
Hi there.

Thanks for the response, but I dont really. I want to know how you pass things from the class containing the code for the forms etc to a completely sepate class file that processes it and returns it back to the class contining the form code so that it can be disaplyed in a jTextBox or jLabel in Netbeans.

I think I get your drift, but I'm not sure how this process would be different from non-Swing Java. Your GUI class would utilize the outside class's (let's call it the Logic class) services by instantiating a Logic class object if it's an instance class and then calling this object's methods or by just calling the Logic class's methods if they are static. I imagine you'd do all this in the actionListener of a GUI button.

Sorry if I am oversimplifying the question.

Good luck!
Andrei Pat
Greenhorn

Joined: Apr 19, 2007
Posts: 13
You create a separate class like this:


in your GUI class (where your text field is available):
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
As a very simple example, say I have a JTextPane called jTextPane1 and two buttons on my JFrame. And say that I have a separate java class called LogicClass like so:

Then I can use the LogicClass from within the GUI class like so:
Sam Bluesman
Ranch Hand

Joined: Nov 21, 2004
Posts: 191
Thank you everybody. Much appreciated.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Netbeans and backends?
 
Similar Threads
TextFeild value from DataBase not coming
Custom Password Dialog
display the log/output in JSP or HTML page
Running a client/server apllication
How to bind a JList to a Bean class property