1 00:00:00,000 --> 00:00:10,000 [intro music] 2 00:00:10,000 --> 00:00:14,000 This presentation is delivered by the Stanford Center for Professional Development. 3 00:00:22,000 --> 00:00:26,000 It's time to delve into a continuation of our last great topic. Okay? 4 00:00:26,000 --> 00:00:30,000 So, it's time to continue a bit with our friend the "interactor". 5 00:00:30,000 --> 00:00:34,000 And if we think about the interactor, an action listener...so last time we talked about 6 00:00:34,000 --> 00:00:38,000 having buttons and buttons-generated action events. Remember that? 7 00:00:38,000 --> 00:00:41,000 So we're going to do a brief review of that and push it a little bit further. 8 00:00:41,000 --> 00:00:46,000 So one of things we talked about is: how in your program, say, in your init method 9 00:00:46,000 --> 00:00:50,000 somewhere you might have "public void init ()" 10 00:00:51,000 --> 00:00:54,000 and inside here you would set up sort of the 11 00:00:54,000 --> 00:00:57,000 parts of your program that you want to actually do something, like, the various 12 00:00:57,000 --> 00:01:00,000 interactors so that when someone clicks on them something happens 13 00:01:00,000 --> 00:01:07,000 and then you would say, "add ActionListeners". And what this would do 14 00:01:07,000 --> 00:01:10,000 is basically say,"Hey I got some buttons in my program, 15 00:01:10,000 --> 00:01:14,000 I want you to be listening for buttons so when someone clicks on a button, I want you to call 16 00:01:14,000 --> 00:01:17,000 a particular method for me called 'ActionPerformed' 17 00:01:17,000 --> 00:01:20,000 and then based on when you call ActionPerformed, I'll figure out what button was clicked 18 00:01:20,000 --> 00:01:23,000 and then actually do something." Okay? 19 00:01:23,000 --> 00:01:25,000 So, over here we had our friend 20 00:01:25,000 --> 00:01:29,000 "public void ActionPerformed" 21 00:01:29,000 --> 00:01:37,000 And "ActionPerformed" would get as its parameter something called an "ActionEvent". 22 00:01:37,000 --> 00:01:41,000 And an ActionEvent (we'd just refer to it as "e"), 23 00:01:41,000 --> 00:01:43,000 was basically what it would check to see 24 00:01:43,000 --> 00:01:47,000 what action was actually taken or basically which button was actually clicked. Okay? 25 00:01:47,000 --> 00:01:51,000 So hopefully you remember that. That's a little bit of review from last time. 26 00:01:51,000 --> 00:01:53,000 Now, when we got this action event we said there are a couple things you could do with it. 27 00:01:54,000 --> 00:01:58,000 Well, there is actually one main thing we talked about which you could do with it 28 00:01:58,000 --> 00:02:02,000 and you could figure out which command was actually the thing that caused this action event 29 00:02:02,000 --> 00:02:05,000 to be generated by saying, "Hey, you know what i want to do?" 30 00:02:05,000 --> 00:02:09,000 I wanna pull out as a string (and I'll just call it 'cmd' for 'command') 31 00:02:09,000 --> 00:02:12,000 the command, or, the name of the interactor 32 00:02:12,000 --> 00:02:15,000 that caused this ActionPerformed method to be called." So here I would say 33 00:02:15,000 --> 00:02:17,000 e dot 34 00:02:17,000 --> 00:02:19,000 command equals e dot 35 00:02:19,000 --> 00:02:22,000 getActionCommand 36 00:02:22,000 --> 00:02:25,000 and what GetActionCommand does...it's just a method 37 00:02:25,000 --> 00:02:30,000 of this ActionEvent that says,"Hey, I'll return to you the name of the interactor as a string 38 00:02:30,000 --> 00:02:33,000 and buttons' names are basically just whatever displays on the button. 39 00:02:33,000 --> 00:02:38,000 So then I could have some ifs in here based on this command, "if command dot equals" 40 00:02:38,000 --> 00:02:40,000 and I can check for some name, then I might wanna take some action based on that button. 41 00:02:42,000 --> 00:02:45,000 It turns out there something else you can ask this ActionEvent e for 42 00:02:45,000 --> 00:02:47,000 other than the action command 43 00:02:47,000 --> 00:02:50,000 you saw this very briefly last time in the program that we did and you're going to see it a little bit more now, 44 00:02:50,000 --> 00:02:54,000 so i want to spend a little bit more time on it 45 00:02:54,000 --> 00:02:56,000 which is something where you can say, "Hey e, 46 00:02:56,000 --> 00:03:02,000 what i want to get from you is not the action command, I want to get the source of the action." 47 00:03:02,000 --> 00:03:07,000 Now the interesting thing about what "getSource" returns to you...actually let me not put the semicolon 48 00:03:07,000 --> 00:03:09,000 here right now... 49 00:03:09,000 --> 00:03:12,000 is getSource actually returns to you an object. 50 00:03:12,000 --> 00:03:17,000 It returns to you the object that caused this event to be generated, which means if a button was clicked 51 00:03:19,000 --> 00:03:22,000 e.getActionCommand will get the name of the button 52 00:03:22,000 --> 00:03:27,000 e.getSource will actually give you a reference to the button object. 53 00:03:27,000 --> 00:03:31,000 So what you're getting back from this is an object. You're getting a reference to that object. 54 00:03:31,000 --> 00:03:34,000 So, what does that mean for you in, sort of, your everyday life? 55 00:03:34,000 --> 00:03:37,000 What that means is: over here when you want to set up your initialization 56 00:03:37,000 --> 00:03:40,000 You could say, "Hey I want to create a button." 57 00:03:40,000 --> 00:03:42,000 And so i'll have some button i want to create 58 00:03:42,000 --> 00:03:45,000 so I'll say "new JButton" 59 00:03:46,000 --> 00:03:49,000 and maybe that button, i want it to say "Hi" on it 60 00:03:49,000 --> 00:03:54,000 And so one thing I can do is I could say, "hi = new JButton"and "hi" 61 00:03:54,000 --> 00:03:58,000 what I'm going to do is make that an instance variable 62 00:03:58,000 --> 00:04:03,000 so somewhere down here in my program where I have my ivars, my instance variables, 63 00:04:03,000 --> 00:04:11,000 i would have "private JButton hi;" So I just do the declaration of a variable called "Hi" 64 00:04:11,000 --> 00:04:13,000 which is of type JButton and then in my initialization method 65 00:04:13,000 --> 00:04:17,000 i actually create that button with the label "Hi" on it 66 00:04:17,000 --> 00:04:20,000 and then i go ahead and add it somewhere to 67 00:04:20,000 --> 00:04:25,000 one of the control bars in my programs. So I would say, "add 'hi' maybe to the SOUTH control bar" 68 00:04:25,000 --> 00:04:27,000 because we really like adding things to the SOUTH control bar 69 00:04:27,000 --> 00:04:30,000 It's just fun when buttons show up on the bottom of our screen. 70 00:04:30,000 --> 00:04:33,000 So we say, "Add it there" and then wait for something to happen. 71 00:04:33,000 --> 00:04:35,000 So add my action listener in case this button gets clicked. 72 00:04:35,000 --> 00:04:37,000 Now when the button gets clicked over here, 73 00:04:37,000 --> 00:04:40,000 what i can do 74 00:04:40,000 --> 00:04:41,000 as i could actually 75 00:04:41,000 --> 00:04:47,000 ask command to get its name. Right? Or I could ask the action event to get the action command name 76 00:04:47,000 --> 00:04:52,000 and then i could say something like," if (cmd.equals " 77 00:04:52,000 --> 00:04:56,000 and the name of the particular button that i created over there happens to be ("Hi"). If it happens to be "Hi" 78 00:04:57,000 --> 00:05:02,000 then there's something i want to do, like maybe i'd want to print something on the screen or whatever the case may be. 79 00:05:03,000 --> 00:05:04,000 That's one way i could write this 80 00:05:04,000 --> 00:05:07,000 and this is kind of the classic way that you've seen it written before. 81 00:05:07,000 --> 00:05:09,000 Okay? That's the way you saw it last time. 82 00:05:09,000 --> 00:05:14,000 The other way i can write it with my friend "get source" is: rather than getting the name of the command 83 00:05:14,000 --> 00:05:16,000 and checking to see if the command is equal to ("Hi") 84 00:05:16,000 --> 00:05:21,000 i can actually say, "Hey, you know what? Mehran told me about this thing called e.getSource 85 00:05:21,000 --> 00:05:24,000 as a matter of fact i don't even need this line for command 86 00:05:24,000 --> 00:05:27,000 anymore let me just comment it out so I don't erase it, okay? 87 00:05:27,000 --> 00:05:33,000 And I can say, " if (e.getSource ... this returns an object to me 88 00:05:33,000 --> 00:05:38,000 i want to check to see if that object that it returns is my ("Hi") button 89 00:05:38,000 --> 00:05:44,000 so here i check directly, is it equal equal to "hi" and then I do whatever I was going to do 90 00:05:44,000 --> 00:05:48,000 so this has exactly the same effect as before. It's checking to see if I've gotten a button 91 00:05:48,000 --> 00:05:52,000 that is the "Hi" button that was clicked. Okay? 92 00:05:52,000 --> 00:05:56,000 so the difference between these two things if you kind of think about them, right?, one of them is 93 00:05:56,000 --> 00:06:01,000 i'm just using the name is a string and the other ones i'm using the actual object 94 00:06:01,000 --> 00:06:07,000 Now if you think about more deeply what that means if i think about the name over here, right? 95 00:06:07,000 --> 00:06:12,000 If i think just in terms of the name i never need to be able to refer to the actual object 96 00:06:12,000 --> 00:06:15,000 which means that if i don't need to refer to the actual object again over here 97 00:06:15,000 --> 00:06:20,000 I don't necessarily need it as an instance variable. I only need it as an instance variable if I'm going to refer 98 00:06:20,000 --> 00:06:24,000 to it again in someplace that's in a different method 99 00:06:24,000 --> 00:06:26,000 that's some other method i may have already used it in. 100 00:06:26,000 --> 00:06:31,000 So let me show you an example of what i mean by that in code to make that more concrete. 101 00:06:31,000 --> 00:06:33,000 Okay, so if we come over here to code 102 00:06:33,000 --> 00:06:35,000 here's essentially the code i just wrote 103 00:06:35,000 --> 00:06:39,000 for basically creating a button so it's just the code i wrote on the board, right? 104 00:06:39,000 --> 00:06:43,000 except I just made the font bigger. i create a button with the name "hi" 105 00:06:43,000 --> 00:06:47,000 i put in the southern region. I add my action listeners to listen for that button getting clicked. 106 00:06:47,000 --> 00:06:52,000 When the button gets clicked I say, "Hey. Is the thing that got clicked this button I created?" 107 00:06:52,000 --> 00:06:54,000 Here i actually called it HiButton. 108 00:06:54,000 --> 00:06:57,000 instead of just "hi" over there. I shortened it to "hi" so it would take up less board space. 109 00:06:57,000 --> 00:07:02,000 if it's actually the source of that action is not have my high but not all 110 00:07:02,000 --> 00:07:04,000 will print out below them 111 00:07:04,000 --> 00:07:07,000 so i can go ahead and run this program 112 00:07:07,000 --> 00:07:13,000 and if i run this program this is now i click on get the same thing i saw the four everytime i click on a get 113 00:07:13,000 --> 00:07:14,000 hello there 114 00:07:14,000 --> 00:07:17,000 now alternatively i could have written some slightly differently which is the 115 00:07:17,000 --> 00:07:18,000 way you saw a blast time 116 00:07:18,000 --> 00:07:21,000 what i can do here as i can say hey 117 00:07:21,000 --> 00:07:25,000 when i'm going to do the added just go ahead and create that button and add it 118 00:07:25,000 --> 00:07:29,000 all in one line because i don't need to have some variables it stores the button 119 00:07:29,000 --> 00:07:35,000 because down here i'd i need to check for the source of 120 00:07:35,000 --> 00:07:35,000 what that action and that was 121 00:07:35,000 --> 00:07:37,000 i'm going to have a safe action event 122 00:07:37,000 --> 00:07:39,000 give me your command 123 00:07:39,000 --> 00:07:41,000 and the command is going to be the name of the button 124 00:07:41,000 --> 00:07:45,000 so i no longer need a variable to actually store a reference to the actual 125 00:07:45,000 --> 00:07:47,000 button object 126 00:07:47,000 --> 00:07:51,000 because this is going to give me the name whenever i needed and so as a 127 00:07:51,000 --> 00:07:53,000 result notice your i don't have an instance variable 128 00:07:53,000 --> 00:07:56,000 so this is one of those things that's a trade-off it also should give you a 129 00:07:56,000 --> 00:07:59,000 little bit more insight into when you have instance variables were so when you 130 00:07:59,000 --> 00:08:00,000 don't have instance variables 131 00:08:00,000 --> 00:08:02,000 you need to have the instance variable 132 00:08:02,000 --> 00:08:08,000 in the case 133 00:08:08,000 --> 00:08:11,000 where you need to have 134 00:08:11,000 --> 00:08:12,000 and i want the new one 135 00:08:12,000 --> 00:08:13,000 you want the instance variable in the case where 136 00:08:13,000 --> 00:08:15,000 you want to be able to refer to this variable 137 00:08:15,000 --> 00:08:17,000 in some method 138 00:08:17,000 --> 00:08:21,000 it's different then perhaps the method which got created right so i created i 139 00:08:21,000 --> 00:08:23,000 created the button over here and start somewhere 140 00:08:23,000 --> 00:08:26,000 but i need to be able to refer to and some other method so it's got to be an 141 00:08:26,000 --> 00:08:27,000 instance variable 142 00:08:27,000 --> 00:08:34,000 if i don't need to refer to any other method which is what i saw on the second 143 00:08:34,000 --> 00:08:35,000 place 144 00:08:35,000 --> 00:08:36,000 i don't need to report would again here is a matter fact there's no other place 145 00:08:36,000 --> 00:08:41,000 i need to refer to it after i created then i don't need distorting 146 00:08:41,000 --> 00:08:52,000 and questions about her 147 00:08:52,000 --> 00:08:57,000 was so that's about the neurological at the computer shouldn't try to figure out 148 00:08:57,000 --> 00:08:59,000 which one could if you give it to bond with the same name 149 00:08:59,000 --> 00:09:01,000 i have no idea 150 00:09:01,000 --> 00:09:07,000 right and it's going to cause you problems they don't do it if you want to 151 00:09:07,000 --> 00:09:08,000 see what happens go ahead and dry bread it's a bug in logic not about and what 152 00:09:08,000 --> 00:09:09,000 the computers executing 153 00:09:09,000 --> 00:09:19,000 any other questions are gone 154 00:09:19,000 --> 00:09:21,000 up it's not going to get the actual button so 155 00:09:21,000 --> 00:09:25,000 you're saying in this other case ever here 156 00:09:25,000 --> 00:09:29,000 what is this thing going to return if i didn't create a variable over here 157 00:09:29,000 --> 00:09:32,000 this thing starting to return some reference to your object 158 00:09:32,000 --> 00:09:35,000 the only issue for you now though is you have no way of checking for equality 159 00:09:35,000 --> 00:09:39,000 with some object right as you know if you don't have the same instance 160 00:09:39,000 --> 00:09:42,000 variable you can check to see if that things equal the high button so if you 161 00:09:42,000 --> 00:09:46,000 created high button over here just immediately added it never kept track of 162 00:09:46,000 --> 00:09:46,000 it over here 163 00:09:46,000 --> 00:09:48,000 this guy would return to you 164 00:09:48,000 --> 99:59:59,999 a pointer too high but menu take right i got appointed a high button how do you 165 99:59:59,999 --> 99:59:59,999 know it's high button 166 99:59:59,999 --> 99:59:59,999 you don't because you have no way of comparing it to the actual hot button 167 99:59:59,999 --> 99:59:59,999 created 168 99:59:59,999 --> 99:59:59,999 and that's why we need to work 169 99:59:59,999 --> 99:59:59,999 so why do i show these to differ quite of doing it the reason why i say these 170 99:59:59,999 --> 99:59:59,999 two different ways of doing it is now you're actually make use of this 171 99:59:59,999 --> 99:59:59,999 with respect to some other interact or is the tracks and see where we care 172 99:59:59,999 --> 99:59:59,999 about doing debt source as opposed to you 173 99:59:59,999 --> 99:59:59,999 the uh... action plan 174 99:59:59,999 --> 99:59:59,999 so what we're gonna do next 175 99:59:59,999 --> 99:59:59,999 is going to say you know allot of times and programs that you really want to 176 99:59:59,999 --> 99:59:59,999 have if you want to have some way of letting the user specified 177 99:59:59,999 --> 99:59:59,999 some taxed 178 99:59:59,999 --> 99:59:59,999 in a program that's running interactively that's not consul right 179 99:59:59,999 --> 99:59:59,999 they'd like to be able to type something and so let me just show you example of 180 99:59:59,999 --> 99:59:59,999 this 181 99:59:59,999 --> 99:59:59,999 dvd buchanan 182 99:59:59,999 --> 99:59:59,999 so you have a program that's got what we refer to as a text feel down here 183 99:59:59,999 --> 99:59:59,999 and i call that name and so if i say hey my name is maryland 184 99:59:59,999 --> 99:59:59,999 it says hello maryland 185 99:59:59,999 --> 99:59:59,999 and then i say are not and i was joking my name is really sally 186 99:59:59,999 --> 99:59:59,999 most of you don't know this 187 99:59:59,999 --> 99:59:59,999 as as a hollow sally right so it's just some way of being able to 188 99:59:59,999 --> 99:59:59,999 have some taxes 189 99:59:59,999 --> 99:59:59,999 field over here that the user fails and in the senate interact a right this is 190 99:59:59,999 --> 99:59:59,999 just one fields dot on the console 191 99:59:59,999 --> 99:59:59,999 and then do some action in the action we have to do here is to write something 192 99:59:59,999 --> 99:59:59,999 the console 193 99:59:59,999 --> 99:59:59,999 that makes use of the tax that the 194 99:59:59,999 --> 99:59:59,999 the use your actually typed in 195 99:59:59,999 --> 99:59:59,999 so how do we get something like that to work 196 99:59:59,999 --> 99:59:59,999 so what we need to do is 197 99:59:59,999 --> 99:59:59,999 av and interact with it's called the text field 198 99:59:59,999 --> 99:59:59,999 and basically text field is 199 99:59:59,999 --> 99:59:59,999 is just epping use alright it's a little place where someone can type some text 200 99:59:59,999 --> 99:59:59,999 isn't interact or such as if it under control bars 201 99:59:59,999 --> 99:59:59,999 and then potentially one make it enter 202 99:59:59,999 --> 99:59:59,999 you get some action event that tells you unique actually or if you want you can 203 99:59:59,999 --> 99:59:59,999 do something with this text 204 99:59:59,999 --> 99:59:59,999 so that's the basic idea what you really get is a box and that's all you get with 205 99:59:59,999 --> 99:59:59,999 it if you want to add a label to that box like the added name over here 206 99:59:59,999 --> 99:59:59,999 we need to sort of specified that 207 99:59:59,999 --> 99:59:59,999 and i'll show you how to do that in just a second but what you're really get at 208 99:59:59,999 --> 99:59:59,999 the box in a new types in something 209 99:59:59,999 --> 99:59:59,999 and then hits began turkey then potentially some of them is generated 210 99:59:59,999 --> 99:59:59,999 for you 211 99:59:59,999 --> 99:59:59,999 so how does that actually set up so the thing we want to create is called ej 212 99:59:59,999 --> 99:59:59,999 text field ok it's just another one of these interact or just like you saw 213 99:59:59,999 --> 99:59:59,999 before we had checkboxes in combo boxes and all that stuff it's just called it a 214 99:59:59,999 --> 99:59:59,999 text field 215 99:59:59,999 --> 99:59:59,999 off named this twenty ab 216 99:59:59,999 --> 99:59:59,999 to stand for text field 217 99:59:59,999 --> 99:59:59,999 and what you do when you trade and you want to be easy to use a new g tax to be 218 99:59:59,999 --> 99:59:59,999 loved and what you've given as a parameter here's the funky thing 219 99:59:59,999 --> 99:59:59,999 you don't give it its label 220 99:59:59,999 --> 99:59:59,999 the label doesn't come with the tax till you need to create the label separately 221 99:59:59,999 --> 99:59:59,999 what you give it is the size of that text feel how big it should be in terms 222 99:59:59,999 --> 99:59:59,999 of the maximum number of characters that would show up in their so if we say ten 223 99:59:59,999 --> 99:59:59,999 for example you're saying is i want to have some text you'll get a hold almost 224 99:59:59,999 --> 99:59:59,999 ten characters and if you some font that's variable with it automatically 225 99:59:59,999 --> 99:59:59,999 gives you the size of like ten ends kazan is the widest character in case 226 99:59:59,999 --> 99:59:59,999 you didn't know that's just life in the city 227 99:59:59,999 --> 99:59:59,999 now the funny thing about this right were let relative to add this action 228 99:59:59,999 --> 99:59:59,999 performed 229 99:59:59,999 --> 99:59:59,999 is one the user hits answer 230 99:59:59,999 --> 99:59:59,999 if i didn't do anything else you would not actually get this call to action 231 99:59:59,999 --> 99:59:59,999 performed 232 99:59:59,999 --> 99:59:59,999 we'll because action performed only called for you for buttons 233 99:59:59,999 --> 99:59:59,999 so what you need to do is after you actually create this text field you need 234 99:59:59,999 --> 99:59:59,999 to say hey you know what 235 99:59:59,999 --> 99:59:59,999 i need to let you know about this text field add something that can generate 236 99:59:59,999 --> 99:59:59,999 actions and so the way you do this is a looks a little bit funky 237 99:59:59,999 --> 99:59:59,999 would you tell the tax field 238 99:59:59,999 --> 99:59:59,999 not and 239 99:59:59,999 --> 99:59:59,999 action listeners 240 99:59:59,999 --> 99:59:59,999 bits to pay 241 99:59:59,999 --> 99:59:59,999 you don't need to worry about all that blood is that actually mean at a very 242 99:59:59,999 --> 99:59:59,999 low level all you need to know if you're telling 243 99:59:59,999 --> 99:59:59,999 this text field 244 99:59:59,999 --> 99:59:59,999 hey guess what 245 99:59:59,999 --> 99:59:59,999 you're going to be able to generate actions now and the thing that you're 246 99:59:59,999 --> 99:59:59,999 going to let people know when you generate some actions is yourself which 247 99:59:59,999 --> 99:59:59,999 is why we pass this 248 99:59:59,999 --> 99:59:59,999 but anytime you create excel the youngest do this once for all text of 249 99:59:59,999 --> 99:59:59,999 the via multiple text fields 250 99:59:59,999 --> 99:59:59,999 you need to send this add action listener this 251 99:59:59,999 --> 99:59:59,999 message 252 99:59:59,999 --> 99:59:59,999 each one independently we only have one year so we only need to do it once here 253 99:59:59,999 --> 99:59:59,999 but what this basically gaza says 254 99:59:59,999 --> 99:59:59,999 auto text field 255 99:59:59,999 --> 99:59:59,999 that you can now generate these action events as well 256 99:59:59,999 --> 99:59:59,999 so after you created any sort of set up this line and you would want to add it 257 99:59:59,999 --> 99:59:59,999 some more inter program write to someone your program you would probably say 258 99:59:59,999 --> 99:59:59,999 bad 259 99:59:59,999 --> 99:59:59,999 kidnapped and we might add ginsburg's ample in the south as we had everything 260 99:59:59,999 --> 99:59:59,999 in the south 261 99:59:59,999 --> 99:59:59,999 when someone takes something and it's yep and hits internet will generate some 262 99:59:59,999 --> 99:59:59,999 call to action event for prefer action performed pasternak shanavas 263 99:59:59,999 --> 99:59:59,999 once that gets set up 264 99:59:59,999 --> 99:59:59,999 how do you actually say grout 265 99:59:59,999 --> 99:59:59,999 what was the text field that generated this about right because you could have 266 99:59:59,999 --> 99:59:59,999 multiple text feels that someone could have typed into it hit the enter key 267 99:59:59,999 --> 99:59:59,999 what you're doing teary-eyed use your friend if you just dot me dot get sore 268 99:59:59,999 --> 99:59:59,999 so inside here which are to say is 269 99:59:59,999 --> 99:59:59,999 he died gets worse 270 99:59:59,999 --> 99:59:59,999 is people equal to so yeah 271 99:59:59,999 --> 99:59:59,999 and at this point all kinds of warning bells should go out for you and so maybe 272 99:59:59,999 --> 99:59:59,999 inside here you won't be something like you want to print len 273 99:59:59,999 --> 99:59:59,999 where you want to say hi and then add to it the tax that's in that text box in 274 99:59:59,999 --> 99:59:59,999 the way you do that as you just say the name of whatever the text field is and 275 99:59:59,999 --> 99:59:59,999 the message you sended is get taxed and what it will give you back 276 99:59:59,999 --> 99:59:59,999 act is it will just returned to you this thing by it's not just returns a string 277 99:59:59,999 --> 99:59:59,999 of whatever's in that box on the user enter 278 99:59:59,999 --> 99:59:59,999 so that's all right out hike and then whatever text they type in just like you 279 99:59:59,999 --> 99:59:59,999 saw on the program except that was writing hello 280 99:59:59,999 --> 99:59:59,999 and maybe that's what we want to do 281 99:59:59,999 --> 99:59:59,999 but the warning bells it should be going off now what's the problem if i've just 282 99:59:59,999 --> 99:59:59,999 written the code like this 283 99:59:59,999 --> 99:59:59,999 it's not an instance variable writes i have no way if this is my payment method 284 99:59:59,999 --> 99:59:59,999 over here i have no way of being able to report that's me up again 285 99:59:59,999 --> 99:59:59,999 out here 286 99:59:59,999 --> 99:59:59,999 so i need to create the instance variable right if this is my new method 287 99:59:59,999 --> 99:59:59,999 public void in eight in front of him 288 99:59:59,999 --> 99:59:59,999 what i need to do is this year somewhere else in my class let's say over here 289 99:59:59,999 --> 99:59:59,999 which is where i declare my art bar's right which is just lower down in the 290 99:59:59,999 --> 99:59:59,999 class umar 291 99:59:59,999 --> 99:59:59,999 i need to actually have prided 292 99:59:59,999 --> 99:59:59,999 jamie 293 99:59:59,999 --> 99:59:59,999 packs 294 99:59:59,999 --> 99:59:59,999 field 295 99:59:59,999 --> 99:59:59,999 grossly out and then over here rather than declaring it 296 99:59:59,999 --> 99:59:59,999 i'd just create the new thier so i need to set it up with an instance variable 297 99:59:59,999 --> 99:59:59,999 okay just like this on the example of the button same kind of thing that's 298 99:59:59,999 --> 99:59:59,999 going on here 299 99:59:59,999 --> 99:59:59,999 except the surtax feels 300 99:59:59,999 --> 99:59:59,999 so let me show you an example of this code inaction 301 99:59:59,999 --> 99:59:59,999 so here's a little text field example what i want to do is i'm going to create 302 99:59:59,999 --> 99:59:59,999 next and the consul program some so i don't have a console 303 99:59:59,999 --> 99:59:59,999 in my hand nick i'm going to have 304 99:59:59,999 --> 99:59:59,999 something called name field what's name field it's just a private j text field 305 99:59:59,999 --> 99:59:59,999 right it's an instance variable so i can save off name field 306 99:59:59,999 --> 99:59:59,999 name field i a nationwide over here to be some new jerry text field of site and 307 99:59:59,999 --> 99:59:59,999 write is exactly what i just saw over there 308 99:59:59,999 --> 99:59:59,999 now when i also want to do here is the one actor funk innocent program i want 309 99:59:59,999 --> 99:59:59,999 to give that box a label so before i add this box to my control bar 310 99:59:59,999 --> 99:59:59,999 i'm gonna adding new jail able with jess says names all j label does it just says 311 99:59:59,999 --> 99:59:59,999 hey i'm going to create something that's just this name 312 99:59:59,999 --> 99:59:59,999 or just this particular these attacks attacks happens to be named and i'm 313 99:59:59,999 --> 99:59:59,999 going to add 314 99:59:59,999 --> 99:59:59,999 to my southern control bar 315 99:59:59,999 --> 99:59:59,999 so forth it's just going to write name out there and then after i write name 316 99:59:59,999 --> 99:59:59,999 i'm going to add to my name field which is going to create the box after name 317 99:59:59,999 --> 99:59:59,999 and then i'm going to show you you know i'm going to do exactly what i told you 318 99:59:59,999 --> 99:59:59,999 where you have to tell me name field 319 99:59:59,999 --> 99:59:59,999 you're going to add action listeners of yourself 320 99:59:59,999 --> 99:59:59,999 so that if you do anything 321 99:59:59,999 --> 99:59:59,999 you're going to let 322 99:59:59,999 --> 99:59:59,999 someone else know that you actually have done some action when the user tight 323 99:59:59,999 --> 99:59:59,999 since you would please enter 324 99:59:59,999 --> 99:59:59,999 that means action performed is going to get called for you because now you're 325 99:59:59,999 --> 99:59:59,999 going to be able to generate events to an action listener 326 99:59:59,999 --> 99:59:59,999 and inaction performed 327 99:59:59,999 --> 99:59:59,999 we check you don't get source we can compare against name field 'cause we 328 99:59:59,999 --> 99:59:59,999 have that saved up down here is an instance variable 329 99:59:59,999 --> 99:59:59,999 and will just right out hello and then the text assisted with name field 330 99:59:59,999 --> 99:59:59,999 and money 331 99:59:59,999 --> 99:59:59,999 increase the tax eyes here 332 99:59:59,999 --> 99:59:59,999 just so it's a little bit bigger and we can all see what's actually going on set 333 99:59:59,999 --> 99:59:59,999 for one 334 99:59:59,999 --> 99:59:59,999 of the wild favorite career twenty four 335 99:59:59,999 --> 99:59:59,999 aquino na make a bigger 336 99:59:59,999 --> 99:59:59,999 yeah the asset just in case victor 337 99:59:59,999 --> 99:59:59,999 so here once again they're on 338 99:59:59,999 --> 99:59:59,999 hello marilyn c and one in those it's getting a bit like it in a row right 339 99:59:59,999 --> 99:59:59,999 enter entertainer entertainers that exerc entertainer 340 99:59:59,999 --> 99:59:59,999 that's another one of things it's only so much fun 341 99:59:59,999 --> 99:59:59,999 trying to sell these were scroll emerge from one 342 99:59:59,999 --> 99:59:59,999 not a lot of time going on their why does this gap of about two minutes maybe 343 99:59:59,999 --> 99:59:59,999 one 344 99:59:59,999 --> 99:59:59,999 so we can do it we can go ahead and do it this way now you can get information 345 99:59:59,999 --> 99:59:59,999 pentax box 346 99:59:59,999 --> 99:59:59,999 any questions about text box 347 99:59:59,999 --> 99:59:59,999 behind the back 348 99:59:59,999 --> 99:59:59,999 yeah so basically the way layout works is every time you add things they just 349 99:59:59,999 --> 99:59:59,999 get added sequentially from left to right in whichever region you're adding 350 99:59:59,999 --> 99:59:59,999 them to in this case the southern region and the whole set of stuff gets honored 351 99:59:59,999 --> 99:59:59,999 so if you want to space stuff out which actually need to do our ad for example 352 99:59:59,999 --> 99:59:59,999 more more j labels that might have to spaces in the mental creates more space 353 99:59:59,999 --> 99:59:59,999 between stuff and there's no economic are just leave it here 354 99:59:59,999 --> 99:59:59,999 ikea 355 99:59:59,999 --> 99:59:59,999 so here's what i think india that's kinda funky is we can actually name of 356 99:59:59,999 --> 99:59:59,999 the text field 357 99:59:59,999 --> 99:59:59,999 you might say but maryland this won't get source thing yeah yeah keep around 358 99:59:59,999 --> 99:59:59,999 the instance there but i'm not so keen on that 359 99:59:59,999 --> 99:59:59,999 what i am comwork you not is giving things name so i can just refer to them 360 99:59:59,999 --> 99:59:59,999 by their name inside ok thats cool you can you can have a name 361 99:59:59,999 --> 99:59:59,999 so here that exact same example just slightly differently what i want to do 362 99:59:59,999 --> 99:59:59,999 is on the air 363 99:59:59,999 --> 99:59:59,999 had just one more line here so this is exactly the same code i had before 364 99:59:59,999 --> 99:59:59,999 except after i create the name field i say hey name field 365 99:59:59,999 --> 99:59:59,999 i want to give you an action need 366 99:59:59,999 --> 99:59:59,999 and that were an action command and your action command is going to be name 367 99:59:59,999 --> 99:59:59,999 so whenever you generate these events yeah i can check to see if your sources 368 99:59:59,999 --> 99:59:59,999 actually but the source of that event is you 369 99:59:59,999 --> 99:59:59,999 or if i've given you a name 370 99:59:59,999 --> 99:59:59,999 i can do the same thing i just did with buttons which is down here i can get 371 99:59:59,999 --> 99:59:59,999 action command that gives me the string which is the name of the object the 372 99:59:59,999 --> 99:59:59,999 created this event 373 99:59:59,999 --> 99:59:59,999 and i can see if it's equal to name which is the name that i gave it 374 99:59:59,999 --> 99:59:59,999 so that's just showed you a little back and forth with buttons i kinda showed 375 99:59:59,999 --> 99:59:59,999 you got for it with buttons you just need them cuz you always name buttons 376 99:59:59,999 --> 99:59:59,999 will check against names 377 99:59:59,999 --> 99:59:59,999 but you could actually 378 99:59:59,999 --> 99:59:59,999 check against the source of the button if you want to 379 99:59:59,999 --> 99:59:59,999 gatech still just kinda backwards j text field you always 380 99:59:59,999 --> 99:59:59,999 in some sense have the tax field that you can get with debt source but if you 381 99:59:59,999 --> 99:59:59,999 want to report will by name you have to explicitly given name because name 382 99:59:59,999 --> 99:59:59,999 doesn't show up as part of it right if we want the label we still need to add 383 99:59:59,999 --> 99:59:59,999 the separate label name over here 384 99:59:59,999 --> 99:59:59,999 this is just naming the particular events that come from that box that's 385 99:59:59,999 --> 99:59:59,999 all it does 386 99:59:59,999 --> 99:59:59,999 answer any questions about them 387 99:59:59,999 --> 99:59:59,999 at the max max shows 388 99:59:59,999 --> 99:59:59,999 oss 389 99:59:59,999 --> 99:59:59,999 yen named feel the stand i've are here it's really actually no longer necessary 390 99:59:59,999 --> 99:59:59,999 cuz i don't need to refer to it over here so if i wanted to make it just is 391 99:59:59,999 --> 99:59:59,999 deep sting little campaigns spank sidebars thanks for playing that's real 392 99:59:59,999 --> 99:59:59,999 nice of you 393 99:59:59,999 --> 99:59:59,999 and everything's 394 99:59:59,999 --> 99:59:59,999 although i can't 395 99:59:59,999 --> 99:59:59,999 that's why i did in here cause i still need to refer to it over here to get its 396 99:59:59,999 --> 99:59:59,999 what i could to be honest actually what i could do is i could just 397 99:59:59,999 --> 99:59:59,999 call you get source here and get it source and get it stacks i really don't 398 99:59:59,999 --> 99:59:59,999 need to 399 99:59:59,999 --> 99:59:59,999 but it is better stock that makes it clear that i'm getting the texture so 400 99:59:59,999 --> 99:59:59,999 there is a way around it 401 99:59:59,999 --> 99:59:59,999 but the cleaner ways to actually do it this way 402 99:59:59,999 --> 99:59:59,999 already 403 99:59:59,999 --> 99:59:59,999 get rid of the declaration 404 99:59:59,999 --> 99:59:59,999 that's like c 405 99:59:59,999 --> 99:59:59,999 sang questions about that j text field 406 99:59:59,999 --> 99:59:59,999 uh... yeah 407 99:59:59,999 --> 99:59:59,999 on weekends 408 99:59:59,999 --> 99:59:59,999 and i'll show you that no about twenty minutes 409 99:59:59,999 --> 99:59:59,999 but hand free seats away so before we get there 410 99:59:59,999 --> 99:59:59,999 it's not something completely different 411 99:59:59,999 --> 99:59:59,999 and i think it's completely different is this a how to get to the question in the 412 99:59:59,999 --> 99:59:59,999 back of the room which is 413 99:59:59,999 --> 99:59:59,999 and they're on these things are all sort of showing up centered on the bottom of 414 99:59:59,999 --> 99:59:59,999 the screen cut i actually have these enter actor is laid out a different way 415 99:59:59,999 --> 99:59:59,999 than this way that they're getting laid out for me and in fact you can and 416 99:59:59,999 --> 99:59:59,999 strangely enough the thing you used to do that is called a layout 417 99:59:59,999 --> 99:59:59,999 so i'll let you know controls the layout a particular interactions now it turns 418 99:59:59,999 --> 99:59:59,999 out when you use your friendly console program 419 99:59:59,999 --> 99:59:59,999 or your friend of the graphics program 420 99:59:59,999 --> 99:59:59,999 what you got was a layout was called the border layouts and he was a matter of 421 99:59:59,999 --> 99:59:59,999 fact artists on the border layouts 422 99:59:59,999 --> 99:59:59,999 you saw the boarder layout last time it looked like this 423 99:59:59,999 --> 99:59:59,999 which is you had some cena region you had a north south east and west borders 424 99:59:59,999 --> 99:59:59,999 which is why this thing called a border layout 425 99:59:59,999 --> 99:59:59,999 and what you 426 99:59:59,999 --> 99:59:59,999 what happened with that 427 99:59:59,999 --> 99:59:59,999 what happened with this border layouts 428 99:59:59,999 --> 99:59:59,999 powerpoint wants comply 429 99:59:59,999 --> 99:59:59,999 it at the center was were all the action takes place 430 99:59:59,999 --> 99:59:59,999 the console program would add a console to the sensor automatically right that 431 99:59:59,999 --> 99:59:59,999 is what happens in a consul program and a graphics program would added g canvas 432 99:59:59,999 --> 99:59:59,999 to the center automatically which is what you're going to draw your stuff 433 99:59:59,999 --> 99:59:59,999 and the other regions are only visible if you add stuff to them so in the very 434 99:59:59,999 --> 99:59:59,999 early days when you had a graphics program 435 99:59:59,999 --> 99:59:59,999 that was all just graphics you would say hey mera nothing showed up at is the 436 99:59:59,999 --> 99:59:59,999 self region 437 99:59:59,999 --> 99:59:59,999 yeah 'cause we didn't put any interact or if they are so 438 99:59:59,999 --> 99:59:59,999 these enter actor region's only show up if we actually put in a raptor on 439 99:59:59,999 --> 99:59:59,999 rightly said these are referred to as control bar say saudis last time 440 99:59:59,999 --> 99:59:59,999 so how do i consider different kinds of layouts so there's a couple of other 441 99:59:59,999 --> 99:59:59,999 layout also think about their something called a greed layout 442 99:59:59,999 --> 99:59:59,999 and and the land grant layout works is you actually creighton object called 443 99:59:59,999 --> 99:59:59,999 agreed to lay out and you specify inaccurate lay out how many rows and 444 99:59:59,999 --> 99:59:59,999 columns are in the great layout so 445 99:59:59,999 --> 99:59:59,999 we might take you rosen three columns which means we're going to have a laying 446 99:59:59,999 --> 99:59:59,999 out the look something like this is just a grade with two rooms in three columns 447 99:59:59,999 --> 99:59:59,999 and i say that the code for this in just two seconds and then the nitty-gritty 448 99:59:59,999 --> 99:59:59,999 details 449 99:59:59,999 --> 99:59:59,999 but conceptually here's what it is 450 99:59:59,999 --> 99:59:59,999 now when i had i'd ims so what i do as i say hey you know what i want to set my 451 99:59:59,999 --> 99:59:59,999 layout to leave is great layout 452 99:59:59,999 --> 99:59:59,999 what now happens when i had i done is is it will add items the items being the 453 99:59:59,999 --> 99:59:59,999 interact urs 454 99:59:59,999 --> 99:59:59,999 one-by-one starting at the top most role in the leftmost center in the last most 455 99:59:59,999 --> 99:59:59,999 square 456 99:59:59,999 --> 99:59:59,999 and every time i add a new element it moved over by one until i get to the end 457 99:59:59,999 --> 99:59:59,999 of the row and then it automatically comes down so go sequentially across row 458 99:59:59,999 --> 99:59:59,999 by roe 459 99:59:59,999 --> 99:59:59,999 but allows me to contemplate things that may grade 460 99:59:59,999 --> 99:59:59,999 if i want to actually be able to do things and agreed so let me show you an 461 99:59:59,999 --> 99:59:59,999 example of what a grid layout might look like 462 99:59:59,999 --> 99:59:59,999 world on with you lou died 463 99:59:59,999 --> 99:59:59,999 so great layout 464 99:59:59,999 --> 99:59:59,999 here's a simple program it has a great layout what we do is we start off 465 99:59:59,999 --> 99:59:59,999 inordinate method by saying 466 99:59:59,999 --> 99:59:59,999 hey you know what i want to create a layout 467 99:59:59,999 --> 99:59:59,999 so i want to set the existing layout that the program is going to use to be a 468 99:59:59,999 --> 99:59:59,999 new grid layout that's to come at three to rose by three columns 469 99:59:59,999 --> 99:59:59,999 now one thing that's interesting about this program if you look at great layout 470 99:59:59,999 --> 99:59:59,999 example 471 99:59:59,999 --> 99:59:59,999 it does not extend consul program 472 99:59:59,999 --> 99:59:59,999 it does not extend graphics program these are not expiry of four house and 473 99:59:59,999 --> 99:59:59,999 it's beautiful life and it's beautiful children 474 99:59:59,999 --> 99:59:59,999 what have i done 475 99:59:59,999 --> 99:59:59,999 what i've done is set i'm just going to extend the program i don't want you to 476 99:59:59,999 --> 99:59:59,999 create a console for me and i don't want you to create a g canvas for me 477 99:59:59,999 --> 99:59:59,999 cuz i want to take up the whole story with my barnes baby 478 99:59:59,999 --> 99:59:59,999 so that's what i'm gonna do 479 99:59:59,999 --> 99:59:59,999 almanac 480 99:59:59,999 --> 99:59:59,999 six new buttons and these bonds are just going to get sequentially ad in the 481 99:59:59,999 --> 99:59:59,999 order you just saw and then i'm not saying a tad weiss action listeners 482 99:59:59,999 --> 99:59:59,999 and i'm not going to do anything understanding or the buttons but what i 483 99:59:59,999 --> 99:59:59,999 really the reason why i'm doing this 484 99:59:59,999 --> 99:59:59,999 is i just want to see some big fab but 485 99:59:59,999 --> 99:59:59,999 on the air like that 486 99:59:59,999 --> 99:59:59,999 six buttons that take up to the whole scream 487 99:59:59,999 --> 99:59:59,999 it's a good 488 99:59:59,999 --> 99:59:59,999 my enter actors filled up the graded 489 99:59:59,999 --> 99:59:59,999 the layout takes up as much space as possible in the screen and more 490 99:59:59,999 --> 99:59:59,999 importantly each of the interac yours that i put into agreed cell takes up as 491 99:59:59,999 --> 99:59:59,999 much cell as much space and the cell as possible so there's one comes along and 492 99:59:59,999 --> 99:59:59,999 says 493 99:59:59,999 --> 99:59:59,999 all yeah i got so much space on lay down your likely why why do you do this is 494 99:59:59,999 --> 99:59:59,999 the most bring everything ever i don't hahahaha 495 99:59:59,999 --> 99:59:59,999 lying 496 99:59:59,999 --> 99:59:59,999 didn't have any plan that separately 497 99:59:59,999 --> 99:59:59,999 driving everyone talk about a right now 498 99:59:59,999 --> 99:59:59,999 maybe afterwards 499 99:59:59,999 --> 99:59:59,999 such as frightening as like avnet sound effects got 500 99:59:59,999 --> 99:59:59,999 check this out as i resize the window all bein small uncw big buttons 501 99:59:59,999 --> 99:59:59,999 that's why we 502 99:59:59,999 --> 99:59:59,999 have layout managers because the layout manager just gives conceptually says 503 99:59:59,999 --> 99:59:59,999 this is how your layouts going to be 504 99:59:59,999 --> 99:59:59,999 and it says i'm going to handle all the dynamics of resizing and all that stuff 505 99:59:59,999 --> 99:59:59,999 for ups_ people resize the window 506 99:59:59,999 --> 99:59:59,999 but i need to know how things are laid out and if you give me more space 507 99:59:59,999 --> 99:59:59,999 then i need to understand the take it out 508 99:59:59,999 --> 99:59:59,999 great layout not so useful page or something to seize taken if you see in 509 99:59:59,999 --> 99:59:59,999 the book you know it's talking about 510 99:59:59,999 --> 99:59:59,999 there's another kind of layout 511 99:59:59,999 --> 99:59:59,999 which is called a table layout 512 99:59:59,999 --> 99:59:59,999 so that's another kind of lay out all the flow layout when i can talk about it 513 99:59:59,999 --> 99:59:59,999 all 514 99:59:59,999 --> 99:59:59,999 but there's something called a table layout 515 99:59:59,999 --> 99:59:59,999 any table layout is basically just like agreed layout except for the niceties so 516 99:59:59,999 --> 99:59:59,999 you also give it a number of rows and columns 517 99:59:59,999 --> 99:59:59,999 except where it says is rather than having each one of the interact urs fill 518 99:59:59,999 --> 99:59:59,999 up itself a maximum possible size 519 99:59:59,999 --> 99:59:59,999 i'm just going to give that enter actor as much space is it needs in that cell 520 99:59:59,999 --> 99:59:59,999 and no more 521 99:59:59,999 --> 99:59:59,999 so what does that mean 522 99:59:59,999 --> 99:59:59,999 that means if i come in here rather than a grid layout i say i want to create a 523 99:59:59,999 --> 99:59:59,999 new table layout 524 99:59:59,999 --> 99:59:59,999 and i run this 525 99:59:59,999 --> 99:59:59,999 co-ordinate add more imports 526 99:59:59,999 --> 99:59:59,999 are a little guide 527 99:59:59,999 --> 99:59:59,999 i mean just grab the imports from over here 528 99:59:59,999 --> 99:59:59,999 me 529 99:59:59,999 --> 99:59:59,999 you happy 530 99:59:59,999 --> 99:59:59,999 of graphics sorry 531 99:59:59,999 --> 99:59:59,999 come on table layout 532 99:59:59,999 --> 99:59:59,999 though table layout 533 99:59:59,999 --> 99:59:59,999 let me just show you the 534 99:59:59,999 --> 99:59:59,999 nice for example it cable 535 99:59:59,999 --> 99:59:59,999 didi 536 99:59:59,999 --> 99:59:59,999 sometimes in life 537 99:59:59,999 --> 99:59:59,999 he just got to get on with it 538 99:59:59,999 --> 99:59:59,999 we got ugly with it 539 99:59:59,999 --> 99:59:59,999 table layout 540 99:59:59,999 --> 99:59:59,999 there's table layout 541 99:59:59,999 --> 99:59:59,999 six button still 542 99:59:59,999 --> 99:59:59,999 we can spell resize the window but the button there just given as much sizes 543 99:59:59,999 --> 99:59:59,999 they would actually need they don't fill up the whole 544 99:59:59,999 --> 99:59:59,999 region of the actually ma 545 99:59:59,999 --> 99:59:59,999 table layout such something slightly more useful for us than great layout to 546 99:59:59,999 --> 99:59:59,999 the question came up before which was 547 99:59:59,999 --> 99:59:59,999 hey can i actually link like buttons and text fields together 548 99:59:59,999 --> 99:59:59,999 to create something a little bit more funky and in fact i can do that 549 99:59:59,999 --> 99:59:59,999 initially that any context outside something aloo bit more interesting 550 99:59:59,999 --> 99:59:59,999 which is a program that allows for conversion in temperature so this one's 551 99:59:59,999 --> 99:59:59,999 actually in the books i didn't give me the code because although 552 99:59:59,999 --> 99:59:59,999 cody is actually a the coated on the books i didn't get a chance ever handout 553 99:59:59,999 --> 99:59:59,999 they say it is where i got a label called degrees fahrenheit a label called 554 99:59:59,999 --> 99:59:59,999 degrees celsius 555 99:59:59,999 --> 99:59:59,999 and inside here we can type in some value and if we click fahrenheit to 556 99:59:59,999 --> 99:59:59,999 celsius 557 99:59:59,999 --> 99:59:59,999 it will automatically oil 558 99:59:59,999 --> 99:59:59,999 fill in the southeast field of course one value separately to is zero celsius 559 99:59:59,999 --> 99:59:59,999 the other thing that's kinda funky if i don't necessarily have to click the 560 99:59:59,999 --> 99:59:59,999 button i can type in say some value and hit enter 561 99:59:59,999 --> 99:59:59,999 and that's just like 562 99:59:59,999 --> 99:59:59,999 clicking the button 563 99:59:59,999 --> 99:59:59,999 interesting so how do i create this program well if you think about this 564 99:59:59,999 --> 99:59:59,999 program first i'm going to need is these things are not supersized but they're 565 99:59:59,999 --> 99:59:59,999 all laid out in a grade so i'm going to need a table layout 566 99:59:59,999 --> 99:59:59,999 that has to rosen three columns 567 99:59:59,999 --> 99:59:59,999 the first 568 99:59:59,999 --> 99:59:59,999 element that i have here is just the label that i'm going to have a field 569 99:59:59,999 --> 99:59:59,999 that the text field as a matter fact i have a specialized kind of text field 570 99:59:59,999 --> 99:59:59,999 owners to specialize context field 571 99:59:59,999 --> 99:59:59,999 something called the into field and a double field 572 99:59:59,999 --> 99:59:59,999 they work just like text fields except you're guaranteed to get an integer 573 99:59:59,999 --> 99:59:59,999 value were double value from the menu mighty but now and what happens if 574 99:59:59,999 --> 99:59:59,999 someone types and and wants to come for a twitter butcher 575 99:59:59,999 --> 99:59:59,999 i clicked the wrong button they want to convert age were temperature 576 99:59:59,999 --> 99:59:59,999 it says an internet injuring two brings up this pop-up box and gets in their 577 99:59:59,999 --> 99:59:59,999 face and say oh yeah sorry my bad 578 99:59:59,999 --> 99:59:59,999 so guarantees you get a major 579 99:59:59,999 --> 99:59:59,999 and then i'm going to have a button and somehow i want to link the button and 580 99:59:59,999 --> 99:59:59,999 the tax bills to do the same action 581 99:59:59,999 --> 99:59:59,999 so let me show you the car for that it's actually a lot shorter than it looks 582 99:59:59,999 --> 99:59:59,999 like 583 99:59:59,999 --> 99:59:59,999 first thing to do is a case at the layout to be a table layout notice once 584 99:59:59,999 --> 99:59:59,999 again here i am extending a program 'cause i don't want to console or canvas 585 99:59:59,999 --> 99:59:59,999 created for me 586 99:59:59,999 --> 99:59:59,999 i want to be able to specify the whole layout 587 99:59:59,999 --> 99:59:59,999 so i'm just extending a program 588 99:59:59,999 --> 99:59:59,999 i say set the layout to be a table layout to come in three 589 99:59:59,999 --> 99:59:59,999 and again we're going to go sequentially through all the elements of what i want 590 99:59:59,999 --> 99:59:59,999 to have in the first 591 99:59:59,999 --> 99:59:59,999 element 592 99:59:59,999 --> 99:59:59,999 basically the first thing i want to add to my layout i don't specify intel down 593 99:59:59,999 --> 99:59:59,999 here the very first thing to add to my layout is 594 99:59:59,999 --> 99:59:59,999 degrees fahrenheit as a label 595 99:59:59,999 --> 99:59:59,999 then i'm going to add some fahrenheit field what how did i create that 596 99:59:59,999 --> 99:59:59,999 fahrenheit field actually created it up here 597 99:59:59,999 --> 99:59:59,999 what i did 598 99:59:59,999 --> 99:59:59,999 first was declaring it as an instance variable so fahrenheit field isn't ants 599 99:59:59,999 --> 99:59:59,999 field not agape text field that you feel which is just a specialization of eighty 600 99:59:59,999 --> 99:59:59,999 eight ext field 601 99:59:59,999 --> 99:59:59,999 to just give you back a major other than that it works just like a text field 602 99:59:59,999 --> 99:59:59,999 except drugs one show you any feel totally feel 603 99:59:59,999 --> 99:59:59,999 so i created new and field i specified financial value not its initial sides 604 99:59:59,999 --> 99:59:59,999 but its initial value 605 99:59:59,999 --> 99:59:59,999 its initial value is thirty two 606 99:59:59,999 --> 99:59:59,999 then when i say is hey fahrenheit field 607 99:59:59,999 --> 99:59:59,999 i'm going to set your action command 608 99:59:59,999 --> 99:59:59,999 so that when you generate actions the name associated with the actions that 609 99:59:59,999 --> 99:59:59,999 you generate 610 99:59:59,999 --> 99:59:59,999 is going to be af 611 99:59:59,999 --> 99:59:59,999 dash greater than which we can just think of as a rogue c 612 99:59:59,999 --> 99:59:59,999 that's going to be your name so i said its name and i say you're going to 613 99:59:59,999 --> 99:59:59,999 generate action events 614 99:59:59,999 --> 99:59:59,999 someone adn action listener g love yourself 615 99:59:59,999 --> 99:59:59,999 okay just like you sabi for the text helix up now we're going with an infield 616 99:59:59,999 --> 99:59:59,999 we do exactly that same thing with something called the southeast feel 617 99:59:59,999 --> 99:59:59,999 tells his films also declared to be an infield 618 99:59:59,999 --> 99:59:59,999 it starts off the national volume zero we set it's action command to bc goes to 619 99:59:59,999 --> 99:59:59,999 ap as opposed to ap goes to see so we give it a slide a different name 620 99:59:59,999 --> 99:59:59,999 and we also set yet to listen to action events 621 99:59:59,999 --> 99:59:59,999 okay or did generate action events 622 99:59:59,999 --> 99:59:59,999 and then we're going to lay out our great so first element of the great is 623 99:59:59,999 --> 99:59:59,999 the label as we talked about before 624 99:59:59,999 --> 99:59:59,999 next element of our great is our little text box that's going to actually have 625 99:59:59,999 --> 99:59:59,999 the numeric value in it 626 99:59:59,999 --> 99:59:59,999 and last elements of our great on the first of all of the greatest 627 99:59:59,999 --> 99:59:59,999 is a button that's name is bath goes to see 628 99:59:59,999 --> 99:59:59,999 and you look at this and you say hey marron if i have a button its name is 629 99:59:59,999 --> 99:59:59,999 apt goes to see and i named this guy af goes to see 630 99:59:59,999 --> 99:59:59,999 aren't i getting back to the previous point over here of whether that's the 631 99:59:59,999 --> 99:59:59,999 logical problem where i actually have two elements that have the same name 632 99:59:59,999 --> 99:59:59,999 yeah bday i have to always have the same name but i want to do exactly the same 633 99:59:59,999 --> 99:59:59,999 thing in both cases so it doesn't make a difference 634 99:59:59,999 --> 99:59:59,999 so what i want to do is say someone clicks the button 635 99:59:59,999 --> 99:59:59,999 i'm going to do the conversion so i'm going to have some kind of those who do 636 99:59:59,999 --> 99:59:59,999 the conversion 637 99:59:59,999 --> 99:59:59,999 if someone type something in the text field it hits enter 638 99:59:59,999 --> 99:59:59,999 i'm going to do the same thing 639 99:59:59,999 --> 99:59:59,999 so this is something you see a lot of times on the web where for example if 640 99:59:59,999 --> 99:59:59,999 there's a search engine you use you type in the search engine then click search 641 99:59:59,999 --> 99:59:59,999 or you can just take enter how many people actually click the search button 642 99:59:59,999 --> 99:59:59,999 no one how many people just and hit enter 643 99:59:59,999 --> 99:59:59,999 yet isn't it nice that you can just hit enter 644 99:59:59,999 --> 99:59:59,999 that's the same thing we're doing in this program which is why we went 645 99:59:59,999 --> 99:59:59,999 through the extra rigmarole of setting this action command here 646 99:59:59,999 --> 99:59:59,999 'cause sometimes it's just nice to hear and 647 99:59:59,999 --> 99:59:59,999 and we do exactly the same thing for the grease celsius 648 99:59:59,999 --> 99:59:59,999 the name that was so we add that labeled degree celsius we had the southeast 649 99:59:59,999 --> 99:59:59,999 field and then we create a new button whose name is the same as the action 650 99:59:59,999 --> 99:59:59,999 command for the celsius field 651 99:59:59,999 --> 99:59:59,999 and then we add action listeners that sets up our entire user interface or 652 99:59:59,999 --> 99:59:59,999 entire graphical user interface and a good week 653 99:59:59,999 --> 99:59:59,999 and then when the user clicks on a button we say hey 654 99:59:59,999 --> 99:59:59,999 let me get the action command if the action commands f goes to see which 655 99:59:59,999 --> 99:59:59,999 means you are they type something in the fahrenheit field and hit enter 656 99:59:59,999 --> 99:59:59,999 or they click the button 657 99:59:59,999 --> 99:59:59,999 then i'll get the value in the hair fahrenheit field 658 99:59:59,999 --> 99:59:59,999 because fahrenheit field integer field i just always gives me back in a major 659 99:59:59,999 --> 99:59:59,999 and i do a little bit of math if you don't know the map conversion from 660 99:59:59,999 --> 99:59:59,999 fahrenheit the celsius 661 99:59:59,999 --> 99:59:59,999 don't worry about it this is just how you convert from fahrenheit celsius 662 99:59:59,999 --> 99:59:59,999 you taking nine fifth times the fahrenheit value minus thirty two and i 663 99:59:59,999 --> 99:59:59,999 give you the celtics value now you know 664 99:59:59,999 --> 99:59:59,999 what i do more interestingly if i set the value in the celsius field 665 99:59:59,999 --> 99:59:59,999 to be whatever value i computed 666 99:59:59,999 --> 99:59:59,999 so someone just type something into the fahrenheit feel that he enter or click 667 99:59:59,999 --> 99:59:59,999 the ftc_ button 668 99:59:59,999 --> 99:59:59,999 but in what i do to update the screen is ice change whatever values in the 669 99:59:59,999 --> 99:59:59,999 celsius field 670 99:59:59,999 --> 99:59:59,999 and i destroy the receptacle of that or i should say that 671 99:59:59,999 --> 99:59:59,999 compliment reciprocal the inverse the mirror image how many words can you come 672 99:59:59,999 --> 99:59:59,999 up for the same thing 673 99:59:59,999 --> 99:59:59,999 of that if someone does see dat 674 99:59:59,999 --> 99:59:59,999 which is i get the value that's in the celsius field 675 99:59:59,999 --> 99:59:59,999 i do the map it's necessary to convert herself if the fahrenheit nice at the 676 99:59:59,999 --> 99:59:59,999 fair field and that's the whole program right here is my instant variables 677 99:59:59,999 --> 99:59:59,999 so if i run 678 99:59:59,999 --> 99:59:59,999 my little temperature program 679 99:59:59,999 --> 99:59:59,999 i have my label 680 99:59:59,999 --> 99:59:59,999 i have my initial value and i have my fahrenheit to celsius and if i put in 681 99:59:59,999 --> 99:59:59,999 some value here like a hundred degrees fahrenheit 682 99:59:59,999 --> 99:59:59,999 is thirty eight degrees celsius 683 99:59:59,999 --> 99:59:59,999 and two hundred twelve degrees fahrenheit will not touch the mouse just 684 99:59:59,999 --> 99:59:59,999 hit on me in turkey 685 99:59:59,999 --> 99:59:59,999 uh... an er does the same thing is if i click the mouse and same thing on the 686 99:59:59,999 --> 99:59:59,999 second phase zero celsius 687 99:59:59,999 --> 99:59:59,999 the actor into good times and not created a whole program of the graphical 688 99:59:59,999 --> 99:59:59,999 user interface and i'd like to resize and it just doesn't know a lot always 689 99:59:59,999 --> 99:59:59,999 centers for me is not nice if i make it east mall 690 99:59:59,999 --> 99:59:59,999 while these things don't get too small just sent a i can see the screen that's 691 99:59:59,999 --> 99:59:59,999 what the state 692 99:59:59,999 --> 99:59:59,999 any questions about that 693 99:59:59,999 --> 99:59:59,999 how can use the mikes please 694 99:59:59,999 --> 99:59:59,999 i gotta keep reminding everyone views the microphones 695 99:59:59,999 --> 99:59:59,999 p 696 99:59:59,999 --> 99:59:59,999 but you can look really good 697 99:59:59,999 --> 99:59:59,999 uh... there are ways the with table layout you can actually get it whatever 698 99:59:59,999 --> 99:59:59,999 fortuitous at hands 699 99:59:59,999 --> 99:59:59,999 to actually specify different sizes for things and i just didn't do that here 700 99:59:59,999 --> 99:59:59,999 it's in the book if you want to do a but we're not going to 701 99:59:59,999 --> 99:59:59,999 try to push it out for in this class use it but there are ways you can 702 99:59:59,999 --> 99:59:59,999 so one final thing that we want to do is you might say all this is all good well 703 99:59:59,999 --> 99:59:59,999 mirror on yeah i'm not kind of fun but 704 99:59:59,999 --> 99:59:59,999 really what i like to some text in some graphics together and i want to interact 705 99:59:59,999 --> 99:59:59,999 recycle wanted all right 706 99:59:59,999 --> 99:59:59,999 i want tax taiwan wrapped on interactive you think back to busy rethinking man 707 99:59:59,999 --> 99:59:59,999 hangman you had texting had graphics 708 99:59:59,999 --> 99:59:59,999 but she didn't have interacted 709 99:59:59,999 --> 99:59:59,999 here you have interact there is and i show you example interact arisen tax 710 99:59:59,999 --> 99:59:59,999 twenty click the button and said hi and you know 711 99:59:59,999 --> 99:59:59,999 gave your name or whatever now it's time to roll the enchilada and put them all 712 99:59:59,999 --> 99:59:59,999 together in our friend 713 99:59:59,999 --> 99:59:59,999 text and graphics 714 99:59:59,999 --> 99:59:59,999 so what text and graphics is going to do 715 99:59:59,999 --> 99:59:59,999 is it basically what we want to think about is having some consul in the 716 99:59:59,999 --> 99:59:59,999 program 717 99:59:59,999 --> 99:59:59,999 and the graphics canvas in the program and interact or is in the program so we 718 99:59:59,999 --> 99:59:59,999 can just go to town and do whatever you want to do 719 99:59:59,999 --> 99:59:59,999 how do we make this happen 720 99:59:59,999 --> 99:59:59,999 first thing we're going to do 721 99:59:59,999 --> 99:59:59,999 you had a little bit text on the board just to get out there a little 722 99:59:59,999 --> 99:59:59,999 blood circulating in your legs and i know nothing about blood clots in your 723 99:59:59,999 --> 99:59:59,999 legs where you're actually traveling too long on planes and blood clot 724 99:59:59,999 --> 99:59:59,999 yeah we want to talk about that 725 99:59:59,999 --> 99:59:59,999 i didn't give you a small hands of a save your life beverage traveling on a 726 99:59:59,999 --> 99:59:59,999 trip is longer than two hours sometime during the trip or multiple times get up 727 99:59:59,999 --> 99:59:59,999 and walk around 728 99:59:59,999 --> 99:59:59,999 it will save your life 729 99:59:59,999 --> 99:59:59,999 but nigger ever giving a lecture for longer than two hours 730 99:59:59,999 --> 99:59:59,999 get up and walk around it'll save your life to not be the blood clots but 731 99:59:59,999 --> 99:59:59,999 because your students would tell you have to drive you just sitting there 732 99:59:59,999 --> 99:59:59,999 going like all i know not good bread that layout were which we're not going 733 99:59:59,999 --> 99:59:59,999 to get into it 734 99:59:59,999 --> 99:59:59,999 but is it accidentally so text and graphics 735 99:59:59,999 --> 99:59:59,999 she retains the taste great together 736 99:59:59,999 --> 99:59:59,999 you can decide which ones chocolate and which ones peanut butter 737 99:59:59,999 --> 99:59:59,999 lettuce text and graphics and so it's like hangman but with interactives 738 99:59:59,999 --> 99:59:59,999 so what we're going to do is we're going to extend consul program 739 99:59:59,999 --> 99:59:59,999 and the reason why we're going to extend the consul program he's we still need 740 99:59:59,999 --> 99:59:59,999 our plan the console that's what we're going to get the text portion of doing 741 99:59:59,999 --> 99:59:59,999 this interaction 742 99:59:59,999 --> 99:59:59,999 it's from having the consul program 743 99:59:59,999 --> 99:59:59,999 and so what we have a console program what please give this is it gives us 744 99:59:59,999 --> 99:59:59,999 the borders 745 99:59:59,999 --> 99:59:59,999 that we've come to know when law writing gives us the north border in the south 746 99:59:59,999 --> 99:59:59,999 border and western he's and these are places where we can still play so enter 747 99:59:59,999 --> 99:59:59,999 actors 748 99:59:59,999 --> 99:59:59,999 the interesting thing is what's going on in the center region 749 99:59:59,999 --> 99:59:59,999 and what i told you before the consul program 750 99:59:59,999 --> 99:59:59,999 fills up the senate region with a place where you can put text and that's all 751 99:59:59,999 --> 99:59:59,999 you can do with it 752 99:59:59,999 --> 99:59:59,999 so what we're going to say it a consul program what i want to do is in the 753 99:59:59,999 --> 99:59:59,999 center regent i want to give you a different layout and put stuff in that 754 99:59:59,999 --> 99:59:59,999 lady out 755 99:59:59,999 --> 99:59:59,999 second potentially have some text in some graphic 756 99:59:59,999 --> 99:59:59,999 uh... 757 99:59:59,999 --> 99:59:59,999 so what am i going to do 758 99:59:59,999 --> 99:59:59,999 the first thing i want to do is i'm going to think about having some layouts 759 99:59:59,999 --> 99:59:59,999 okay mine layouts going applied to this middle region 760 99:59:59,999 --> 99:59:59,999 the important thing to keep in mind as the console program what used to be was 761 99:59:59,999 --> 99:59:59,999 created console the filled up the entire region 762 99:59:59,999 --> 99:59:59,999 now what i'm going to get is a console as my first elements 763 99:59:59,999 --> 99:59:59,999 which means however i do the layout whatever i do and that lay out the very 764 99:59:59,999 --> 99:59:59,999 first thing like what i have a great that has three elements to it one row 765 99:59:59,999 --> 99:59:59,999 the first elements of that 766 99:59:59,999 --> 99:59:59,999 will be my consul 767 99:59:59,999 --> 99:59:59,999 that you don't have any control over just because of the way the consul 768 99:59:59,999 --> 99:59:59,999 program works the first elements of whatever layout you used when you extend 769 99:59:59,999 --> 99:59:59,999 the consul program create a layout for wall waise bhi your whatever your text 770 99:59:59,999 --> 99:59:59,999 it's 771 99:59:59,999 --> 99:59:59,999 now you said hey 772 99:59:59,999 --> 99:59:59,999 there on your awesome tell me about graphics but if i'm doing with the 773 99:59:59,999 --> 99:59:59,999 consul program how do i get graphics 774 99:59:59,999 --> 99:59:59,999 we give a little trick we did in hangman which is there's this thing called the g 775 99:59:59,999 --> 99:59:59,999 candidates 776 99:59:59,999 --> 99:59:59,999 and what we're going to do is create agee kandicn digi cam this importantly 777 99:59:59,999 --> 99:59:59,999 is actually something that we can add to a linux 778 99:59:59,999 --> 99:59:59,999 so what i can do is say hey crave my consul program i'm going to create some 779 99:59:59,999 --> 99:59:59,999 layout but sam i have a great that's 780 99:59:59,999 --> 99:59:59,999 i'm going to create some sort of way out like maybe i have agreed me out 781 99:59:59,999 --> 99:59:59,999 one comment three 782 99:59:59,999 --> 99:59:59,999 which would give me dressed 783 99:59:59,999 --> 99:59:59,999 i know that my first things i think up my my console what i want to do is 784 99:59:59,999 --> 99:59:59,999 creepy g canvas 785 99:59:59,999 --> 99:59:59,999 and ad that you can visit is my second elements 786 99:59:59,999 --> 99:59:59,999 and just to be super cool to give you something that normally you'd have to 787 99:59:59,999 --> 99:59:59,999 pay twelve ninety five four but i want to get at you for for 788 99:59:59,999 --> 99:59:59,999 we're going to create another g hands and added over here so that she can this 789 99:59:59,999 --> 99:59:59,999 bills 790 99:59:59,999 --> 99:59:59,999 so what we get is consul and to different g canvases 791 99:59:59,999 --> 99:59:59,999 plus we can still add interac result round or screen 792 99:59:59,999 --> 99:59:59,999 at this point you should be looking at this and shock horror and delight and 793 99:59:59,999 --> 99:59:59,999 going 794 99:59:59,999 --> 99:59:59,999 okay marron let's all put it together and five minutes because it's just that 795 99:59:59,999 --> 99:59:59,999 he 796 99:59:59,999 --> 99:59:59,999 so here's how it works 797 99:59:59,999 --> 99:59:59,999 text and graphics ike's ten console program 798 99:59:59,999 --> 99:59:59,999 okay 'cause that's going to get my consul 799 99:59:59,999 --> 99:59:59,999 in miami i say set the layout 800 99:59:59,999 --> 99:59:59,999 on one new grid layout remember great layout the elements of the great layout 801 99:59:59,999 --> 99:59:59,999 expand to take how much space you give them 802 99:59:59,999 --> 99:59:59,999 that's what i want in this case 803 99:59:59,999 --> 99:59:59,999 because what i want to say as i want to have a great i want to give the consul 804 99:59:59,999 --> 99:59:59,999 one-third of the whole grade and cute and this is another third of those 805 99:59:59,999 --> 99:59:59,999 grades and grown too is large as they can be 806 99:59:59,999 --> 99:59:59,999 then i'm going to do is i'm going to create to canvass so i need to have some 807 99:59:59,999 --> 99:59:59,999 instance variables to refer to these canvases 808 99:59:59,999 --> 99:59:59,999 i am i have to canvases 809 99:59:59,999 --> 99:59:59,999 which are just type is g canvas by private labels i will call them the 810 99:59:59,999 --> 99:59:59,999 right canvas and the left hand yes 811 99:59:59,999 --> 99:59:59,999 animals have a text field in this program just for laughs just cuz i can 812 99:59:59,999 --> 99:59:59,999 and that's going to be one of my characters so i want to have interact 813 99:59:59,999 --> 99:59:59,999 respect graph 814 99:59:59,999 --> 99:59:59,999 what am i going to do 815 99:59:59,999 --> 99:59:59,999 first thing to do it on to say that left canvas create a new canvas 816 99:59:59,999 --> 99:59:59,999 that can viz 817 99:59:59,999 --> 99:59:59,999 and when i do this add it's adding it to my laid out 818 99:59:59,999 --> 99:59:59,999 ham adding a whole candid so what is that do it says hey told me got a great 819 99:59:59,999 --> 99:59:59,999 layout here ive already filled in the first thing with the console 'cause 820 99:59:59,999 --> 99:59:59,999 that's what i do on the console program 821 99:59:59,999 --> 99:59:59,999 you just told me to add a canvas 822 99:59:59,999 --> 99:59:59,999 element number two will be the canvas 823 99:59:59,999 --> 99:59:59,999 i do the same thing again for white canvas element number three is not the 824 99:59:59,999 --> 99:59:59,999 right and so i have to big canvasses on there as the second and third elements 825 99:59:59,999 --> 99:59:59,999 of my grade 826 99:59:59,999 --> 99:59:59,999 i got a console 827 99:59:59,999 --> 99:59:59,999 grid canvas tents not going to add to interact with because it's just that 828 99:59:59,999 --> 99:59:59,999 cool i'm going to create a text field which they knew gatech steel text field 829 99:59:59,999 --> 99:59:59,999 i declared as a private instance variable i just showed you that 830 99:59:59,999 --> 99:59:59,999 maximum size is ten 831 99:59:59,999 --> 99:59:59,999 i will add a label to it and the label just going to be called some text 832 99:59:59,999 --> 99:59:59,999 sold the rights some tax 833 99:59:59,999 --> 99:59:59,999 in the southern region 834 99:59:59,999 --> 99:59:59,999 that'll adam i text field in the southern region and that ads at this 835 99:59:59,999 --> 99:59:59,999 point you should come to know involved you always gotta remember to add your 836 99:59:59,999 --> 99:59:59,999 action list are very common thing that happens people create a text field and 837 99:59:59,999 --> 99:59:59,999 their type in an end stuff in the program enough things happening in their 838 99:59:59,999 --> 99:59:59,999 tearing their hair and they're wondering why 839 99:59:59,999 --> 99:59:59,999 they just forgot to add the action list you know it learn it live it probably 840 99:59:59,999 --> 99:59:59,999 it's a good time 841 99:59:59,999 --> 99:59:59,999 action listener for your text field 842 99:59:59,999 --> 99:59:59,999 and then i would have to buttons just for good times so i have my tech said 843 99:59:59,999 --> 99:59:59,999 i'm gonna have to more buttons a button that says draw on the left 844 99:59:59,999 --> 99:59:59,999 and a button that says draw on the right 845 99:59:59,999 --> 99:59:59,999 so i mean show you what all these things are going to do 846 99:59:59,999 --> 99:59:59,999 before i show you the rest of the program 847 99:59:59,999 --> 99:59:59,999 so what i want to show you text and graphics 848 99:59:59,999 --> 99:59:59,999 uh... 849 99:59:59,999 --> 99:59:59,999 out my consolation 850 99:59:59,999 --> 99:59:59,999 i have to you can see them but they are side by side q different canvas windows 851 99:59:59,999 --> 99:59:59,999 over here here's some text i can type in high 852 99:59:59,999 --> 99:59:59,999 you typed 853 99:59:59,999 --> 99:59:59,999 while 854 99:59:59,999 --> 99:59:59,999 that exciting 855 99:59:59,999 --> 99:59:59,999 drama left in my left hand that some just run rectangles offsite i do that 856 99:59:59,999 --> 99:59:59,999 just a second 857 99:59:59,999 --> 99:59:59,999 draw a right 858 99:59:59,999 --> 99:59:59,999 drawing in my right candidates 859 99:59:59,999 --> 99:59:59,999 how did i make that happen alright on your share of the programme so i've set 860 99:59:59,999 --> 99:59:59,999 everything up right console to canvases 861 99:59:59,999 --> 99:59:59,999 text field and two buttons at the bottom 862 99:59:59,999 --> 99:59:59,999 here is where all the actions going on when action performed is called right i 863 99:59:59,999 --> 99:59:59,999 mean someone's interacting with one of the interact urs there's nothing else i 864 99:59:59,999 --> 99:59:59,999 can do in the program except interact with one of the inner actors 865 99:59:59,999 --> 99:59:59,999 first a check for the text field if the interaction with the text field so if 866 99:59:59,999 --> 99:59:59,999 the source of the interaction with the text field i write about you typed and 867 99:59:59,999 --> 99:59:59,999 the text of the text field this will go into the consul biggest anytime you do 868 99:59:59,999 --> 99:59:59,999 applicable in the text always goes in the consul so it just shows up in the 869 99:59:59,999 --> 99:59:59,999 consul not a whole lot exciting going on there 870 99:59:59,999 --> 99:59:59,999 alternatively if the thing they did was not stipe into the text field 871 99:59:59,999 --> 99:59:59,999 they clicked one of the bottoms so i say hey i'm showing i could've been there 872 99:59:59,999 --> 99:59:59,999 done all with get sore throat always get action command 873 99:59:59,999 --> 99:59:59,999 i'm using both just to show you that you can mix and match if you want 874 99:59:59,999 --> 99:59:59,999 so i say hey what was the command get action command 875 99:59:59,999 --> 99:59:59,999 if it was drawl left then what i want to do is i'm going to create a new field a 876 99:59:59,999 --> 99:59:59,999 rectangle let me show you create new filled rectangle it's very simple 877 99:59:59,999 --> 99:59:59,999 it just 878 99:59:59,999 --> 99:59:59,999 creates a rectangle that's fifty by twenty and yes they should have been 879 99:59:59,999 --> 99:59:59,999 constant i didn't make them conference i wouldn't have to scroll down and show 880 99:59:59,999 --> 99:59:59,999 you the constant 881 99:59:59,999 --> 99:59:59,999 i said to be filled 882 99:59:59,999 --> 99:59:59,999 and i return the rectangle solid does is create a filled rectangle on say hey 883 99:59:59,999 --> 99:59:59,999 your ego 884 99:59:59,999 --> 99:59:59,999 and although i do is i take that filled rectangle and i added 885 99:59:59,999 --> 99:59:59,999 to my left hand dates 886 99:59:59,999 --> 99:59:59,999 so because that's not a graphics program i can just a tad with the rectangle one 887 99:59:59,999 --> 99:59:59,999 added if i want to add the rectangle somewhere i need to specify which canvas 888 99:59:59,999 --> 99:59:59,999 of my adding a few i'm adding it's the left campus icao left hand this ads 889 99:59:59,999 --> 99:59:59,999 yourself this rectangle where you can add it x location twenty and at one 890 99:59:59,999 --> 99:59:59,999 location left y 891 99:59:59,999 --> 99:59:59,999 left wide starts out with the value ten 892 99:59:59,999 --> 99:59:59,999 and every time i add something i'd space down my wife's i'm just making wide go 893 99:59:59,999 --> 99:59:59,999 down to buy some spacer mt which is thirty so i was doing is trying a 894 99:59:59,999 --> 99:59:59,999 rectangle and essentially moving down toward drachmir x next rectangle below 895 99:59:59,999 --> 99:59:59,999 it moving down to draw the next rectangle below it 896 99:59:59,999 --> 99:59:59,999 and i do exactly the same thing for the right hand side 897 99:59:59,999 --> 99:59:59,999 except after a quick quick filled rectangle i have a separate whitewater 898 99:59:59,999 --> 99:59:59,999 which keeps track of how low of gotten on that side in terms of the white ford 899 99:59:59,999 --> 99:59:59,999 net 900 99:59:59,999 --> 99:59:59,999 and i add to the right canvas 901 99:59:59,999 --> 99:59:59,999 that's the only difference 902 99:59:59,999 --> 99:59:59,999 so when i run this program 903 99:59:59,999 --> 99:59:59,999 right some text 904 99:59:59,999 --> 99:59:59,999 right again if i type and great 905 99:59:59,999 --> 99:59:59,999 by typing great 906 99:59:59,999 --> 99:59:59,999 and hit enter it generates the event which does the sprint lynn on the screen 907 99:59:59,999 --> 99:59:59,999 right it generates this event over here this action performed 908 99:59:59,999 --> 99:59:59,999 the source was text field and i write out the text on the screen 909 99:59:59,999 --> 99:59:59,999 if i click on one of the buttons drama apt 910 99:59:59,999 --> 99:59:59,999 draws the filled rectangle and its incremented the why on the left hand 911 99:59:59,999 --> 99:59:59,999 side for next time i clicked route left 912 99:59:59,999 --> 99:59:59,999 it draws at lower and lower and lower and dry right does the same thing 913 99:59:59,999 --> 99:59:59,999 notice of the x location for both 914 99:59:59,999 --> 99:59:59,999 this canvas and this can this when i had the rectangles are both a twenty the 915 99:59:59,999 --> 99:59:59,999 reason why it shows up to a different place in the screen is because they're 916 99:59:59,999 --> 99:59:59,999 two different and this is in those kind of invisible border here 917 99:59:59,999 --> 99:59:59,999 so you can create cameron text 918 99:59:59,999 --> 99:59:59,999 graphics and interactive altogether and just go to town any questions 919 99:59:59,999 --> 99:59:59,999 all right and i will see you on wednesday