I learned programming a long time ago when it was all command line, steps 1, 2 , 3 and so on. I am trying to understand the concepts of object oriented programming. I have created a project in Eclipse. There are 3 classes: MainInput, ManipulateText and OutputWindow. What I am trying to do is this:
1) Display the MainInput window (which was created as a swing JDialog).
1-a) Allow user to type text in a box
1- b When user clicks "OK", then go to 2 (below)
2) Manipulate that text (By using class ManipulateText) by adding the words "SPOOKY LETTERS" to the end of the text the user input in 1.
3) Display the OutputWindow (JFrame) with the manipulated text on the display.
I got the MainInput window to display but don't know how to execute the ManipulateText method.
I attached the code for the three and marked up //comments on the trouble spots. Most of the code was generated with Eclipse
Any helpful feedback would be appreciated
This is an self made "tutorial" I am trying to work through to understand how OOP really works.
My end project is to take a "MainInput" window to accept a lot of input
then manipulate that input (mostly math) in separate class objects depending on what the desired output is desired.
Your ManipulateText class needs a method that accepts a String (the user input text), manipulates it and then returns the new value. It shouldn't have knowledge of a GUI component, it shouldn't even care where the String comes from, it's job is just to manipulate text.
BTW why are creating a JDialog to input the text and then a JFrame to display it, this is quite complex for a beginners program. I would start by just having a JFrame with an input and output field and a manipulate button. Pressing the manipulate button would take the input value, manipulate the text and then output the manipulated text. Once you have this working then remove the input field and change the manipulate button to popup a JDialog, get the user input, manipulate it and output it the the output field.