Java Programming: 8 - Using Objects, creating a window

Поделиться
HTML-код
  • Опубликовано: 14 ноя 2024

Комментарии • 77

  • @paramz100
    @paramz100 4 года назад

    Honestly, THIS is video series I have been looking for. Super easy to follow and I can understand this material. Thank you.

  • @emabuono9992
    @emabuono9992 10 лет назад

    My native language is spanish but i understeand this tutorial better than any other spanish tutorial i've seen. Thanks and keep it up.

  • @PossessWithin
    @PossessWithin 11 лет назад +9

    That is for SURE the best lesson I've ever had about java. THANK YOU!!!!!!!!!

  • @stinkymans5002
    @stinkymans5002 6 лет назад

    CodeMonkeyCharlie You are literally better than my Java 1 teacher. Thank you so much. I love how you teach and it seems so straightforward

  • @JoshBrownPhotography
    @JoshBrownPhotography 10 лет назад +9

    FAR more informative, and detailed, than all the other videos I've come across thus far. Great Job! Liked, and Sub'd!

  • @balajikrishnamoorthy5464
    @balajikrishnamoorthy5464 7 лет назад

    Thanks for deep description on Java objects. Its is very clear.

  • @pkgamma
    @pkgamma 7 лет назад

    Just 20 minutes before my CS125 quiz this sure helped me a lot. Thanks. Ready for the quiz now.

  • @FlyffDeveloper
    @FlyffDeveloper 10 лет назад +1

    Excellent tutorials, explained, commented and defined for us. Keep it coming!

  • @CodeMonkeyCharlie
    @CodeMonkeyCharlie  12 лет назад

    Generally speaking you should only make the window visible after everything has been added to it, which should make sure everything gets drawn.
    You could also at some point call repaint(), but if you're setting up a UI that isn't going to change, it is best to completely build the UI prior to making the window visible.

  • @TheSiva2012
    @TheSiva2012 6 лет назад

    I learned C++ so i can understand but java is such a wonderful language to learn. your teaching very crystal clear to me. you offering a great service to us. God bless you. Thanks Sir.(I have deitel's java How to learn sir)

  • @CodeMonkeyCharlie
    @CodeMonkeyCharlie  12 лет назад

    It's faster to use code completion once you get the hang of it. Eclipse will use context to help you out as well. For example, if you have BufferedInputStream imported, type bu, and press control + spacebar, that will be your first option.
    So you can type a couple letters, use the shortcut and press enter to complete. It allows for very rapid development, helps to reduce human error due to misspellings and such, and helps you learn by showing you some other classes that are out there.

  • @ViktorRadoslavov
    @ViktorRadoslavov 7 лет назад +1

    When you clicked run for the first time and an ACTUAL WINDOW popped up on your screen, you blew my mind.
    Fuckin' 'ogrammin' maaaaaaaan.

  • @TheEmgriffiths
    @TheEmgriffiths 8 лет назад

    Another great video - this series is really good. Thank you.

  • @henk5025
    @henk5025 6 лет назад

    I get a lesson about this in college, but I didn't understand it. This video is so clear, thanks ;)

  • @CodeMonkeyCharlie
    @CodeMonkeyCharlie  11 лет назад

    If that is what you want in your user interface, sure. If you're primarily working with text, it may be easier to work entirely within the console.
    Maybe something like this would get you started?
    Scanner scanner = new Scanner(System.in);
    showGameIntro();
    while(gameIsRunning) {
    String userCommand = scanner.next();
    processCommand(userCommand);
    }
    The idea being showGameIntro starts the game, then you keep looping and processing the user input according to your game logic.

  • @hakancavusoglu2264
    @hakancavusoglu2264 8 лет назад

    Great works bro thank you.Love from Turkey.

  • @PaulieRR
    @PaulieRR 12 лет назад

    Makes sense. Many thanks, Charlie.

  • @CodeMonkeyCharlie
    @CodeMonkeyCharlie  12 лет назад

    No, it isn't necessary. You can resize a window after it is visible. Doing so before it is made visible ensures that you won't notice any sudden jump in the window's size that could happen if all the initialization code doesn't execute in a single refresh cycle on your monitor.

  • @CodeMonkeyCharlie
    @CodeMonkeyCharlie  12 лет назад

    There are other components available that may be more appropriate in your case, such as JTextArea (Google for code samples), but you can also put HTML inside of JLabels and have some control over formatting. Here's an example: apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-JLabel.html (just pay attention to the labelText Strings)
    In short, you can use HTML paragraph tags to break up lines inside the label.

  • @Robert420L
    @Robert420L 10 лет назад

    u r the man...very clear and precise and informative and blah, blah, blah...:)

  • @CodeMonkeyCharlie
    @CodeMonkeyCharlie  13 лет назад

    @Joncjmc It's called Eclipse. It is a very popular IDE for development in a variety of languages. It's free, just Google it and get one of the Java ones.

  • @CodeMonkeyCharlie
    @CodeMonkeyCharlie  12 лет назад

    If you're certain the code is the same, the data type is correct, and the import is there, try cleaning/rebuilding the project or restarting Eclipse. If you're not having any luck with that, send me your code in a message and I'll take a look at it.

  • @mohaarulez
    @mohaarulez 11 лет назад

    This was verry helpful! thanks, keep up the good work!

  • @CodeMonkeyCharlie
    @CodeMonkeyCharlie  11 лет назад

    You could do the same sort of thing using a jTextArea, there would just be a little more boilerplate code, and you'd be using getText() and setText(...), etc.

  • @JossinJax
    @JossinJax 5 лет назад

    Great presentation. Extra points for smooooth voice :D

  • @nax6206
    @nax6206 6 лет назад

    thank u from sweden

  • @Skywardbound172
    @Skywardbound172 10 лет назад +1

    If you dont have JFrame shortcut,download / install current JDK (8u5 currently) R Click MyFirstProject folder in Package Explorer -> properties -> java build path -> libraries tab. remove all libraries then Add Library -> JRE System Library -> next -> select Workspace defult JRE (Java SE 8 [1.8_06]). Finish. OK. Try JF short cut...

  • @bj0629
    @bj0629 12 лет назад

    Hi, thank you for your teaching. I want to ask JAVA to make windows which can do that like VB by drawing windows components. Thank you again.

  • @CodeMonkeyCharlie
    @CodeMonkeyCharlie  12 лет назад

    I copy pasted this code and the label appears for me. I do not know why it is not working for you. One thing you could try is having the setVisible line be the very last statement.

  • @advsds
    @advsds 8 лет назад +1

    When ever I try to use ctrl+spacebar, on JF the only things in the suggestion box are JarFile and JulianFields, anyone know what's up?

  • @keithfjord
    @keithfjord 8 лет назад

    Helpful. Thanks.

  • @audreymciver4863
    @audreymciver4863 5 лет назад

    I would like to include intelligence analyzation on each and every app. The Experian Equifax and Transunion apps have too many permissions

  • @jordyleffers9244
    @jordyleffers9244 10 лет назад

    Thanks for the video, i have a question though:
    The string object your calling in the end of the video, to me, it looks just the same as a string variable. What's the difference?

  • @tommy.russoniello
    @tommy.russoniello 9 лет назад

    very helpful, thanks! :D

  • @odedovadia
    @odedovadia 12 лет назад

    Thank you very much.

  • @Sasori915
    @Sasori915 11 лет назад

    Could you maybe add an annotation reminding people to terminate the program? I remember the first time I went through this, Eclipse got really laggy because I didn't realize that closing the window didn't actually end the program so I had about five or possibly more iterations of Object running simultaneously all doing nothing. :/

  • @rananjayabandara7091
    @rananjayabandara7091 9 лет назад

    grate .thank you sir

  • @flamingoth
    @flamingoth 12 лет назад

    HEY! this si very useful! thnks ! can u tell me how to keep adding text to the window. I tried making my text longer and it reaches a point where it doesnt fit anymore, i tried to make the window bigger but still, it is a lot of text. i would like to put text in the whole window. can u help me PLEASEEE?!

  • @PaulieRR
    @PaulieRR 12 лет назад

    I'm curious: is it strictly necessary to define the window size and title *before* setting the window as visible? I ask because you seem to be saying it *is* necessary, but when I swap the code around in Eclipse, it doesn't seem to make much difference?

  • @tyru2
    @tyru2 8 лет назад

    THANK YOU SO MUCH

  • @KristapsKKK
    @KristapsKKK 12 лет назад

    cool stuff, thanks;

  • @shleebeez
    @shleebeez 9 лет назад +1

    At 1:33 what is the shortcut you use to import JFrame up at the top? It appears you don't actually manually type in anything.

  • @NanoValorant
    @NanoValorant 4 года назад

    How can I open the frame without opening the program first?

  • @pebble6248
    @pebble6248 6 лет назад

    its a really detailed and good video but it doesent work for me? I tried JFrame window new = JFrame (); window.setVisible(true); then ran it and i had like 2 errors so nothing happened

  • @austinanderson3647
    @austinanderson3647 9 лет назад

    Question, How do you Change the position of the text while it is in the window
    JFrame window = new JFrame();
    window.setTitle("Java App");
    window.setSize(800, 600);
    window.setVisible(true);
    JLabel label = new JLabel();
    label.setText("Java Applet");
    window.add(label);

    • @CodeMonkeyCharlie
      @CodeMonkeyCharlie  9 лет назад

      Frames can be configured with layouts that try to keep things organized nicely for you, but can be a little confusing to learn. See here: docs.oracle.com/javase/tutorial/uiswing/layout/using.html
      Alternatively, you can setLayout(null) and use absolute positioning, but that isn't without its downsides. More work, you have to deal with resizing, etc. Example here: docs.oracle.com/javase/tutorial/uiswing/layout/none.html

    • @austinanderson3647
      @austinanderson3647 9 лет назад

      Yeah, sorry I have no idea what they mean. It makes everything a billion times easier to learn code when your being taught step by step through a video.
      By the way, Thank you so much for making these videos, others who try to teach programming don't explain it very well, and you make it step by step, Making it so clear to understand.

    • @GiorgiSukhitashvili
      @GiorgiSukhitashvili 9 лет назад

      +CodeMonkeyCharlie
      These are best tutorials i've come accross. Could you please make more... plz

  • @kapilsoni3106
    @kapilsoni3106 10 лет назад +1

    on mac the label component is not adding to window with command window.add(label);

    • @youcantkillthemonkey
      @youcantkillthemonkey 9 лет назад +1

      Kapil Soni Through trial and error, I've found that calling the revalidate method on the JFrame object after adding the label will get it to show. in this case,
      window.add(label);
      window.revalidate();
      Hope it helps.

  • @MrOgnjenSrb
    @MrOgnjenSrb 9 лет назад

    Yes, i shall sub.

  • @flamingoth
    @flamingoth 12 лет назад

    :D thank you so much! i wish i was as smart and inteligent as you :$

  • @taufiqsun
    @taufiqsun 10 лет назад

    My JF shortcut doesn't appear.

  • @funnystuffers1
    @funnystuffers1 13 лет назад

    i love you!

  • @datnig7500
    @datnig7500 11 лет назад

    why is it when i run once it dosent let me run a seconed time

  • @Minecrafter-hu2uz
    @Minecrafter-hu2uz 9 лет назад

    It says invalid "Main". Please Help!

  • @minigoalwalla
    @minigoalwalla 13 лет назад

    the "window" does not store the object but POInts to the object!!!

  • @audreymciver4863
    @audreymciver4863 5 лет назад +1

    I do not agree to my privacy being violated it violates my civil rights and I have never agreed to this. I want it stopped.

  • @Vijster1
    @Vijster1 12 лет назад

    HOW TO USE DOCTOR JAVA

  • @Tulanir1
    @Tulanir1 12 лет назад

    01:34 OR you could just type JFrame which would be much faster.... ._.

  • @silentwalrus60
    @silentwalrus60 12 лет назад

    AP COMPUTER SCIENCE IS THE BEST!!!!!
    *assuming spelling errors*

  • @audreymciver4863
    @audreymciver4863 5 лет назад

    I would like to also know why I’m getting ads for taxes when I have not made any money from anything. I worked at McDonald’s and filled my taxes yesterday I do do what I am supposed to do

    • @eatyofacen00b
      @eatyofacen00b 5 лет назад

      what in the fuck are you on about?

  • @audreymciver4863
    @audreymciver4863 5 лет назад

    All apps need to be fixed to make the internet safer

  • @mohammadakramslimania8558
    @mohammadakramslimania8558 10 лет назад

    oh maaaaaaaan , THANKS A LOOOOOOOOOOT :'( :'( :'( :'(

  • @robyrandom1148
    @robyrandom1148 5 лет назад

    2019 anyone ??

  • @siAppDesign
    @siAppDesign 5 лет назад

    class ame objects.. noo.. are you serious.? good way to confused beginner

  • @youtubeaccount0x073
    @youtubeaccount0x073 5 лет назад

    YOU ARE NOT SHOWING HOW TO CREATE THESE METHODS OMG PLEASE

  • @killthewall101
    @killthewall101 12 лет назад

    At the "label.setText()" line I get an error saying "label cannot be resolved"
    why is that? The code is exactly the same as yours