I'm surprised that is of interest. If I cover the topic I'll start at the bottom with JSP and work my way up to cover everything. I'm getting good at posting regularly again and so should be able to blast through this topic. I'll hold a vote soon
I don't know? I have kind of promised to cover OpenGL and Android games. People didn't seem to be too interested in my last game tutorial though. I think people don't understand the math and just give up? I'll be making that decision soon. UML will be followed by refactoring because nobody covers it and it is a perfect bind between design patterns and UML. They'll be pretty quick. Maybe I'll hold another vote after that?
Love your videos. I think that You shouldn't fuzz design pattern with Swing components though. It makes pattern harder to understand. Leave it for java specific tutorials :)
You could encrypt the information easily. There are numerous obfuscation techniques that you could use that would make the data very hard to change. You would have to save it some place though for later use.
Thank you :) I did make an objective c tutorial years ago, but I was forced to take part of it down because I made a game that was out there already. I'm making android videos next and it will be a very long tutorial
I did that already :) Look at Java Video Tutorial 44, 45 and 46 If I had more time to make videos, I think I could cover any subject. I've spent my whole life learning new topics so it is fun for me. Maybe some day I'll be able to turn this hobby into a job
I don't know about subclassing another JComponent. I think I'd just paint everything from scratch. That way you can make it look however you want. If you use JComponents to much they will look completely different on every machine. I'm planning on covering Java 2D maybe depending on how voting goes next week.
What's the problem then? Watch the part that is related to the pattern, then you can simply skip and that JElements stuff and watch how the program works :)
I want all of you guys to know I take your requests very seriously. I wouldn't have made a tutorial destined to never get views like Design Patterns if I didn't :) One thing I can't do though is bounce between tutorials. It is too hard for me to organize. If you all decide I should cover J2EE instead of games / Android I will. I'll have a vote very soon to make the final decision
I don't mean anything you said sounds like manipulation, I mean I think that is the only way to cut through manipulation that has forced them to turn a blind eye from reality. Look at the Ayn Rand books as an example. They convinced people through story telling to create a political movement beyond anything she probably could have ever imagined. Through stories you can convince people. People are blind to facts and arguing. You can only sneak in and persuade them through storytelling often
I see where you are coming from. I used to think a lot about political problems. I guess I lost heart? I have never been very political. I prefer to help people in ways that I know we all can. I teach poor kids for free. I give food to food banks. I can list a bunch of things each and every person could do tomorrow and make a positive impact. I'm sure you can as well. I think a story must be written to break through the barriers in peoples minds. I'm not up to manipulate people now though
This sounds like something that would just be handled by painting what looks like components in a paint window. Then you'll have to simulate button clicking or whatever by capturing where the user clicks. You'll have to throw your own exceptions for those mouse clicks to react to the user
I'm sorry, but I can't do that. I had a lot of trouble when I allowed people to download them. I had a guy selling my videos. If you look into it, you can still find a way to download them. Why not watch them on UA-cam for free? I almost never even use preroll ads
Yes Derek, I really appreciate your dedication towards the online community..I understand that it will be very difficult for you to manage it, if you go by request of every individual.. :).. voting out is definitely a good option :).. I will benefit everyone :) Thanks once again .. God Bless You..
1, 2, 3, 4 undo, undo -> 2 add 5, what user sees -> 1, 2, 5, there is no redo because you are at the newest but in your code, add 5 -> 1, 2, 3, 4, 5, redo get you 3 I think it's the design problem, maybe there should be a stack in which you delete / undo, and another list, they are synced when you add more nodes.
Yes I thought for this exacty. To solve this problem you soud use a stack for redo also (or use index as in the example), and if any new momento was added to the history, then you should clear the redo stack (or delete every memento from the array after the index.)
Dear Mr Derek Banas, I still cannot understand this checking statement (saveFiles - 1) > currentArticle Q1: what if it just (saveFiles ) > currentArticle will anything happen catastrophically ? Q2: what is the relationship between saveFiles and currentArticle anyway ? Is this some type of two pointer techniqe ?
for example I have a text area in my JFrame and when i press save then the text in the text area is saved somewhere but, I dont want a user to just be able to change that text by opening a file it was saved in. or could this even be done without the need of files? so you still have that info when you restart the program
Thanks So much for the Video, and you really can make videos on any topics. Did u consider iOS & Objective -C videos I've started learning and you are the first that come to my mind.but I couldn't find any videos for you regarding iOS programming.
I got the font thing to work. Anyways I have a a question. If i have a JComponent class and I add it to my JFrame and I have another JComponent class and add it to the JFrame how could I make the one on the top transparent so everything I made in the first one would be still visible but if i had something in the second one it would be visible too?
Hmm, I'm not sure you understood me. This is what I meant. I have a class that extends JComponent and it has a method paint() obviously. I have painted some strings and shapes on it. I have added it to my JFrame. Now what I'm trying to do is add another class that extends JComponent and has a method paint obviously, and put it ontop of the other one I have, but when I do it overlays the other one. How could I fix it? If I put anything in it I still want it to show up though. Is this possible?
That is terrible beyond words. I don't really know what to say. I just know that at times we seem to run out of options. There is such an amazing world out there though and so many things to see and do. For most of my life I've been lucky to see the amazing things and I just want to see more. The worst case scenario is that you have to live out in the woods all alone and live off of the land. Not so many years ago that is what most people did. My great grandparents did
I'm sorry, but I haven't been in Walmart for over 10 years. I have no idea what their checkout looks like. I'm guessing it was programmed in C++ because that is probably what I'd use.
Not exactly. I'm creating a game and I'm on the menu part and I have a JComponent class for the menu graphics where it draws the menu and I want a seperate JComponent class for the Dialogs. So what I'm trying to do is have my menu drawn by one class and then draw all my dialogs/confirm boxes drawn by another class and the dialog class is above the menu class and just displays all the dialogs
Could you show me how to import fonts into your program. This is what I've tried: Font font = null; try { graphicsEnvironment.registerFont(Font.createFont(Font.TRUE_TYPE_FONT, new File("./res/fonts/urban.ttf"))); } catch(Exception e){ e.printStackTrace(); } font = new Font("Urban Sketch", Font.PLAIN, 30); when I used the graphicsEnv it showed my font but when i did g.drawString("test", 50, 50); it showed nothing but it normally did show the font and i also did do g.setFont(font);
sure, but you didnt show us how to add our own fonts. I looked it up and the code above is what i got and i impoerted the font but when i draw my string it will not show up when i have my font set to my custom font
Hmm, I'm thinking of how would they save it like minecraft worlds are saved in .dat files some games i'm not even sure they have external files for that. Just wondering how would you save a piece of info but not letting a user to simply change it
just getting into Design Patterns ..and i love your videos Derek !! ,although i am from an C# background ..in the Memento pattern example , noticed a lot of "if" statements, "if" statements usually point to a need for another design pattern (?)..usually..sometimes ...do correct the statement , i am kind of a newbie to Design Patterns
I am actually one of the people that talks to the Jehovah Witness when they come by. I'm always open to talk to anyone. I don't know very much about the religion though and have never attended any services there. I'm sorry if your experience there was so bad. That is a shame
What if you want to save the state of multiple objects of multiple classes with multiple relations, instead of a simple class with a simple string attribute?
No matter what type of file you are trying to save, you basically have to put all the information into a string and write it into a hard drive. Say in minecraft probably the block id and location is saved and then the entire thing is compressed and encrypted. Then the unreadable string is saved with a ".dat" extension
What is the purpose of the Memento class? It just stores a simple string. So why don't you use a String object and leave out the Memento class entirely?
It's just an example... A memento can be a way bigger and more complicated class. I bet it can be even abstracted out into a family of classes you would want to remember.
Thoughts going into the video...I used the state pattern for my current Android project and I realize just how much code duplication I have... I wonder if this will help
Thank you! As always very understandable. But i am a little bit confused when I think about Memento and Command pattern. What is the difference in terms of undo/redo?
Memento is the true undo/redo - it stores the state of the originator, like snapshots. We can actually do time travels back or forth to any time if there's a snapshot available. Command's undo though is just a counter action of the last step, it can be useful when the states are deterministic and can be implemented with a state machine (see state pattern), eg. an ON-OFF switch and so on - the opposite of turnOn() is for sure turnOff(). If we have complex or infinite possible previous states, we will need to use true snapshots like Memento, eg. a String altered by a setter, we can't simply undo the changes if we don't know what exactly the counter action is.
wow, what a voice, is it your real one, or do you use any kind of mic app ? by the way, thanks for the tutorial, I hate java and patterns, but I have to do some for my diploma, without you, I was so dead !
Hi Derek, as usual this is very useful and so well explained!!! I just noticed that when I tried to make it executable using your video "MAKE JAVA FILES EXECUTABLE" no 88 it won’t work... I also tried with few other exercises and it's the same unlucky result. Will you explain how to complete this please? Many thanks in advance and take care.
I don't see why using Editor and Snapshot (EditorState) classes are helpful. If we want to add or undo changes, then why not have a History class to store the state history in a Stack or a List? Why bring up other classes like Editor class or Snapshot class? public class History { private Stack states = new Stack(); public void push(T item) { states.push(); } public T pop() { return states.pop(); } }
I am just all the tutorials quickly cause I am curious, but I think you should of done your java tutorials with this style, like the presentation thing at the begening
Well, you don't need mode. This one is pretty simple, it just saves an object. And you can even use an array, to save different versions of the object.
I'm surprised that is of interest. If I cover the topic I'll start at the bottom with JSP and work my way up to cover everything. I'm getting good at posting regularly again and so should be able to blast through this topic. I'll hold a vote soon
I don't know? I have kind of promised to cover OpenGL and Android games. People didn't seem to be too interested in my last game tutorial though. I think people don't understand the math and just give up? I'll be making that decision soon. UML will be followed by refactoring because nobody covers it and it is a perfect bind between design patterns and UML. They'll be pretty quick. Maybe I'll hold another vote after that?
Derek Banas sir please focus on j2ee
Love your videos.
I think that You shouldn't fuzz design pattern with Swing components though. It makes pattern harder to understand. Leave it for java specific tutorials :)
You could encrypt the information easily. There are numerous obfuscation techniques that you could use that would make the data very hard to change. You would have to save it some place though for later use.
Yes you are correct. I cover how to eliminate the if statements in the refactoring tutorials
Thank you :) I did make an objective c tutorial years ago, but I was forced to take part of it down because I made a game that was out there already. I'm making android videos next and it will be a very long tutorial
I did that already :) Look at Java Video Tutorial 44, 45 and 46
If I had more time to make videos, I think I could cover any subject. I've spent my whole life learning new topics so it is fun for me. Maybe some day I'll be able to turn this hobby into a job
have you done it?
Lol you've 100% achieved that goal now hahaha
I don't know about subclassing another JComponent. I think I'd just paint everything from scratch. That way you can make it look however you want. If you use JComponents to much they will look completely different on every machine. I'm planning on covering Java 2D maybe depending on how voting goes next week.
Why ? why all these swings and JElements ? :( I just try to understand pattern :|
What's the problem then? Watch the part that is related to the pattern, then you can simply skip and that JElements stuff and watch how the program works :)
swing library is strongly connected with memento pattern.
The pattern is all there. You don't have to know how to use Swing, but using it is just a prettier way to visualize it.
Tottaly agree, but then the video will be less than 10 min which is not profitable for the you-tuber
I want all of you guys to know I take your requests very seriously. I wouldn't have made a tutorial destined to never get views like Design Patterns if I didn't :) One thing I can't do though is bounce between tutorials. It is too hard for me to organize. If you all decide I should cover J2EE instead of games / Android I will. I'll have a vote very soon to make the final decision
I don't mean anything you said sounds like manipulation, I mean I think that is the only way to cut through manipulation that has forced them to turn a blind eye from reality. Look at the Ayn Rand books as an example. They convinced people through story telling to create a political movement beyond anything she probably could have ever imagined. Through stories you can convince people. People are blind to facts and arguing. You can only sneak in and persuade them through storytelling often
On the harddrive I would suppose. It just takes a few lines of code to store that information. Maybe I'm not understanding the question?
thanks. lk u know walmart self service checkouts??what did they use to create the GUI?
I see where you are coming from. I used to think a lot about political problems. I guess I lost heart? I have never been very political. I prefer to help people in ways that I know we all can. I teach poor kids for free. I give food to food banks. I can list a bunch of things each and every person could do tomorrow and make a positive impact. I'm sure you can as well. I think a story must be written to break through the barriers in peoples minds. I'm not up to manipulate people now though
Ich bin dankbar, dass Sie meine Videos sehen. Danke
This sounds like something that would just be handled by painting what looks like components in a paint window. Then you'll have to simulate button clicking or whatever by capturing where the user clicks. You'll have to throw your own exceptions for those mouse clicks to react to the user
For GUI development I use Swing and the Standard Widget Toolkit
Are you trying to implement a layers system like Photoshop has?
is that the best API for GUI?
Спасибо. Я очень рада, что вам понравилось :)
Thank you very much :) There are ways to download the videos and a quick search will provide the answer
I'm sorry, but I can't do that. I had a lot of trouble when I allowed people to download them. I had a guy selling my videos. If you look into it, you can still find a way to download them. Why not watch them on UA-cam for free? I almost never even use preroll ads
lol I never been to Walmart.
Why would u use C++ instead of Java Derek?
You never know when I'll upload a video :) I'll try to finish this tutorial tomorrow!
Then UML 2.0 is next
Yes Derek, I really appreciate your dedication towards the online community..I understand that it will be very difficult for you to manage it, if you go by request of every individual.. :).. voting out is definitely a good option :).. I will benefit everyone :)
Thanks once again ..
God Bless You..
1, 2, 3, 4
undo, undo -> 2
add 5, what user sees -> 1, 2, 5, there is no redo because you are at the newest
but in your code, add 5 -> 1, 2, 3, 4, 5, redo get you 3
I think it's the design problem, maybe there should be a stack in which you delete / undo, and another list, they are synced when you add more nodes.
Yes I thought for this exacty. To solve this problem you soud use a stack for redo also (or use index as in the example), and if any new momento was added to the history, then you should clear the redo stack (or delete every memento from the array after the index.)
Speed is the only reason. C++ is extremely fast in comparison to Java. I use C for hardware / electronics related projects.
I find it weird that the restoreMemento method would return an attribute instead of an Originator object (with the updated attribute)
Dear Mr Derek Banas,
I still cannot understand this checking statement
(saveFiles - 1) > currentArticle
Q1: what if it just (saveFiles ) > currentArticle will anything happen catastrophically ?
Q2: what is the relationship between saveFiles and currentArticle anyway ? Is this some type of two pointer techniqe ?
Yes Chief , webservices like SOAP / REST and Struts 2 would be Godsend.
You can pretty much watch them in any order.
You're very welcome :) Ill cover JavaFX ASAP.
In this tutorial I showed how to gray out components undoBut.setEnabled(false)
lovely presentation of Memento design pattern !
Thank you :)
for example I have a text area in my JFrame and when i press save then the text in the text area is saved somewhere but, I dont want a user to just be able to change that text by opening a file it was saved in. or could this even be done without the need of files? so you still have that info when you restart the program
Thanks So much for the Video, and you really can make videos on any topics.
Did u consider iOS & Objective -C videos
I've started learning and you are the first that come to my mind.but I couldn't find any videos for you regarding iOS programming.
I got the font thing to work. Anyways I have a a question. If i have a JComponent class and I add it to my JFrame and I have another JComponent class and add it to the JFrame how could I make the one on the top transparent so everything I made in the first one would be still visible but if i had something in the second one it would be visible too?
Hmm, I'm not sure you understood me. This is what I meant.
I have a class that extends JComponent and it has a method paint() obviously. I have painted some strings and shapes on it. I have added it to my JFrame. Now what I'm trying to do is add another class that extends JComponent and has a method paint obviously, and put it ontop of the other one I have, but when I do it overlays the other one. How could I fix it? If I put anything in it I still want it to show up though. Is this possible?
Nice tutorial.
Quick question.
You know games like Call of Duty etc. Any Games, how do they save the players profile and where would they save it?
That is terrible beyond words. I don't really know what to say. I just know that at times we seem to run out of options. There is such an amazing world out there though and so many things to see and do. For most of my life I've been lucky to see the amazing things and I just want to see more. The worst case scenario is that you have to live out in the woods all alone and live off of the land. Not so many years ago that is what most people did. My great grandparents did
I'm sorry, but I haven't been in Walmart for over 10 years. I have no idea what their checkout looks like. I'm guessing it was programmed in C++ because that is probably what I'd use.
Will Hello internet and welcome here if your lecturer can't explain this to you
That's funny :)
Not exactly. I'm creating a game and I'm on the menu part and I have a JComponent class for the menu graphics where it draws the menu and I want a seperate JComponent class for the Dialogs. So what I'm trying to do is have my menu drawn by one class and then draw all my dialogs/confirm boxes drawn by another class and the dialog class is above the menu class and just displays all the dialogs
Spring and Hibernate after UML?
Could you show me how to import fonts into your program.
This is what I've tried:
Font font = null;
try {
graphicsEnvironment.registerFont(Font.createFont(Font.TRUE_TYPE_FONT, new File("./res/fonts/urban.ttf")));
} catch(Exception e){ e.printStackTrace(); }
font = new Font("Urban Sketch", Font.PLAIN, 30);
when I used the graphicsEnv it showed my font but when i did g.drawString("test", 50, 50); it showed nothing but it normally did show the font and i also did do g.setFont(font);
sure, but you didnt show us how to add our own fonts. I looked it up and the code above is what i got and i impoerted the font but when i draw my string it will not show up when i have my font set to my custom font
Hmm, I'm thinking of how would they save it like minecraft worlds are saved in .dat files some games i'm not even sure they have external files for that. Just wondering how would you save a piece of info but not letting a user to simply change it
just getting into Design Patterns ..and i love your videos Derek !! ,although i am from an C# background
..in the Memento pattern example , noticed a lot of "if" statements, "if" statements usually point to a need for another design pattern (?)..usually..sometimes ...do correct the statement , i am kind of a newbie to Design Patterns
I am actually one of the people that talks to the Jehovah Witness when they come by. I'm always open to talk to anyone. I don't know very much about the religion though and have never attended any services there. I'm sorry if your experience there was so bad. That is a shame
Continuation of the last Comments...
FYI I'm not talking bout the default java dialogs. I'm talking bout me drawing my own dialogs.
Thank you for clarifying Derek - i will check out the refactoring tutorials..
I thought I covered fonts previously? I'll have to go look back at my old tutorials
Clear and clean, THANK YOU VERY MUCH.
I'm happy it helped :)
What if you want to save the state of multiple objects of multiple classes with multiple relations, instead of a simple class with a simple string attribute?
Use a dictionary or hashmap or things like that to store all the states in one place ;)
No matter what type of file you are trying to save, you basically have to put all the information into a string and write it into a hard drive.
Say in minecraft probably the block id and location is saved and then the entire thing is compressed and encrypted. Then the unreadable string is saved with a ".dat" extension
Derek, ты супер!!! Твои видео просто невероятно полезны!!!
What is the purpose of the Memento class?
It just stores a simple string. So why don't you use a String object and leave out the Memento class entirely?
It's just an example... A memento can be a way bigger and more complicated class. I bet it can be even abstracted out into a family of classes you would want to remember.
Thoughts going into the video...I used the state pattern for my current Android project and I realize just how much code duplication I have... I wonder if this will help
Happy I could help :) It is amazing how useful design patterns can be
Thank you! As always very understandable. But i am a little bit confused when I think about Memento and Command pattern. What is the difference in terms of undo/redo?
Memento is the true undo/redo - it stores the state of the originator, like snapshots. We can actually do time travels back or forth to any time if there's a snapshot available.
Command's undo though is just a counter action of the last step, it can be useful when the states are deterministic and can be implemented with a state machine (see state pattern), eg. an ON-OFF switch and so on - the opposite of turnOn() is for sure turnOff(). If we have complex or infinite possible previous states, we will need to use true snapshots like Memento, eg. a String altered by a setter, we can't simply undo the changes if we don't know what exactly the counter action is.
im understanding all that and also there is going to be key navigation. But my main question is that thing i told you possible? If yes, how?
wow, what a voice, is it your real one, or do you use any kind of mic app ?
by the way, thanks for the tutorial, I hate java and patterns, but I have to do some for my diploma, without you, I was so dead !
Thank you :) Yes that is my normal voice and no I don't edit it in any way
Hi Derek, as usual this is very useful and so well explained!!! I just noticed that when I tried to make it executable using your video "MAKE JAVA FILES EXECUTABLE" no 88 it won’t work... I also tried with few other exercises and it's the same unlucky result. Will you explain how to complete this please? Many thanks in advance and take care.
Very well done.
Wondering, if this was a video game could it be used to save game state to a file?
Thank you :) Yes I tend to use patterns in general to help model out virtual worlds like games.
Wow thanks again Sir Derek. Please make some tutorials for JavaFX. I would like to learn GUI programming
I don't see why using Editor and Snapshot (EditorState) classes are helpful. If we want to add or undo changes, then why not have a History class to store the state history in a Stack or a List? Why bring up other classes like Editor class or Snapshot class?
public class History
{
private Stack states = new Stack();
public void push(T item)
{
states.push();
}
public T pop()
{
return states.pop();
}
}
is one expected to follow these as presented here or you can watch in any order you like
this is simply awsome
Thank you very much :)
Very nice!!!
Happy I could help :)
I am looking Spring and Hibernate..Please do some tutorials if you find some free time ...Thanks in advance :)
when i said it normally did show the font i meant the text, it normally did show the text
You really can do any tutorial?! Maybe you can make tutorial about working with xml in java? :3
I am just all the tutorials quickly cause I am curious, but I think you should of done your java tutorials with this style, like the presentation thing at the begening
hey you re tuto are great, but can we get the source code pliize?
+ibn mrabet achraf Thank you :) Here is the source code www.newthinktank.com/2012/10/memento-design-pattern-tutorial/
you are the best
You are very kind :) I'm happy to help
I have to say that the all the swings stuff are reduntent...
Serienmäßig dankbar für diese Anstrengung. Mehr Leistung für Sie.
Keine Medaille für mich wieder traurig.
awesome! :)
Thank you :)
Well....I vote for Java EE! :)
....because I watch this so late. :)
J2EE would be awesome.
use stack
coool example
Thank you :)
My hair is getting fewer...
Not the best example.
1 minute for memento, 19 minutes for java stuff, really?
Well, you don't need mode. This one is pretty simple, it just saves an object. And you can even use an array, to save different versions of the object.
@@KublaiKhan2025 you probably replied to a wrong comment!