Return to Video

Lecture 21 | Programming Methodology (Stanford)

  • 0:00 - 0:10
    [intro music]
  • 0:10 - 0:14
    This presentation is delivered by the Stanford Center for Professional Development.
  • 0:22 - 0:26
    It's time to delve into a continuation of our last great topic. Okay?
  • 0:26 - 0:30
    So, it's time to continue a bit with our friend the "interactor".
  • 0:30 - 0:34
    And if we think about the interactor, an action listener...so last time we talked about
  • 0:34 - 0:38
    having buttons and buttons-generated action events. Remember that?
  • 0:38 - 0:41
    So we're going to do a brief review of that and push it a little bit further.
  • 0:41 - 0:46
    So one of things we talked about is: how in your program, say, in your init method
  • 0:46 - 0:50
    somewhere you might have "public void init ()"
  • 0:51 - 0:54
    and inside here you would set up sort of the
  • 0:54 - 0:57
    parts of your program that you want to actually do something, like, the various
  • 0:57 - 1:00
    interactors so that when someone clicks on them something happens
  • 1:00 - 1:07
    and then you would say, "add ActionListeners". And what this would do
  • 1:07 - 1:10
    is basically say,"Hey I got some buttons in my program,
  • 1:10 - 1:14
    I want you to be listening for buttons so when someone clicks on a button, I want you to call
  • 1:14 - 1:17
    a particular method for me called 'ActionPerformed'
  • 1:17 - 1:20
    and then based on when you call ActionPerformed, I'll figure out what button was clicked
  • 1:20 - 1:23
    and then actually do something."
    Okay?
  • 1:23 - 1:25
    So, over here we had our friend
  • 1:25 - 1:29
    "public void ActionPerformed"
  • 1:29 - 1:37
    And "ActionPerformed" would get as its parameter something called an "ActionEvent".
  • 1:37 - 1:41
    And an ActionEvent (we'd just refer to it as "e"),
  • 1:41 - 1:43
    was basically what it would check to see
  • 1:43 - 1:47
    what action was actually taken or basically which button was actually clicked. Okay?
  • 1:47 - 1:51
    So hopefully you remember that. That's a little bit of review from last time.
  • 1:51 - 1:53
    Now, when we got this action event we said there are a couple things you could do with it.
  • 1:54 - 1:58
    Well, there is actually one main thing we talked about which you could do with it
  • 1:58 - 2:02
    and you could figure out which command was actually the thing that caused this action event
  • 2:02 - 2:05
    to be generated by saying, "Hey, you know what i want to do?"
  • 2:05 - 2:09
    I wanna pull out as a string (and I'll just call it 'cmd' for 'command')
  • 2:09 - 2:12
    the command, or, the name of the interactor
  • 2:12 - 2:15
    that caused this ActionPerformed method to be called." So here I would say
  • 2:15 - 2:17
    e dot
  • 2:17 - 2:19
    command equals e dot
  • 2:19 - 2:22
    getActionCommand
  • 2:22 - 2:25
    and what GetActionCommand does...it's just a method
  • 2:25 - 2:30
    of this ActionEvent that says,"Hey, I'll return to you the name of the interactor as a string
  • 2:30 - 2:33
    and buttons' names are basically just whatever displays on the button.
  • 2:33 - 2:38
    So then I could have some ifs in here based on this command, "if command dot equals"
  • 2:38 - 2:40
    and I can check for some name, then I might wanna take some action based on that button.
  • 2:42 - 2:45
    It turns out there something else you can ask this ActionEvent e for
  • 2:45 - 2:47
    other than the action command
  • 2:47 - 2:50
    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,
  • 2:50 - 2:54
    so i want to spend a little bit more time on it
  • 2:54 - 2:56
    which is something where you can say, "Hey e,
  • 2:56 - 3:02
    what i want to get from you is not the action command, I want to get the source of the action."
  • 3:02 - 3:07
    Now the interesting thing about what "getSource" returns to you...actually let me not put the semicolon
  • 3:07 - 3:09
    here right now...
  • 3:09 - 3:12
    is getSource actually returns to you an object.
  • 3:12 - 3:17
    It returns to you the object that caused this event to be generated, which means if a button was clicked
  • 3:19 - 3:22
    e.getActionCommand will get the name of the button
  • 3:22 - 3:27
    e.getSource will actually give you a reference to the button object.
  • 3:27 - 3:31
    So what you're getting back from this is an object. You're getting a reference to that object.
  • 3:31 - 3:34
    So, what does that mean for you in, sort of, your everyday life?
  • 3:34 - 3:37
    What that means is: over here when you want to set up your initialization
  • 3:37 - 3:40
    You could say, "Hey I want to create a button."
  • 3:40 - 3:42
    And so i'll have some button i want to create
  • 3:42 - 3:45
    so I'll say "new JButton"
  • 3:46 - 3:49
    and maybe that button, i want it to say "Hi" on it
  • 3:49 - 3:54
    And so one thing I can do is I could say, "hi = new JButton"and "hi"
  • 3:54 - 3:58
    what I'm going to do is make that an instance variable
  • 3:58 - 4:03
    so somewhere down here in my program where I have my ivars, my instance variables,
  • 4:03 - 4:11
    i would have "private JButton hi;"
    So I just do the declaration of a variable called "Hi"
  • 4:11 - 4:13
    which is of type JButton and then in my initialization method
  • 4:13 - 4:17
    i actually create that button with the label "Hi" on it
  • 4:17 - 4:20
    and then i go ahead and add it somewhere to
  • 4:20 - 4:25
    one of the control bars in my programs. So I would say, "add 'hi' maybe to the SOUTH control bar"
  • 4:25 - 4:27
    because we really like adding things to the SOUTH control bar
  • 4:27 - 4:30
    It's just fun when buttons show up on the bottom of our screen.
  • 4:30 - 4:33
    So we say, "Add it there" and then wait for something to happen.
  • 4:33 - 4:35
    So add my action listener in case this button gets clicked.
  • 4:35 - 4:37
    Now when the button gets clicked over here,
  • 4:37 - 4:40
    what i can do
  • 4:40 - 4:41
    as i could actually
  • 4:41 - 4:47
    ask command to get its name. Right? Or I could ask the action event to get the action command name
  • 4:47 - 4:52
    and then i could say something like," if (cmd.equals "
  • 4:52 - 4:56
    and the name of the particular button that i created over there happens to be ("Hi"). If it happens to be "Hi"
  • 4:57 - 5:02
    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.
  • 5:03 - 5:04
    That's one way i could write this
  • 5:04 - 5:07
    and this is kind of the classic way that you've seen it written before.
  • 5:07 - 5:09
    Okay? That's the way you saw it last time.
  • 5:09 - 5:14
    The other way i can write it with my friend "get source" is: rather than getting the name of the command
  • 5:14 - 5:16
    and checking to see if the command is equal to ("Hi")
  • 5:16 - 5:21
    i can actually say, "Hey, you know what? Mehran told me about this thing called e.getSource
  • 5:21 - 5:24
    as a matter of fact i don't even need this line for command
  • 5:24 - 5:27
    anymore let me just comment it out so I don't erase it, okay?
  • 5:27 - 5:33
    And I can say, " if (e.getSource ... this returns an object to me
  • 5:33 - 5:38
    i want to check to see if that object that it returns is my ("Hi") button
  • 5:38 - 5:44
    so here i check directly, is it equal equal to "hi" and then I do whatever I was going to do
  • 5:44 - 5:48
    so this has exactly the same effect as before. It's checking to see if I've gotten a button
  • 5:48 - 5:52
    that is the "Hi" button that was clicked. Okay?
  • 5:52 - 5:56
    so the difference between these two things if you kind of think about them, right?, one of them is
  • 5:56 - 6:01
    i'm just using the name is a string and the other ones i'm using the actual object
  • 6:01 - 6:07
    Now if you think about more deeply what that means if i think about the name over here, right?
  • 6:07 - 6:12
    If i think just in terms of the name i never need to be able to refer to the actual object
  • 6:12 - 6:15
    which means that if i don't need to refer to the actual object again over here
  • 6:15 - 6:20
    I don't necessarily need it as an instance variable. I only need it as an instance variable if I'm going to refer
  • 6:20 - 6:24
    to it again in someplace that's in a different method
  • 6:24 - 6:26
    that's some other method i may have already used it in.
  • 6:26 - 6:31
    So let me show you an example of what i mean by that in code to make that more concrete.
  • 6:31 - 6:33
    Okay, so if we come over here to code
  • 6:33 - 6:35
    here's essentially the code i just wrote
  • 6:35 - 6:39
    for basically creating a button so it's just the code i wrote on the board, right?
  • 6:39 - 6:43
    except I just made the font bigger. i create a button with the name "hi"
  • 6:43 - 6:47
    i put in the southern region. I add my action listeners to listen for that button getting clicked.
  • 6:47 - 6:52
    When the button gets clicked I say, "Hey. Is the thing that got clicked this button I created?"
  • 6:52 - 6:54
    Here i actually called it HiButton.
  • 6:54 - 6:57
    instead of just "hi" over there. I shortened it to "hi" so it would take up less board space.
  • 6:57 - 7:02
    if it's actually the source of that action is not have my high but not all
  • 7:02 - 7:04
    will print out below them
  • 7:04 - 7:07
    so i can go ahead and run this program
  • 7:07 - 7:13
    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
  • 7:13 - 7:14
    hello there
  • 7:14 - 7:17
    now alternatively i could have written some slightly differently which is the
  • 7:17 - 7:18
    way you saw a blast time
  • 7:18 - 7:21
    what i can do here as i can say hey
  • 7:21 - 7:25
    when i'm going to do the added just go ahead and create that button and add it
  • 7:25 - 7:29
    all in one line because i don't need to have some variables it stores the button
  • 7:29 - 7:35
    because down here i'd i need to check for the source of
  • 7:35 - 7:35
    what that action and that was
  • 7:35 - 7:37
    i'm going to have a safe action event
  • 7:37 - 7:39
    give me your command
  • 7:39 - 7:41
    and the command is going to be the name of the button
  • 7:41 - 7:45
    so i no longer need a variable to actually store a reference to the actual
  • 7:45 - 7:47
    button object
  • 7:47 - 7:51
    because this is going to give me the name whenever i needed and so as a
  • 7:51 - 7:53
    result notice your i don't have an instance variable
  • 7:53 - 7:56
    so this is one of those things that's a trade-off it also should give you a
  • 7:56 - 7:59
    little bit more insight into when you have instance variables were so when you
  • 7:59 - 8:00
    don't have instance variables
  • 8:00 - 8:02
    you need to have the instance variable
  • 8:02 - 8:08
    in the case
  • 8:08 - 8:11
    where you need to have
  • 8:11 - 8:12
    and i want the new one
  • 8:12 - 8:13
    you want the instance variable in the case where
  • 8:13 - 8:15
    you want to be able to refer to this variable
  • 8:15 - 8:17
    in some method
  • 8:17 - 8:21
    it's different then perhaps the method which got created right so i created i
  • 8:21 - 8:23
    created the button over here and start somewhere
  • 8:23 - 8:26
    but i need to be able to refer to and some other method so it's got to be an
  • 8:26 - 8:27
    instance variable
  • 8:27 - 8:34
    if i don't need to refer to any other method which is what i saw on the second
  • 8:34 - 8:35
    place
  • 8:35 - 8:36
    i don't need to report would again here is a matter fact there's no other place
  • 8:36 - 8:41
    i need to refer to it after i created then i don't need distorting
  • 8:41 - 8:52
    and questions about her
  • 8:52 - 8:57
    was so that's about the neurological at the computer shouldn't try to figure out
  • 8:57 - 8:59
    which one could if you give it to bond with the same name
  • 8:59 - 9:01
    i have no idea
  • 9:01 - 9:07
    right and it's going to cause you problems they don't do it if you want to
  • 9:07 - 9:08
    see what happens go ahead and dry bread it's a bug in logic not about and what
  • 9:08 - 9:09
    the computers executing
  • 9:09 - 9:19
    any other questions are gone
  • 9:19 - 9:21
    up it's not going to get the actual button so
  • 9:21 - 9:25
    you're saying in this other case ever here
  • 9:25 - 9:29
    what is this thing going to return if i didn't create a variable over here
  • 9:29 - 9:32
    this thing starting to return some reference to your object
  • 9:32 - 9:35
    the only issue for you now though is you have no way of checking for equality
  • 9:35 - 9:39
    with some object right as you know if you don't have the same instance
  • 9:39 - 9:42
    variable you can check to see if that things equal the high button so if you
  • 9:42 - 9:46
    created high button over here just immediately added it never kept track of
  • 9:46 - 9:46
    it over here
  • 9:46 - 9:48
    this guy would return to you
  • 9:48 -
    a pointer too high but menu take right i got appointed a high button how do you
  • Not Synced
    know it's high button
  • Not Synced
    you don't because you have no way of comparing it to the actual hot button
  • Not Synced
    created
  • Not Synced
    and that's why we need to work
  • Not Synced
    so why do i show these to differ quite of doing it the reason why i say these
  • Not Synced
    two different ways of doing it is now you're actually make use of this
  • Not Synced
    with respect to some other interact or is the tracks and see where we care
  • Not Synced
    about doing debt source as opposed to you
  • Not Synced
    the uh... action plan
  • Not Synced
    so what we're gonna do next
  • Not Synced
    is going to say you know allot of times and programs that you really want to
  • Not Synced
    have if you want to have some way of letting the user specified
  • Not Synced
    some taxed
  • Not Synced
    in a program that's running interactively that's not consul right
  • Not Synced
    they'd like to be able to type something and so let me just show you example of
  • Not Synced
    this
  • Not Synced
    dvd buchanan
  • Not Synced
    so you have a program that's got what we refer to as a text feel down here
  • Not Synced
    and i call that name and so if i say hey my name is maryland
  • Not Synced
    it says hello maryland
  • Not Synced
    and then i say are not and i was joking my name is really sally
  • Not Synced
    most of you don't know this
  • Not Synced
    as as a hollow sally right so it's just some way of being able to
  • Not Synced
    have some taxes
  • Not Synced
    field over here that the user fails and in the senate interact a right this is
  • Not Synced
    just one fields dot on the console
  • Not Synced
    and then do some action in the action we have to do here is to write something
  • Not Synced
    the console
  • Not Synced
    that makes use of the tax that the
  • Not Synced
    the use your actually typed in
  • Not Synced
    so how do we get something like that to work
  • Not Synced
    so what we need to do is
  • Not Synced
    av and interact with it's called the text field
  • Not Synced
    and basically text field is
  • Not Synced
    is just epping use alright it's a little place where someone can type some text
  • Not Synced
    isn't interact or such as if it under control bars
  • Not Synced
    and then potentially one make it enter
  • Not Synced
    you get some action event that tells you unique actually or if you want you can
  • Not Synced
    do something with this text
  • Not Synced
    so that's the basic idea what you really get is a box and that's all you get with
  • Not Synced
    it if you want to add a label to that box like the added name over here
  • Not Synced
    we need to sort of specified that
  • Not Synced
    and i'll show you how to do that in just a second but what you're really get at
  • Not Synced
    the box in a new types in something
  • Not Synced
    and then hits began turkey then potentially some of them is generated
  • Not Synced
    for you
  • Not Synced
    so how does that actually set up so the thing we want to create is called ej
  • Not Synced
    text field ok it's just another one of these interact or just like you saw
  • Not Synced
    before we had checkboxes in combo boxes and all that stuff it's just called it a
  • Not Synced
    text field
  • Not Synced
    off named this twenty ab
  • Not Synced
    to stand for text field
  • Not Synced
    and what you do when you trade and you want to be easy to use a new g tax to be
  • Not Synced
    loved and what you've given as a parameter here's the funky thing
  • Not Synced
    you don't give it its label
  • Not Synced
    the label doesn't come with the tax till you need to create the label separately
  • Not Synced
    what you give it is the size of that text feel how big it should be in terms
  • Not Synced
    of the maximum number of characters that would show up in their so if we say ten
  • Not Synced
    for example you're saying is i want to have some text you'll get a hold almost
  • Not Synced
    ten characters and if you some font that's variable with it automatically
  • Not Synced
    gives you the size of like ten ends kazan is the widest character in case
  • Not Synced
    you didn't know that's just life in the city
  • Not Synced
    now the funny thing about this right were let relative to add this action
  • Not Synced
    performed
  • Not Synced
    is one the user hits answer
  • Not Synced
    if i didn't do anything else you would not actually get this call to action
  • Not Synced
    performed
  • Not Synced
    we'll because action performed only called for you for buttons
  • Not Synced
    so what you need to do is after you actually create this text field you need
  • Not Synced
    to say hey you know what
  • Not Synced
    i need to let you know about this text field add something that can generate
  • Not Synced
    actions and so the way you do this is a looks a little bit funky
  • Not Synced
    would you tell the tax field
  • Not Synced
    not and
  • Not Synced
    action listeners
  • Not Synced
    bits to pay
  • Not Synced
    you don't need to worry about all that blood is that actually mean at a very
  • Not Synced
    low level all you need to know if you're telling
  • Not Synced
    this text field
  • Not Synced
    hey guess what
  • Not Synced
    you're going to be able to generate actions now and the thing that you're
  • Not Synced
    going to let people know when you generate some actions is yourself which
  • Not Synced
    is why we pass this
  • Not Synced
    but anytime you create excel the youngest do this once for all text of
  • Not Synced
    the via multiple text fields
  • Not Synced
    you need to send this add action listener this
  • Not Synced
    message
  • Not Synced
    each one independently we only have one year so we only need to do it once here
  • Not Synced
    but what this basically gaza says
  • Not Synced
    auto text field
  • Not Synced
    that you can now generate these action events as well
  • Not Synced
    so after you created any sort of set up this line and you would want to add it
  • Not Synced
    some more inter program write to someone your program you would probably say
  • Not Synced
    bad
  • Not Synced
    kidnapped and we might add ginsburg's ample in the south as we had everything
  • Not Synced
    in the south
  • Not Synced
    when someone takes something and it's yep and hits internet will generate some
  • Not Synced
    call to action event for prefer action performed pasternak shanavas
  • Not Synced
    once that gets set up
  • Not Synced
    how do you actually say grout
  • Not Synced
    what was the text field that generated this about right because you could have
  • Not Synced
    multiple text feels that someone could have typed into it hit the enter key
  • Not Synced
    what you're doing teary-eyed use your friend if you just dot me dot get sore
  • Not Synced
    so inside here which are to say is
  • Not Synced
    he died gets worse
  • Not Synced
    is people equal to so yeah
  • Not Synced
    and at this point all kinds of warning bells should go out for you and so maybe
  • Not Synced
    inside here you won't be something like you want to print len
  • Not Synced
    where you want to say hi and then add to it the tax that's in that text box in
  • Not Synced
    the way you do that as you just say the name of whatever the text field is and
  • Not Synced
    the message you sended is get taxed and what it will give you back
  • Not Synced
    act is it will just returned to you this thing by it's not just returns a string
  • Not Synced
    of whatever's in that box on the user enter
  • Not Synced
    so that's all right out hike and then whatever text they type in just like you
  • Not Synced
    saw on the program except that was writing hello
  • Not Synced
    and maybe that's what we want to do
  • Not Synced
    but the warning bells it should be going off now what's the problem if i've just
  • Not Synced
    written the code like this
  • Not Synced
    it's not an instance variable writes i have no way if this is my payment method
  • Not Synced
    over here i have no way of being able to report that's me up again
  • Not Synced
    out here
  • Not Synced
    so i need to create the instance variable right if this is my new method
  • Not Synced
    public void in eight in front of him
  • Not Synced
    what i need to do is this year somewhere else in my class let's say over here
  • Not Synced
    which is where i declare my art bar's right which is just lower down in the
  • Not Synced
    class umar
  • Not Synced
    i need to actually have prided
  • Not Synced
    jamie
  • Not Synced
    packs
  • Not Synced
    field
  • Not Synced
    grossly out and then over here rather than declaring it
  • Not Synced
    i'd just create the new thier so i need to set it up with an instance variable
  • Not Synced
    okay just like this on the example of the button same kind of thing that's
  • Not Synced
    going on here
  • Not Synced
    except the surtax feels
  • Not Synced
    so let me show you an example of this code inaction
  • Not Synced
    so here's a little text field example what i want to do is i'm going to create
  • Not Synced
    next and the consul program some so i don't have a console
  • Not Synced
    in my hand nick i'm going to have
  • Not Synced
    something called name field what's name field it's just a private j text field
  • Not Synced
    right it's an instance variable so i can save off name field
  • Not Synced
    name field i a nationwide over here to be some new jerry text field of site and
  • Not Synced
    write is exactly what i just saw over there
  • Not Synced
    now when i also want to do here is the one actor funk innocent program i want
  • Not Synced
    to give that box a label so before i add this box to my control bar
  • Not Synced
    i'm gonna adding new jail able with jess says names all j label does it just says
  • Not Synced
    hey i'm going to create something that's just this name
  • Not Synced
    or just this particular these attacks attacks happens to be named and i'm
  • Not Synced
    going to add
  • Not Synced
    to my southern control bar
  • Not Synced
    so forth it's just going to write name out there and then after i write name
  • Not Synced
    i'm going to add to my name field which is going to create the box after name
  • Not Synced
    and then i'm going to show you you know i'm going to do exactly what i told you
  • Not Synced
    where you have to tell me name field
  • Not Synced
    you're going to add action listeners of yourself
  • Not Synced
    so that if you do anything
  • Not Synced
    you're going to let
  • Not Synced
    someone else know that you actually have done some action when the user tight
  • Not Synced
    since you would please enter
  • Not Synced
    that means action performed is going to get called for you because now you're
  • Not Synced
    going to be able to generate events to an action listener
  • Not Synced
    and inaction performed
  • Not Synced
    we check you don't get source we can compare against name field 'cause we
  • Not Synced
    have that saved up down here is an instance variable
  • Not Synced
    and will just right out hello and then the text assisted with name field
  • Not Synced
    and money
  • Not Synced
    increase the tax eyes here
  • Not Synced
    just so it's a little bit bigger and we can all see what's actually going on set
  • Not Synced
    for one
  • Not Synced
    of the wild favorite career twenty four
  • Not Synced
    aquino na make a bigger
  • Not Synced
    yeah the asset just in case victor
  • Not Synced
    so here once again they're on
  • Not Synced
    hello marilyn c and one in those it's getting a bit like it in a row right
  • Not Synced
    enter entertainer entertainers that exerc entertainer
  • Not Synced
    that's another one of things it's only so much fun
  • Not Synced
    trying to sell these were scroll emerge from one
  • Not Synced
    not a lot of time going on their why does this gap of about two minutes maybe
  • Not Synced
    one
  • Not Synced
    so we can do it we can go ahead and do it this way now you can get information
  • Not Synced
    pentax box
  • Not Synced
    any questions about text box
  • Not Synced
    behind the back
  • Not Synced
    yeah so basically the way layout works is every time you add things they just
  • Not Synced
    get added sequentially from left to right in whichever region you're adding
  • Not Synced
    them to in this case the southern region and the whole set of stuff gets honored
  • Not Synced
    so if you want to space stuff out which actually need to do our ad for example
  • Not Synced
    more more j labels that might have to spaces in the mental creates more space
  • Not Synced
    between stuff and there's no economic are just leave it here
  • Not Synced
    ikea
  • Not Synced
    so here's what i think india that's kinda funky is we can actually name of
  • Not Synced
    the text field
  • Not Synced
    you might say but maryland this won't get source thing yeah yeah keep around
  • Not Synced
    the instance there but i'm not so keen on that
  • Not Synced
    what i am comwork you not is giving things name so i can just refer to them
  • Not Synced
    by their name inside ok thats cool you can you can have a name
  • Not Synced
    so here that exact same example just slightly differently what i want to do
  • Not Synced
    is on the air
  • Not Synced
    had just one more line here so this is exactly the same code i had before
  • Not Synced
    except after i create the name field i say hey name field
  • Not Synced
    i want to give you an action need
  • Not Synced
    and that were an action command and your action command is going to be name
  • Not Synced
    so whenever you generate these events yeah i can check to see if your sources
  • Not Synced
    actually but the source of that event is you
  • Not Synced
    or if i've given you a name
  • Not Synced
    i can do the same thing i just did with buttons which is down here i can get
  • Not Synced
    action command that gives me the string which is the name of the object the
  • Not Synced
    created this event
  • Not Synced
    and i can see if it's equal to name which is the name that i gave it
  • Not Synced
    so that's just showed you a little back and forth with buttons i kinda showed
  • Not Synced
    you got for it with buttons you just need them cuz you always name buttons
  • Not Synced
    will check against names
  • Not Synced
    but you could actually
  • Not Synced
    check against the source of the button if you want to
  • Not Synced
    gatech still just kinda backwards j text field you always
  • Not Synced
    in some sense have the tax field that you can get with debt source but if you
  • Not Synced
    want to report will by name you have to explicitly given name because name
  • Not Synced
    doesn't show up as part of it right if we want the label we still need to add
  • Not Synced
    the separate label name over here
  • Not Synced
    this is just naming the particular events that come from that box that's
  • Not Synced
    all it does
  • Not Synced
    answer any questions about them
  • Not Synced
    at the max max shows
  • Not Synced
    oss
  • Not Synced
    yen named feel the stand i've are here it's really actually no longer necessary
  • Not Synced
    cuz i don't need to refer to it over here so if i wanted to make it just is
  • Not Synced
    deep sting little campaigns spank sidebars thanks for playing that's real
  • Not Synced
    nice of you
  • Not Synced
    and everything's
  • Not Synced
    although i can't
  • Not Synced
    that's why i did in here cause i still need to refer to it over here to get its
  • Not Synced
    what i could to be honest actually what i could do is i could just
  • Not Synced
    call you get source here and get it source and get it stacks i really don't
  • Not Synced
    need to
  • Not Synced
    but it is better stock that makes it clear that i'm getting the texture so
  • Not Synced
    there is a way around it
  • Not Synced
    but the cleaner ways to actually do it this way
  • Not Synced
    already
  • Not Synced
    get rid of the declaration
  • Not Synced
    that's like c
  • Not Synced
    sang questions about that j text field
  • Not Synced
    uh... yeah
  • Not Synced
    on weekends
  • Not Synced
    and i'll show you that no about twenty minutes
  • Not Synced
    but hand free seats away so before we get there
  • Not Synced
    it's not something completely different
  • Not Synced
    and i think it's completely different is this a how to get to the question in the
  • Not Synced
    back of the room which is
  • Not Synced
    and they're on these things are all sort of showing up centered on the bottom of
  • Not Synced
    the screen cut i actually have these enter actor is laid out a different way
  • Not Synced
    than this way that they're getting laid out for me and in fact you can and
  • Not Synced
    strangely enough the thing you used to do that is called a layout
  • Not Synced
    so i'll let you know controls the layout a particular interactions now it turns
  • Not Synced
    out when you use your friendly console program
  • Not Synced
    or your friend of the graphics program
  • Not Synced
    what you got was a layout was called the border layouts and he was a matter of
  • Not Synced
    fact artists on the border layouts
  • Not Synced
    you saw the boarder layout last time it looked like this
  • Not Synced
    which is you had some cena region you had a north south east and west borders
  • Not Synced
    which is why this thing called a border layout
  • Not Synced
    and what you
  • Not Synced
    what happened with that
  • Not Synced
    what happened with this border layouts
  • Not Synced
    powerpoint wants comply
  • Not Synced
    it at the center was were all the action takes place
  • Not Synced
    the console program would add a console to the sensor automatically right that
  • Not Synced
    is what happens in a consul program and a graphics program would added g canvas
  • Not Synced
    to the center automatically which is what you're going to draw your stuff
  • Not Synced
    and the other regions are only visible if you add stuff to them so in the very
  • Not Synced
    early days when you had a graphics program
  • Not Synced
    that was all just graphics you would say hey mera nothing showed up at is the
  • Not Synced
    self region
  • Not Synced
    yeah 'cause we didn't put any interact or if they are so
  • Not Synced
    these enter actor region's only show up if we actually put in a raptor on
  • Not Synced
    rightly said these are referred to as control bar say saudis last time
  • Not Synced
    so how do i consider different kinds of layouts so there's a couple of other
  • Not Synced
    layout also think about their something called a greed layout
  • Not Synced
    and and the land grant layout works is you actually creighton object called
  • Not Synced
    agreed to lay out and you specify inaccurate lay out how many rows and
  • Not Synced
    columns are in the great layout so
  • Not Synced
    we might take you rosen three columns which means we're going to have a laying
  • Not Synced
    out the look something like this is just a grade with two rooms in three columns
  • Not Synced
    and i say that the code for this in just two seconds and then the nitty-gritty
  • Not Synced
    details
  • Not Synced
    but conceptually here's what it is
  • Not Synced
    now when i had i'd ims so what i do as i say hey you know what i want to set my
  • Not Synced
    layout to leave is great layout
  • Not Synced
    what now happens when i had i done is is it will add items the items being the
  • Not Synced
    interact urs
  • Not Synced
    one-by-one starting at the top most role in the leftmost center in the last most
  • Not Synced
    square
  • Not Synced
    and every time i add a new element it moved over by one until i get to the end
  • Not Synced
    of the row and then it automatically comes down so go sequentially across row
  • Not Synced
    by roe
  • Not Synced
    but allows me to contemplate things that may grade
  • Not Synced
    if i want to actually be able to do things and agreed so let me show you an
  • Not Synced
    example of what a grid layout might look like
  • Not Synced
    world on with you lou died
  • Not Synced
    so great layout
  • Not Synced
    here's a simple program it has a great layout what we do is we start off
  • Not Synced
    inordinate method by saying
  • Not Synced
    hey you know what i want to create a layout
  • Not Synced
    so i want to set the existing layout that the program is going to use to be a
  • Not Synced
    new grid layout that's to come at three to rose by three columns
  • Not Synced
    now one thing that's interesting about this program if you look at great layout
  • Not Synced
    example
  • Not Synced
    it does not extend consul program
  • Not Synced
    it does not extend graphics program these are not expiry of four house and
  • Not Synced
    it's beautiful life and it's beautiful children
  • Not Synced
    what have i done
  • Not Synced
    what i've done is set i'm just going to extend the program i don't want you to
  • Not Synced
    create a console for me and i don't want you to create a g canvas for me
  • Not Synced
    cuz i want to take up the whole story with my barnes baby
  • Not Synced
    so that's what i'm gonna do
  • Not Synced
    almanac
  • Not Synced
    six new buttons and these bonds are just going to get sequentially ad in the
  • Not Synced
    order you just saw and then i'm not saying a tad weiss action listeners
  • Not Synced
    and i'm not going to do anything understanding or the buttons but what i
  • Not Synced
    really the reason why i'm doing this
  • Not Synced
    is i just want to see some big fab but
  • Not Synced
    on the air like that
  • Not Synced
    six buttons that take up to the whole scream
  • Not Synced
    it's a good
  • Not Synced
    my enter actors filled up the graded
  • Not Synced
    the layout takes up as much space as possible in the screen and more
  • Not Synced
    importantly each of the interac yours that i put into agreed cell takes up as
  • Not Synced
    much cell as much space and the cell as possible so there's one comes along and
  • Not Synced
    says
  • Not Synced
    all yeah i got so much space on lay down your likely why why do you do this is
  • Not Synced
    the most bring everything ever i don't hahahaha
  • Not Synced
    lying
  • Not Synced
    didn't have any plan that separately
  • Not Synced
    driving everyone talk about a right now
  • Not Synced
    maybe afterwards
  • Not Synced
    such as frightening as like avnet sound effects got
  • Not Synced
    check this out as i resize the window all bein small uncw big buttons
  • Not Synced
    that's why we
  • Not Synced
    have layout managers because the layout manager just gives conceptually says
  • Not Synced
    this is how your layouts going to be
  • Not Synced
    and it says i'm going to handle all the dynamics of resizing and all that stuff
  • Not Synced
    for ups_ people resize the window
  • Not Synced
    but i need to know how things are laid out and if you give me more space
  • Not Synced
    then i need to understand the take it out
  • Not Synced
    great layout not so useful page or something to seize taken if you see in
  • Not Synced
    the book you know it's talking about
  • Not Synced
    there's another kind of layout
  • Not Synced
    which is called a table layout
  • Not Synced
    so that's another kind of lay out all the flow layout when i can talk about it
  • Not Synced
    all
  • Not Synced
    but there's something called a table layout
  • Not Synced
    any table layout is basically just like agreed layout except for the niceties so
  • Not Synced
    you also give it a number of rows and columns
  • Not Synced
    except where it says is rather than having each one of the interact urs fill
  • Not Synced
    up itself a maximum possible size
  • Not Synced
    i'm just going to give that enter actor as much space is it needs in that cell
  • Not Synced
    and no more
  • Not Synced
    so what does that mean
  • Not Synced
    that means if i come in here rather than a grid layout i say i want to create a
  • Not Synced
    new table layout
  • Not Synced
    and i run this
  • Not Synced
    co-ordinate add more imports
  • Not Synced
    are a little guide
  • Not Synced
    i mean just grab the imports from over here
  • Not Synced
    me
  • Not Synced
    you happy
  • Not Synced
    of graphics sorry
  • Not Synced
    come on table layout
  • Not Synced
    though table layout
  • Not Synced
    let me just show you the
  • Not Synced
    nice for example it cable
  • Not Synced
    didi
  • Not Synced
    sometimes in life
  • Not Synced
    he just got to get on with it
  • Not Synced
    we got ugly with it
  • Not Synced
    table layout
  • Not Synced
    there's table layout
  • Not Synced
    six button still
  • Not Synced
    we can spell resize the window but the button there just given as much sizes
  • Not Synced
    they would actually need they don't fill up the whole
  • Not Synced
    region of the actually ma
  • Not Synced
    table layout such something slightly more useful for us than great layout to
  • Not Synced
    the question came up before which was
  • Not Synced
    hey can i actually link like buttons and text fields together
  • Not Synced
    to create something a little bit more funky and in fact i can do that
  • Not Synced
    initially that any context outside something aloo bit more interesting
  • Not Synced
    which is a program that allows for conversion in temperature so this one's
  • Not Synced
    actually in the books i didn't give me the code because although
  • Not Synced
    cody is actually a the coated on the books i didn't get a chance ever handout
  • Not Synced
    they say it is where i got a label called degrees fahrenheit a label called
  • Not Synced
    degrees celsius
  • Not Synced
    and inside here we can type in some value and if we click fahrenheit to
  • Not Synced
    celsius
  • Not Synced
    it will automatically oil
  • Not Synced
    fill in the southeast field of course one value separately to is zero celsius
  • Not Synced
    the other thing that's kinda funky if i don't necessarily have to click the
  • Not Synced
    button i can type in say some value and hit enter
  • Not Synced
    and that's just like
  • Not Synced
    clicking the button
  • Not Synced
    interesting so how do i create this program well if you think about this
  • Not Synced
    program first i'm going to need is these things are not supersized but they're
  • Not Synced
    all laid out in a grade so i'm going to need a table layout
  • Not Synced
    that has to rosen three columns
  • Not Synced
    the first
  • Not Synced
    element that i have here is just the label that i'm going to have a field
  • Not Synced
    that the text field as a matter fact i have a specialized kind of text field
  • Not Synced
    owners to specialize context field
  • Not Synced
    something called the into field and a double field
  • Not Synced
    they work just like text fields except you're guaranteed to get an integer
  • Not Synced
    value were double value from the menu mighty but now and what happens if
  • Not Synced
    someone types and and wants to come for a twitter butcher
  • Not Synced
    i clicked the wrong button they want to convert age were temperature
  • Not Synced
    it says an internet injuring two brings up this pop-up box and gets in their
  • Not Synced
    face and say oh yeah sorry my bad
  • Not Synced
    so guarantees you get a major
  • Not Synced
    and then i'm going to have a button and somehow i want to link the button and
  • Not Synced
    the tax bills to do the same action
  • Not Synced
    so let me show you the car for that it's actually a lot shorter than it looks
  • Not Synced
    like
  • Not Synced
    first thing to do is a case at the layout to be a table layout notice once
  • Not Synced
    again here i am extending a program 'cause i don't want to console or canvas
  • Not Synced
    created for me
  • Not Synced
    i want to be able to specify the whole layout
  • Not Synced
    so i'm just extending a program
  • Not Synced
    i say set the layout to be a table layout to come in three
  • Not Synced
    and again we're going to go sequentially through all the elements of what i want
  • Not Synced
    to have in the first
  • Not Synced
    element
  • Not Synced
    basically the first thing i want to add to my layout i don't specify intel down
  • Not Synced
    here the very first thing to add to my layout is
  • Not Synced
    degrees fahrenheit as a label
  • Not Synced
    then i'm going to add some fahrenheit field what how did i create that
  • Not Synced
    fahrenheit field actually created it up here
  • Not Synced
    what i did
  • Not Synced
    first was declaring it as an instance variable so fahrenheit field isn't ants
  • Not Synced
    field not agape text field that you feel which is just a specialization of eighty
  • Not Synced
    eight ext field
  • Not Synced
    to just give you back a major other than that it works just like a text field
  • Not Synced
    except drugs one show you any feel totally feel
  • Not Synced
    so i created new and field i specified financial value not its initial sides
  • Not Synced
    but its initial value
  • Not Synced
    its initial value is thirty two
  • Not Synced
    then when i say is hey fahrenheit field
  • Not Synced
    i'm going to set your action command
  • Not Synced
    so that when you generate actions the name associated with the actions that
  • Not Synced
    you generate
  • Not Synced
    is going to be af
  • Not Synced
    dash greater than which we can just think of as a rogue c
  • Not Synced
    that's going to be your name so i said its name and i say you're going to
  • Not Synced
    generate action events
  • Not Synced
    someone adn action listener g love yourself
  • Not Synced
    okay just like you sabi for the text helix up now we're going with an infield
  • Not Synced
    we do exactly that same thing with something called the southeast feel
  • Not Synced
    tells his films also declared to be an infield
  • Not Synced
    it starts off the national volume zero we set it's action command to bc goes to
  • Not Synced
    ap as opposed to ap goes to see so we give it a slide a different name
  • Not Synced
    and we also set yet to listen to action events
  • Not Synced
    okay or did generate action events
  • Not Synced
    and then we're going to lay out our great so first element of the great is
  • Not Synced
    the label as we talked about before
  • Not Synced
    next element of our great is our little text box that's going to actually have
  • Not Synced
    the numeric value in it
  • Not Synced
    and last elements of our great on the first of all of the greatest
  • Not Synced
    is a button that's name is bath goes to see
  • Not Synced
    and you look at this and you say hey marron if i have a button its name is
  • Not Synced
    apt goes to see and i named this guy af goes to see
  • Not Synced
    aren't i getting back to the previous point over here of whether that's the
  • Not Synced
    logical problem where i actually have two elements that have the same name
  • Not Synced
    yeah bday i have to always have the same name but i want to do exactly the same
  • Not Synced
    thing in both cases so it doesn't make a difference
  • Not Synced
    so what i want to do is say someone clicks the button
  • Not Synced
    i'm going to do the conversion so i'm going to have some kind of those who do
  • Not Synced
    the conversion
  • Not Synced
    if someone type something in the text field it hits enter
  • Not Synced
    i'm going to do the same thing
  • Not Synced
    so this is something you see a lot of times on the web where for example if
  • Not Synced
    there's a search engine you use you type in the search engine then click search
  • Not Synced
    or you can just take enter how many people actually click the search button
  • Not Synced
    no one how many people just and hit enter
  • Not Synced
    yet isn't it nice that you can just hit enter
  • Not Synced
    that's the same thing we're doing in this program which is why we went
  • Not Synced
    through the extra rigmarole of setting this action command here
  • Not Synced
    'cause sometimes it's just nice to hear and
  • Not Synced
    and we do exactly the same thing for the grease celsius
  • Not Synced
    the name that was so we add that labeled degree celsius we had the southeast
  • Not Synced
    field and then we create a new button whose name is the same as the action
  • Not Synced
    command for the celsius field
  • Not Synced
    and then we add action listeners that sets up our entire user interface or
  • Not Synced
    entire graphical user interface and a good week
  • Not Synced
    and then when the user clicks on a button we say hey
  • Not Synced
    let me get the action command if the action commands f goes to see which
  • Not Synced
    means you are they type something in the fahrenheit field and hit enter
  • Not Synced
    or they click the button
  • Not Synced
    then i'll get the value in the hair fahrenheit field
  • Not Synced
    because fahrenheit field integer field i just always gives me back in a major
  • Not Synced
    and i do a little bit of math if you don't know the map conversion from
  • Not Synced
    fahrenheit the celsius
  • Not Synced
    don't worry about it this is just how you convert from fahrenheit celsius
  • Not Synced
    you taking nine fifth times the fahrenheit value minus thirty two and i
  • Not Synced
    give you the celtics value now you know
  • Not Synced
    what i do more interestingly if i set the value in the celsius field
  • Not Synced
    to be whatever value i computed
  • Not Synced
    so someone just type something into the fahrenheit feel that he enter or click
  • Not Synced
    the ftc_ button
  • Not Synced
    but in what i do to update the screen is ice change whatever values in the
  • Not Synced
    celsius field
  • Not Synced
    and i destroy the receptacle of that or i should say that
  • Not Synced
    compliment reciprocal the inverse the mirror image how many words can you come
  • Not Synced
    up for the same thing
  • Not Synced
    of that if someone does see dat
  • Not Synced
    which is i get the value that's in the celsius field
  • Not Synced
    i do the map it's necessary to convert herself if the fahrenheit nice at the
  • Not Synced
    fair field and that's the whole program right here is my instant variables
  • Not Synced
    so if i run
  • Not Synced
    my little temperature program
  • Not Synced
    i have my label
  • Not Synced
    i have my initial value and i have my fahrenheit to celsius and if i put in
  • Not Synced
    some value here like a hundred degrees fahrenheit
  • Not Synced
    is thirty eight degrees celsius
  • Not Synced
    and two hundred twelve degrees fahrenheit will not touch the mouse just
  • Not Synced
    hit on me in turkey
  • Not Synced
    uh... an er does the same thing is if i click the mouse and same thing on the
  • Not Synced
    second phase zero celsius
  • Not Synced
    the actor into good times and not created a whole program of the graphical
  • Not Synced
    user interface and i'd like to resize and it just doesn't know a lot always
  • Not Synced
    centers for me is not nice if i make it east mall
  • Not Synced
    while these things don't get too small just sent a i can see the screen that's
  • Not Synced
    what the state
  • Not Synced
    any questions about that
  • Not Synced
    how can use the mikes please
  • Not Synced
    i gotta keep reminding everyone views the microphones
  • Not Synced
    p
  • Not Synced
    but you can look really good
  • Not Synced
    uh... there are ways the with table layout you can actually get it whatever
  • Not Synced
    fortuitous at hands
  • Not Synced
    to actually specify different sizes for things and i just didn't do that here
  • Not Synced
    it's in the book if you want to do a but we're not going to
  • Not Synced
    try to push it out for in this class use it but there are ways you can
  • Not Synced
    so one final thing that we want to do is you might say all this is all good well
  • Not Synced
    mirror on yeah i'm not kind of fun but
  • Not Synced
    really what i like to some text in some graphics together and i want to interact
  • Not Synced
    recycle wanted all right
  • Not Synced
    i want tax taiwan wrapped on interactive you think back to busy rethinking man
  • Not Synced
    hangman you had texting had graphics
  • Not Synced
    but she didn't have interacted
  • Not Synced
    here you have interact there is and i show you example interact arisen tax
  • Not Synced
    twenty click the button and said hi and you know
  • Not Synced
    gave your name or whatever now it's time to roll the enchilada and put them all
  • Not Synced
    together in our friend
  • Not Synced
    text and graphics
  • Not Synced
    so what text and graphics is going to do
  • Not Synced
    is it basically what we want to think about is having some consul in the
  • Not Synced
    program
  • Not Synced
    and the graphics canvas in the program and interact or is in the program so we
  • Not Synced
    can just go to town and do whatever you want to do
  • Not Synced
    how do we make this happen
  • Not Synced
    first thing we're going to do
  • Not Synced
    you had a little bit text on the board just to get out there a little
  • Not Synced
    blood circulating in your legs and i know nothing about blood clots in your
  • Not Synced
    legs where you're actually traveling too long on planes and blood clot
  • Not Synced
    yeah we want to talk about that
  • Not Synced
    i didn't give you a small hands of a save your life beverage traveling on a
  • Not Synced
    trip is longer than two hours sometime during the trip or multiple times get up
  • Not Synced
    and walk around
  • Not Synced
    it will save your life
  • Not Synced
    but nigger ever giving a lecture for longer than two hours
  • Not Synced
    get up and walk around it'll save your life to not be the blood clots but
  • Not Synced
    because your students would tell you have to drive you just sitting there
  • Not Synced
    going like all i know not good bread that layout were which we're not going
  • Not Synced
    to get into it
  • Not Synced
    but is it accidentally so text and graphics
  • Not Synced
    she retains the taste great together
  • Not Synced
    you can decide which ones chocolate and which ones peanut butter
  • Not Synced
    lettuce text and graphics and so it's like hangman but with interactives
  • Not Synced
    so what we're going to do is we're going to extend consul program
  • Not Synced
    and the reason why we're going to extend the consul program he's we still need
  • Not Synced
    our plan the console that's what we're going to get the text portion of doing
  • Not Synced
    this interaction
  • Not Synced
    it's from having the consul program
  • Not Synced
    and so what we have a console program what please give this is it gives us
  • Not Synced
    the borders
  • Not Synced
    that we've come to know when law writing gives us the north border in the south
  • Not Synced
    border and western he's and these are places where we can still play so enter
  • Not Synced
    actors
  • Not Synced
    the interesting thing is what's going on in the center region
  • Not Synced
    and what i told you before the consul program
  • Not Synced
    fills up the senate region with a place where you can put text and that's all
  • Not Synced
    you can do with it
  • Not Synced
    so what we're going to say it a consul program what i want to do is in the
  • Not Synced
    center regent i want to give you a different layout and put stuff in that
  • Not Synced
    lady out
  • Not Synced
    second potentially have some text in some graphic
  • Not Synced
    uh...
  • Not Synced
    so what am i going to do
  • Not Synced
    the first thing i want to do is i'm going to think about having some layouts
  • Not Synced
    okay mine layouts going applied to this middle region
  • Not Synced
    the important thing to keep in mind as the console program what used to be was
  • Not Synced
    created console the filled up the entire region
  • Not Synced
    now what i'm going to get is a console as my first elements
  • Not Synced
    which means however i do the layout whatever i do and that lay out the very
  • Not Synced
    first thing like what i have a great that has three elements to it one row
  • Not Synced
    the first elements of that
  • Not Synced
    will be my consul
  • Not Synced
    that you don't have any control over just because of the way the consul
  • Not Synced
    program works the first elements of whatever layout you used when you extend
  • Not Synced
    the consul program create a layout for wall waise bhi your whatever your text
  • Not Synced
    it's
  • Not Synced
    now you said hey
  • Not Synced
    there on your awesome tell me about graphics but if i'm doing with the
  • Not Synced
    consul program how do i get graphics
  • Not Synced
    we give a little trick we did in hangman which is there's this thing called the g
  • Not Synced
    candidates
  • Not Synced
    and what we're going to do is create agee kandicn digi cam this importantly
  • Not Synced
    is actually something that we can add to a linux
  • Not Synced
    so what i can do is say hey crave my consul program i'm going to create some
  • Not Synced
    layout but sam i have a great that's
  • Not Synced
    i'm going to create some sort of way out like maybe i have agreed me out
  • Not Synced
    one comment three
  • Not Synced
    which would give me dressed
  • Not Synced
    i know that my first things i think up my my console what i want to do is
  • Not Synced
    creepy g canvas
  • Not Synced
    and ad that you can visit is my second elements
  • Not Synced
    and just to be super cool to give you something that normally you'd have to
  • Not Synced
    pay twelve ninety five four but i want to get at you for for
  • Not Synced
    we're going to create another g hands and added over here so that she can this
  • Not Synced
    bills
  • Not Synced
    so what we get is consul and to different g canvases
  • Not Synced
    plus we can still add interac result round or screen
  • Not Synced
    at this point you should be looking at this and shock horror and delight and
  • Not Synced
    going
  • Not Synced
    okay marron let's all put it together and five minutes because it's just that
  • Not Synced
    he
  • Not Synced
    so here's how it works
  • Not Synced
    text and graphics ike's ten console program
  • Not Synced
    okay 'cause that's going to get my consul
  • Not Synced
    in miami i say set the layout
  • Not Synced
    on one new grid layout remember great layout the elements of the great layout
  • Not Synced
    expand to take how much space you give them
  • Not Synced
    that's what i want in this case
  • Not Synced
    because what i want to say as i want to have a great i want to give the consul
  • Not Synced
    one-third of the whole grade and cute and this is another third of those
  • Not Synced
    grades and grown too is large as they can be
  • Not Synced
    then i'm going to do is i'm going to create to canvass so i need to have some
  • Not Synced
    instance variables to refer to these canvases
  • Not Synced
    i am i have to canvases
  • Not Synced
    which are just type is g canvas by private labels i will call them the
  • Not Synced
    right canvas and the left hand yes
  • Not Synced
    animals have a text field in this program just for laughs just cuz i can
  • Not Synced
    and that's going to be one of my characters so i want to have interact
  • Not Synced
    respect graph
  • Not Synced
    what am i going to do
  • Not Synced
    first thing to do it on to say that left canvas create a new canvas
  • Not Synced
    that can viz
  • Not Synced
    and when i do this add it's adding it to my laid out
  • Not Synced
    ham adding a whole candid so what is that do it says hey told me got a great
  • Not Synced
    layout here ive already filled in the first thing with the console 'cause
  • Not Synced
    that's what i do on the console program
  • Not Synced
    you just told me to add a canvas
  • Not Synced
    element number two will be the canvas
  • Not Synced
    i do the same thing again for white canvas element number three is not the
  • Not Synced
    right and so i have to big canvasses on there as the second and third elements
  • Not Synced
    of my grade
  • Not Synced
    i got a console
  • Not Synced
    grid canvas tents not going to add to interact with because it's just that
  • Not Synced
    cool i'm going to create a text field which they knew gatech steel text field
  • Not Synced
    i declared as a private instance variable i just showed you that
  • Not Synced
    maximum size is ten
  • Not Synced
    i will add a label to it and the label just going to be called some text
  • Not Synced
    sold the rights some tax
  • Not Synced
    in the southern region
  • Not Synced
    that'll adam i text field in the southern region and that ads at this
  • Not Synced
    point you should come to know involved you always gotta remember to add your
  • Not Synced
    action list are very common thing that happens people create a text field and
  • Not Synced
    their type in an end stuff in the program enough things happening in their
  • Not Synced
    tearing their hair and they're wondering why
  • Not Synced
    they just forgot to add the action list you know it learn it live it probably
  • Not Synced
    it's a good time
  • Not Synced
    action listener for your text field
  • Not Synced
    and then i would have to buttons just for good times so i have my tech said
  • Not Synced
    i'm gonna have to more buttons a button that says draw on the left
  • Not Synced
    and a button that says draw on the right
  • Not Synced
    so i mean show you what all these things are going to do
  • Not Synced
    before i show you the rest of the program
  • Not Synced
    so what i want to show you text and graphics
  • Not Synced
    uh...
  • Not Synced
    out my consolation
  • Not Synced
    i have to you can see them but they are side by side q different canvas windows
  • Not Synced
    over here here's some text i can type in high
  • Not Synced
    you typed
  • Not Synced
    while
  • Not Synced
    that exciting
  • Not Synced
    drama left in my left hand that some just run rectangles offsite i do that
  • Not Synced
    just a second
  • Not Synced
    draw a right
  • Not Synced
    drawing in my right candidates
  • Not Synced
    how did i make that happen alright on your share of the programme so i've set
  • Not Synced
    everything up right console to canvases
  • Not Synced
    text field and two buttons at the bottom
  • Not Synced
    here is where all the actions going on when action performed is called right i
  • Not Synced
    mean someone's interacting with one of the interact urs there's nothing else i
  • Not Synced
    can do in the program except interact with one of the inner actors
  • Not Synced
    first a check for the text field if the interaction with the text field so if
  • Not Synced
    the source of the interaction with the text field i write about you typed and
  • Not Synced
    the text of the text field this will go into the consul biggest anytime you do
  • Not Synced
    applicable in the text always goes in the consul so it just shows up in the
  • Not Synced
    consul not a whole lot exciting going on there
  • Not Synced
    alternatively if the thing they did was not stipe into the text field
  • Not Synced
    they clicked one of the bottoms so i say hey i'm showing i could've been there
  • Not Synced
    done all with get sore throat always get action command
  • Not Synced
    i'm using both just to show you that you can mix and match if you want
  • Not Synced
    so i say hey what was the command get action command
  • Not Synced
    if it was drawl left then what i want to do is i'm going to create a new field a
  • Not Synced
    rectangle let me show you create new filled rectangle it's very simple
  • Not Synced
    it just
  • Not Synced
    creates a rectangle that's fifty by twenty and yes they should have been
  • Not Synced
    constant i didn't make them conference i wouldn't have to scroll down and show
  • Not Synced
    you the constant
  • Not Synced
    i said to be filled
  • Not Synced
    and i return the rectangle solid does is create a filled rectangle on say hey
  • Not Synced
    your ego
  • Not Synced
    and although i do is i take that filled rectangle and i added
  • Not Synced
    to my left hand dates
  • Not Synced
    so because that's not a graphics program i can just a tad with the rectangle one
  • Not Synced
    added if i want to add the rectangle somewhere i need to specify which canvas
  • Not Synced
    of my adding a few i'm adding it's the left campus icao left hand this ads
  • Not Synced
    yourself this rectangle where you can add it x location twenty and at one
  • Not Synced
    location left y
  • Not Synced
    left wide starts out with the value ten
  • Not Synced
    and every time i add something i'd space down my wife's i'm just making wide go
  • Not Synced
    down to buy some spacer mt which is thirty so i was doing is trying a
  • Not Synced
    rectangle and essentially moving down toward drachmir x next rectangle below
  • Not Synced
    it moving down to draw the next rectangle below it
  • Not Synced
    and i do exactly the same thing for the right hand side
  • Not Synced
    except after a quick quick filled rectangle i have a separate whitewater
  • Not Synced
    which keeps track of how low of gotten on that side in terms of the white ford
  • Not Synced
    net
  • Not Synced
    and i add to the right canvas
  • Not Synced
    that's the only difference
  • Not Synced
    so when i run this program
  • Not Synced
    right some text
  • Not Synced
    right again if i type and great
  • Not Synced
    by typing great
  • Not Synced
    and hit enter it generates the event which does the sprint lynn on the screen
  • Not Synced
    right it generates this event over here this action performed
  • Not Synced
    the source was text field and i write out the text on the screen
  • Not Synced
    if i click on one of the buttons drama apt
  • Not Synced
    draws the filled rectangle and its incremented the why on the left hand
  • Not Synced
    side for next time i clicked route left
  • Not Synced
    it draws at lower and lower and lower and dry right does the same thing
  • Not Synced
    notice of the x location for both
  • Not Synced
    this canvas and this can this when i had the rectangles are both a twenty the
  • Not Synced
    reason why it shows up to a different place in the screen is because they're
  • Not Synced
    two different and this is in those kind of invisible border here
  • Not Synced
    so you can create cameron text
  • Not Synced
    graphics and interactive altogether and just go to town any questions
  • Not Synced
    all right and i will see you on wednesday
Title:
Lecture 21 | Programming Methodology (Stanford)
Description:

Lecture by Professor Mehran Sahami for the Stanford Computer Science Department (CS106A). Professor Sahami continues lecturing on interactions and pushes it further.

CS106A is an Introduction to the engineering of computer applications emphasizing modern software engineering principles: object-oriented design, decomposition, encapsulation, abstraction, and testing. Uses the Java programming language. Emphasis is on good programming style and the built-in facilities of the Java language.

Complete Playlist for the Course:
http://www.youtube.com/view_play_list?p=84A56BC7F4A1F852

CS106A at Stanford Unversity:
http://www.stanford.edu/class/cs106a/

Stanford Center for Professional Development:
http://scpd.stanford.edu/

Stanford University:
http://www.stanford.edu

Stanford University Channel on YouTube:
http://www.youtube.com/stanford

more » « less
Video Language:
English
Duration:
47:39
codecrystal edited English subtitles for Lecture 21 | Programming Methodology (Stanford)
Eunjeong_Kim added a translation

English subtitles

Incomplete

Revisions