• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Netbeans and backends?

 
Sam Bluesman
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I know what you mean. You want to reverse a String.
Try its toCharArray method and Arrays.reverse.
 
Sam Bluesman
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You create a separate class like this:


in your GUI class (where your text field is available):
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you everybody. Much appreciated.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic