Java 2D graphics 🖍️

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 ต.ค. 2024
  • Java 2d graphics GUI swing tutorial for beginners
    #Java #2D #graphics #tutorial #beginners #shapes #paint()
    // ---------------------------------------------
    public class Main{
    public static void main(String[] args) {
    new MyFrame();
    }
    }
    // ----------------------------------------------
    import javax.swing.*;
    public class MyFrame extends JFrame{
    MyPanel panel;
    MyFrame(){
    panel = new MyPanel();
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.add(panel);
    this.pack();
    this.setLocationRelativeTo(null);
    this.setVisible(true);
    }
    }
    // ----------------------------------------------
    import java.awt.*;
    import javax.swing.*;
    public class MyPanel extends JPanel{
    //Image image;
    MyPanel(){
    //image = new ImageIcon("sky.png").getImage();
    this.setPreferredSize(new Dimension(500,500));
    }
    public void paint(Graphics g) {
    Graphics2D g2D = (Graphics2D) g;
    //g2D.drawImage(image, 0, 0, null);
    g2D.setPaint(Color.blue);
    g2D.setStroke(new BasicStroke(5));
    g2D.drawLine(0, 0, 500, 500);
    //g2D.setPaint(Color.pink);
    //g2D.drawRect(0, 0, 100, 200);
    //g2D.fillRect(0, 0, 100, 200);
    //g2D.setPaint(Color.orange);
    //g2D.drawOval(0, 0, 100, 100);
    //g2D.fillOval(0, 0, 100, 100);
    //g2D.setPaint(Color.red);
    //g2D.drawArc(0, 0, 100, 100, 0, 180);
    //g2D.fillArc(0, 0, 100, 100, 0, 180);
    //g2D.setPaint(Color.white);
    //g2D.fillArc(0, 0, 100, 100, 180, 180);
    //int[] xPoints = {150,250,350};
    //int[] yPoints = {300,150,300};
    //g2D.setPaint(Color.yellow);
    //g2D.drawPolygon(xPoints, yPoints, 3);
    //g2D.fillPolygon(xPoints, yPoints, 3);
    //g2D.setPaint(Color.magenta);
    //g2D.setFont(new Font("Ink Free",Font.BOLD,50));
    //g2D.drawString("U R A WINNER! :D", 50, 50);
    }
    }

ความคิดเห็น • 126

  • @BroCodez
    @BroCodez  4 ปีที่แล้ว +71

    // ---------------------------------------------
    public class Main{
    public static void main(String[] args) {

    new MyFrame();

    }
    }
    // ----------------------------------------------
    import javax.swing.*;
    public class MyFrame extends JFrame{

    MyPanel panel;

    MyFrame(){

    panel = new MyPanel();

    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    this.add(panel);
    this.pack();
    this.setLocationRelativeTo(null);
    this.setVisible(true);
    }
    }
    // ----------------------------------------------
    import java.awt.*;
    import javax.swing.*;
    public class MyPanel extends JPanel{
    //Image image;

    MyPanel(){

    //image = new ImageIcon("sky.png").getImage();
    this.setPreferredSize(new Dimension(500,500));
    }

    public void paint(Graphics g) {

    Graphics2D g2D = (Graphics2D) g;

    //g2D.drawImage(image, 0, 0, null);

    g2D.setPaint(Color.blue);
    g2D.setStroke(new BasicStroke(5));
    g2D.drawLine(0, 0, 500, 500);

    //g2D.setPaint(Color.pink);
    //g2D.drawRect(0, 0, 100, 200);
    //g2D.fillRect(0, 0, 100, 200);

    //g2D.setPaint(Color.orange);
    //g2D.drawOval(0, 0, 100, 100);
    //g2D.fillOval(0, 0, 100, 100);

    //g2D.setPaint(Color.red);
    //g2D.drawArc(0, 0, 100, 100, 0, 180);
    //g2D.fillArc(0, 0, 100, 100, 0, 180);
    //g2D.setPaint(Color.white);
    //g2D.fillArc(0, 0, 100, 100, 180, 180);

    //int[] xPoints = {150,250,350};
    //int[] yPoints = {300,150,300};
    //g2D.setPaint(Color.yellow);
    //g2D.drawPolygon(xPoints, yPoints, 3);
    //g2D.fillPolygon(xPoints, yPoints, 3);

    //g2D.setPaint(Color.magenta);
    //g2D.setFont(new Font("Ink Free",Font.BOLD,50));
    //g2D.drawString("U R A WINNER! :D", 50, 50);
    }
    }

    • @rolpon2871
      @rolpon2871 2 ปีที่แล้ว +3

      hi

    • @zakeerhussain4112
      @zakeerhussain4112 ปีที่แล้ว +1

      Code for Pokemon
      g2d.setColor(Color.red);
      g2d.fillArc(0, 0, 200, 200, 0, 180);
      g2d.setColor(Color.white);
      g2d.fillArc(0, 0, 200, 200, 180, 180);
      g2d.setColor(Color.black);
      g2d.fillOval(80, 80, 50, 50);
      g2d.setFont(new Font("MV Boli",Font.BOLD,20));
      g2d.drawString("POKEMON", 50, 70);

    • @joyceasante8292
      @joyceasante8292 ปีที่แล้ว

      Practicing...
      public class Main{
      public static void main(String[]args){
      new MyFrame();
      }
      **************************
      import javax.swing.*;
      public class MyFrame extends JFrame{
      MyPanel panel;
      MyFrame(){
      panel = new MyPanel();
      this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      this.add(panel);
      this.pack();
      this.setLocationRelativeTo(null);
      this.setVisible(true);
      }
      }
      *****************
      import java.awt.*;
      import javax.swing.*;
      public class MyPanel extends JPanel{
      Image image;
      MyPanel(){
      image = new ImageIcon("landscape.png").getImage();
      this.setPreferredSize(new Dimension(100,100));
      }
      public void paint(Graphics g){
      Graphics2D g2D = (Graphics2D) g;
      g2D.setPaint(Color.green);
      //g2D.setStroke(new BasicStroke(5));
      //g2D.drawLine(0,0,250, 250);
      //g2D.setPaint(Color.yellow);
      //g2D.drawRect(0,0,100,200);
      //g2D.fillRect(0,0,100,200);
      //g2D.setPaint(Color.orange);
      //g2D.drawOval(0,0,100,100);
      //g2D.fillOval(0,0,100,100);
      g2D.setPaint(Color.red);
      //g2D.drawArc(0,0,100,100,0,100);
      //g2D.fillArc(0,0,100,100,0,100);
      //g2D.setPaint(Color.white);
      //g2D.fillArc(0,0,100,100,100,100);
      //int[]xPoints = {125,225,325};
      //int[]yPoints = {250,300,250};
      //g2D.setPaint(Color.green);
      //g2D.drawPolygon(xPoints,yPoints,3);
      //g2D.fillPolygon(xPoints,yPoints,3);
      //g2D.setPaint(Color.gray);
      //g2D.setFont(new Font("Times New Roman", Font.PLAIN,18));
      //g2D.drawString("GLAMOROUS CODER",100,100);
      g2D.drawImage(image,0,0,null);
      }
      }

  • @jhanzaibhumayun5782
    @jhanzaibhumayun5782 3 ปีที่แล้ว +20

    Thank you for these tutorials! I have completed a basic java course but it didn't include panels, frames or graphics. Your tutorials are very helpful.

  • @programer6664
    @programer6664 2 ปีที่แล้ว +13

    After I saw the red background that I set I got very happy, at least I saw that something is working maybe now I can focus on programming and quit gaming because the past semester I am just copying my classmates work and not attending classes but when I see and try this tutorial then it worked, It got me very excited and motivated to continue, thank you very much brother keep up....
    -to someone who can relate in this comment like it I'm just curious if someone experienced it beside me.

  • @DiamantOpp
    @DiamantOpp 7 หลายเดือนก่อน

    Out of all coding related channels on youtube, this is BY FAR the best one.

  • @BroCodez
    @BroCodez  4 ปีที่แล้ว +8

    Here's the code for the picture in the thumbnail. I didn't have time to code this with you guys since I'm trying to cut down on the length of my videos:
    // Landscape Image
    //---------------------------------------------------------
    public class Main{
    public static void main(String[] args) {

    new MyFrame();

    }
    }
    //---------------------------------------------------------
    import java.awt.*;
    import javax.swing.*;
    public class MyFrame extends JFrame{

    MyPanel panel;

    MyFrame(){

    panel = new MyPanel();

    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.add(panel);
    this.pack();
    this.setLocationRelativeTo(null);
    this.setVisible(true);
    }
    }
    //---------------------------------------------------------
    import java.awt.*;
    import javax.swing.*;
    public class MyPanel extends JPanel{
    Image image;

    MyPanel(){

    image = new ImageIcon("sky.png").getImage();
    this.setPreferredSize(new Dimension(500,500));

    }
    public void paint(Graphics g){

    Graphics2D g2D = (Graphics2D) g;

    g2D.drawImage(image, 0, 0, null);

    g2D.setPaint(Color.green);
    g2D.fillRect(0, 300, 500, 500);

    g2D.setPaint(Color.gray);
    g2D.fillRect(225, 325, 50, 100);
    g2D.fillRect(325, 350, 50, 100);
    g2D.fillRect(125, 350, 50, 100);

    g2D.setStroke(new BasicStroke(1));
    g2D.setPaint(Color.orange);
    g2D.fillArc(150, 200, 200, 200, 0, 180);
    int[] xPoints = {0,100,200};
    int[] yPoints = {300,150,300};

    g2D.setPaint(new Color(0x694d00));
    g2D.drawPolygon(xPoints, yPoints, xPoints.length);
    g2D.fillPolygon(xPoints, yPoints, xPoints.length);

    int[] xPoints2 = {300,400,500};
    int[] yPoints2 = {300,150,300};

    g2D.setPaint(new Color(0x694d00));
    g2D.drawPolygon(xPoints2, yPoints2, xPoints.length);
    g2D.fillPolygon(xPoints2, yPoints2, xPoints.length);

    g2D.setPaint(Color.green);
    g2D.setStroke(new BasicStroke(10));
    g2D.drawLine(0, 300, 500, 300);

    g2D.setPaint(Color.YELLOW);
    g2D.setFont(new Font("Ink Free",Font.BOLD,50));
    g2D.drawString("Welcome to my city", 25, 75);

    }
    }
    //---------------------------------------------------------

  • @bluesillybeard
    @bluesillybeard 3 ปีที่แล้ว +13

    This is a brilliant tutorial! straight to the point (well, ignoring the like & subscribe stuff), very straightforward and easy to understand!

  • @theuser810
    @theuser810 2 ปีที่แล้ว +3

    Sometimes if you run the code, it might maintain the previous state of the canvas. What you need to do is run each file individually, before running the main file. It might not apply to everyone, but it did for me (I am on Sublime Text 3).

  • @ElectroGehirn
    @ElectroGehirn 8 หลายเดือนก่อน

    Hi
    First, thank you so much, your tutorials help me sooo much to learn about this stuff as someone that randomly jumped in!
    and i have a question, could you go more into strokes, because there is more about them as shown in your video, maybe you could mix this into a next tutorial for graphics2d or something else but the potential for strokes is a bit lost there, but its also not that big but its something that would have also fit in pretty good

  • @radupurecel3330
    @radupurecel3330 4 ปีที่แล้ว +4

    I'm glad I find your channel! I've learned and still learning so much things in a short time! ^^

  • @pavelkvasnicka6856
    @pavelkvasnicka6856 ปีที่แล้ว

    This is the best Java tutorial for beginners, so you can learn Java and English in one hit. Please keep going! I vote for Java advance tutorial. Thanks a lot Bro

  • @ozz961
    @ozz961 3 ปีที่แล้ว +4

    draw rect like get rekt , perfectly explained 🙌 👌

  • @streelet8647
    @streelet8647 ปีที่แล้ว +1

    Thanks for the useful content

  • @ADAhd66
    @ADAhd66 2 ปีที่แล้ว

    Want to create moving object from one point to other,and thank you for your teaching in a simple and detailed way of explanation

  • @mikloscsuvar6097
    @mikloscsuvar6097 ปีที่แล้ว

    This was a good summary on 2D graphics basics. I got this link as a course material.

  • @YTSHANKY
    @YTSHANKY 4 ปีที่แล้ว +23

    TH-cam never recommend your videos.. I watch a lot of videos related to programming.. i randomly searched bro code.. and found your channel

  • @amira66996
    @amira66996 5 หลายเดือนก่อน

    Hey , just want to say that your videos are awesome
    and this video really helped me , thank you

  • @edsiegel5357
    @edsiegel5357 3 ปีที่แล้ว +1

    That was great. the first clear description of how to use 2D graphics i've seen.

  • @Ahmed-iam
    @Ahmed-iam 2 ปีที่แล้ว

    Super helpful

  • @balaeinstein8710
    @balaeinstein8710 4 ปีที่แล้ว +2

    i think this is the best playlist available for learning java graphics . Thanks a lot bro. playlist is not updated?

  • @animeshbiswas2754
    @animeshbiswas2754 2 ปีที่แล้ว

    You're awesome. I am learning so much from you. Please keep it up.

  • @AkramAtti-jj6yc
    @AkramAtti-jj6yc 4 หลายเดือนก่อน

    Nice video !!!!!

  • @cinderacedr
    @cinderacedr ปีที่แล้ว

    Gave it a like! Thanks man and great video!

  • @MittenyLewis
    @MittenyLewis 2 ปีที่แล้ว

    cool video bro.

  • @zed9zed
    @zed9zed 2 ปีที่แล้ว +2

    Great and simple, with no fluff! Thanks much.

  • @turhantemizel2682
    @turhantemizel2682 7 หลายเดือนก่อน

    Your explanation is brilliant!

  • @jfruit6310
    @jfruit6310 4 ปีที่แล้ว +1

    previously i watch your pong project and i don't understand method paint is work with out call so i back to your this new video and i found your description thank for your hard work.

    • @BroCodez
      @BroCodez  4 ปีที่แล้ว +3

      thanks for watching! That's one of the reasons I went back to update some of these GUI videos. I feel like I could have explained a few things better

  • @kenkinyua7036
    @kenkinyua7036 2 ปีที่แล้ว

    thanks you make learning fun and productive😄

  • @pavan_goat
    @pavan_goat ปีที่แล้ว

    Great thanks

  • @neenaelsa9924
    @neenaelsa9924 ปีที่แล้ว

    Thank you so much for the video. Very helpful for a beginner.

  • @YTSHANKY
    @YTSHANKY 4 ปีที่แล้ว +1

    As always .. bery good content

  • @eugenezuev7349
    @eugenezuev7349 4 หลายเดือนก่อน

    Bro is a Java king

  • @tuoivan4374
    @tuoivan4374 ปีที่แล้ว

    Thank you for these tutorials!

  • @chrismunsonmusic3432
    @chrismunsonmusic3432 2 ปีที่แล้ว

    Awesome content

  • @redphantom451
    @redphantom451 14 วันที่ผ่านมา

    Thanks dude, might create a personal video to help me re-learn this

  • @tecso2027
    @tecso2027 3 ปีที่แล้ว +2

    Great video, easy to follow and understand. Thanks for uploading!

  • @nawfalnjm5699
    @nawfalnjm5699 3 ปีที่แล้ว

    thank you for this video . helped me so much to understand GUI

  • @virachi275
    @virachi275 ปีที่แล้ว

    I love at the begin of this vid that show an image from the game Dragon's Lair

  • @kemann3815
    @kemann3815 2 ปีที่แล้ว

    Another great one

  • @zlotyyy7991
    @zlotyyy7991 8 หลายเดือนก่อน

    thanks bro

  • @ItsIcedDonut
    @ItsIcedDonut 5 หลายเดือนก่อน +1

    For some reason when I try to draw the image it doesn't work, I have tried multiple images and even copying the exact code from the description but nothing seems to work.

  • @carriejiang1570
    @carriejiang1570 2 ปีที่แล้ว

    Very nice video ! 😀😀

  • @karlpillay8360
    @karlpillay8360 10 หลายเดือนก่อน

    Ehhhh so I did this and the ImageIcon doesn't seem to be able to import my images. However, there is another way I learned using the BufferedImage thingy and then surrounding it with try and catch in the constructor. The image works fine with that method but not for the imageicon method like you use, am I missing something?
    Thank you for all your teachings by the way :'>

  • @zer0k1line68
    @zer0k1line68 2 ปีที่แล้ว +1

    I made two triangles with 5 points :)
    int[] triangleXPoints = new int[] {
    0, 200, 400, 600, 800
    };
    int[] triangleYPoints = new int[] {
    300, 80, 300, 80, 300
    };
    g2D.setPaint(Color.yellow);
    g2D.fillPolygon(triangleXPoints, triangleYPoints, 5);

  • @stephanososten2580
    @stephanososten2580 2 ปีที่แล้ว

    Thanks so much for helping me cause I didn't have any knowledge about how to set up an image background.

  • @thatnelfy
    @thatnelfy 2 ปีที่แล้ว

    u a best. ty!

  • @ratibor_shevchenko
    @ratibor_shevchenko 4 ปีที่แล้ว +3

    Hi! I have a problem:
    My code is the same but I can't see the line (like at 4:00). The line became visible only if I call the repaint() method in the paint() method after the drawLine() call. Can you explain this problem, please?
    ***
    EDIT: I see that the issue could be fixed by calling the super.paint(g) method at the beginnin of our overriding method.
    ***
    After that, I would be grateful if you did a video to explain something about BufferedImage, BufferStrategy, VolatileImage end/or similar. And it would be very interesting and useful if sometimes you explained some efficiency information just to understand which class is more suitable for our use.
    Thank you!

  • @nages1171
    @nages1171 3 ปีที่แล้ว +1

    I love your videos but i have a question is there a way to draw on a panel without creating a new class and extending it to JPanel if there is a way help pls

  • @JehanSaren
    @JehanSaren ปีที่แล้ว

    sir, next please🙏 cloth simulation

  • @anonimanonim1223
    @anonimanonim1223 2 ปีที่แล้ว

    Like it!

  • @belalehner3937
    @belalehner3937 ปีที่แล้ว

    Thank You for this video! You have just shown me a bit from the fun side of Java. And by the way, it can be useful while making business charts for the accounting for example.

  • @MrLoser-ks2xn
    @MrLoser-ks2xn 2 ปีที่แล้ว

    Thanks

  • @shpatspahiu2929
    @shpatspahiu2929 2 ปีที่แล้ว

    Helpful

  • @andrewchen861
    @andrewchen861 2 ปีที่แล้ว

    Thanks for the video!

  • @dougrattmann5791
    @dougrattmann5791 2 ปีที่แล้ว

    Great explained!

  • @AsfawYemaneBerhe
    @AsfawYemaneBerhe ปีที่แล้ว

    Thank you,Bro

  • @marekmacku3526
    @marekmacku3526 2 ปีที่แล้ว

    Great video! Thanks alot

  • @akeimstbernard4603
    @akeimstbernard4603 2 ปีที่แล้ว

    Thank you for this understandable tutorial, you're amazing.

  • @mahmoudgaber7739
    @mahmoudgaber7739 2 ปีที่แล้ว

    thank u

  • @yoursubscriber6909
    @yoursubscriber6909 4 ปีที่แล้ว

    Really Cool

  • @GuillinCorp
    @GuillinCorp 2 ปีที่แล้ว +2

    Hello. How can I get a reference to the panel to call the paint function from main? I need to pass through a graphics object but I can't

    • @GuillinCorp
      @GuillinCorp 2 ปีที่แล้ว

      This is how I fixed it, created a method to return the instance of panel in the MyFrame class:
      MyPanel getpanel(){
      return panel;
      }
      On the MyPanel class, I created a new method to pass into the data I want to use to draw onto my panel:
      protected void drawelevators(myarray[] _myarray) {
      myarray= _myarray;
      repaint();
      }
      By calling the repaint function, this function is called for painting on the panel:
      protected void paintComponent(Graphics g) {}
      on the main thread, I created instances to the the panel object like this:
      MyFrame frame = new MyFrame();
      MyPanel panel = frame.getpanel();
      Then I called the function I talked about above:
      panel.drawelevators(myarray);

  • @acminostgien3038
    @acminostgien3038 7 หลายเดือนก่อน

    is it posible to draw tilesets, like only a portion of an image to be displayed?

  • @mauriciomachado8855
    @mauriciomachado8855 3 ปีที่แล้ว +2

    Muito bom. Obrigado.

  • @siddheshss12345
    @siddheshss12345 4 ปีที่แล้ว +3

    How is the paint function invoked without calling it? is it because of the new java functionality?

    • @BroCodez
      @BroCodez  4 ปีที่แล้ว +2

      It's called automatically in the background when you create a component

  • @MrLoser-ks2xn
    @MrLoser-ks2xn ปีที่แล้ว

  • @gamehacker5692
    @gamehacker5692 6 หลายเดือนก่อน

    Does this support multithreading, python didn’t so that’s why I’m asking before I start my project lol otherwise I’ll have to scrap the graphics which would really suck

  • @motototoralabastru2741
    @motototoralabastru2741 2 ปีที่แล้ว

    thank you for this video, it was very helpful :)

  • @omardumet120
    @omardumet120 3 ปีที่แล้ว

    amazing

  • @GodmyX
    @GodmyX ปีที่แล้ว

    Thank you!

  • @bubblejuiceTV
    @bubblejuiceTV 3 ปีที่แล้ว +2

    Hi Bro,
    Loving these vids. I have a quick question..
    How do I set up eclipse to show the arguments like yours.
    yours: g2d.drawArc(x, y, width, height, startAngle, arcAngle);
    mine: g2d.drawArc(arg0, arg1, arg2, arg3, arg4, arg5);
    If anyone knows what setting I need to enable so the argument tips look like this.
    Thanks in advance :)

    • @asher05
      @asher05 2 ปีที่แล้ว

      Try IntelliJ IDE ;D

  • @gooseguy1641
    @gooseguy1641 ปีที่แล้ว

    I have essentially the same code as in the video for printing an image onto a window, but when I print a 320x240 image onto a 320x240 panel, it lowers the resolution of the image significantly. I can't figure out why it's lowering the quality of the image so much. Is there some in between step that the printing takes that does this, and if so can I avoid it?

  • @moka8267
    @moka8267 2 ปีที่แล้ว

    Thanks, I think this will be more useful for my puzzle game than using all that code from other game development videos :)

  • @honoredegg
    @honoredegg 2 ปีที่แล้ว

    72th. Thank you, ma Bro Sensei

  • @davidorevic6651
    @davidorevic6651 ปีที่แล้ว

    Why do we need an array of Integers when drawing the triangle?

  • @chzzh6634
    @chzzh6634 3 ปีที่แล้ว

    cool

  • @oussamaelhousni5665
    @oussamaelhousni5665 3 ปีที่แล้ว

    Thnk u Bro

  • @lequangnghi194
    @lequangnghi194 2 ปีที่แล้ว

    Here's my Pokeball 😂:
    g2D.setPaint(Color.red);
    g2D.drawArc(200, 0, 100, 100, 0, 180); //draw a half circle
    g2D.fillArc(200, 0, 100, 100, 0, 180);
    g2D.setPaint(Color.white);
    g2D.drawArc(200, 0, 100, 100, 180, 180); //draw a half circle
    g2D.fillArc(200, 0, 100, 100, 180, 180);
    g2D.fillOval(230, 30, 40, 40); //fill a small circle inside the big circle
    g2D.setPaint(Color.black);
    g2D.drawOval(200, 0, 100, 100); //draw an outline: outside circle
    g2D.drawOval(230, 30, 40, 40); //draw an outline: middle circle
    g2D.drawOval(240, 40, 20, 20); //draw an outline: inside circle
    g2D.drawLine(200, 50, 230, 50); //draw a line inside the ball
    g2D.drawLine(270, 50, 300, 50); //draw a line inside the ball

  • @BRED40k
    @BRED40k 2 ปีที่แล้ว

    how do u create the new class MyFrames?

  • @joelrooldemelojunior9612
    @joelrooldemelojunior9612 3 ปีที่แล้ว

    hi, could you talk about the *intersects* function.
    thanks

  • @mediadimah22
    @mediadimah22 3 ปีที่แล้ว

    System. Out.print('' U R GREAT MAN! '') ;

  • @yoursubscriber6909
    @yoursubscriber6909 4 ปีที่แล้ว +1

    I'm first to comment after you 👑

    • @BroCodez
      @BroCodez  4 ปีที่แล้ว +2

      Here you go:
      🥇

  • @gdbot1
    @gdbot1 ปีที่แล้ว

    I have question, how to update this method, or delete this is graphic object?

  • @chingoputoh7969
    @chingoputoh7969 2 ปีที่แล้ว

    Hi to all. I'm having a problem launching this. I copied it almost exactly as coded, with different class names and different shapes. I keep running the package all three files are in as a Java application and it's not showing a window. No errors but that's about it.
    EDIT: Never mind, I fixed it. My version of Main was opening panels rather than the frames. Thanks for the video, you're really saving my bacon on my undergrad thesis.

  • @mrbadmadable
    @mrbadmadable 3 ปีที่แล้ว +1

    Hello guys, can someone explain to me, why i don't get the proposals shown at 3:18 ? I only get proposals like equals(), getClass(), hashCode(), wait(), etc. but nothing like drawLine, setPaint, etc. :(

  • @kshau_
    @kshau_ 3 ปีที่แล้ว

    15:00 Reminds me of Bill Cipher

  • @zillionere
    @zillionere 3 ปีที่แล้ว

    Good

  • @falyarivelo7068
    @falyarivelo7068 2 ปีที่แล้ว

    thanks a lot bro!

  • @neurotoxin6802
    @neurotoxin6802 3 ปีที่แล้ว

    Its too late, but can I change a background color of my window?

  • @ArrowCraft-k2j
    @ArrowCraft-k2j ปีที่แล้ว

    Algorithm

  • @Verzach3
    @Verzach3 3 ปีที่แล้ว +1

    Any way to add a event listener to this?

  • @dausel6276
    @dausel6276 8 หลายเดือนก่อน

    I was trying to copy the "paint" method but somehow it gives me the error: empty parameter field (I guess because of "g" ). What have I done wrong?

  • @PhieFty
    @PhieFty 3 ปีที่แล้ว

    Why my eclipse content assist didn't tell any of drawing method when i type g2d. ?

  • @draft_fusion
    @draft_fusion 2 ปีที่แล้ว

    How come you do not need to call paint(); ?

  • @przemysawmazurek6028
    @przemysawmazurek6028 3 ปีที่แล้ว

    Can someone explain me why we don;t invoke method paint but it works?

  • @thephoenixsystem6765
    @thephoenixsystem6765 2 ปีที่แล้ว

    Who else heard "Let's draw a pokeball" and went and drew a detailed pokeball? xD

  • @iamfunnyguy8468
    @iamfunnyguy8468 2 ปีที่แล้ว

    hello can someone help me.
    when i run my program, my jframe displays plain black color . what is the problem?

  • @bijikuda3124
    @bijikuda3124 ปีที่แล้ว

    than how to draw more than 1 polygon in 1 applet coding?

  • @ziskador
    @ziskador 3 ปีที่แล้ว

    finally a non hindi tutorial

  • @utku1376
    @utku1376 3 ปีที่แล้ว

    why we cant use JPannel in MyFrame class rather than create a different class?

    • @ojaspednekar
      @ojaspednekar 3 ปีที่แล้ว

      for code readability. If you want to, there is no problem with that. Once you refer this after 5-10 years, it would be hard to read all of that code, or it could be difficult to read for a colleague.

  • @lequangnghi194
    @lequangnghi194 2 ปีที่แล้ว

    I have no idea why I cannot cast "Graphics g" as a Graphics2D. :(
    It says: "Graphics2D cannot be resolved to a type" and this Exception shows up when I run the program:
    Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problems:
    Graphics2D cannot be resolved to a type

    • @dusklycanrocvlogs
      @dusklycanrocvlogs 2 ปีที่แล้ว

      Did you import Graphics2D at the top of your main class's file? That'd be the import java.awt.Graphics2D line at the top of the java file shown in the video.
      Make sure your imports are correct and that you've imported both Graphics and Graphics2D and then cast Graphics g as Graphics2D in your program.

    • @lequangnghi194
      @lequangnghi194 2 ปีที่แล้ว

      @@dusklycanrocvlogs Wow, I actually forgot to import java.awt.Graphics2D
      Problems solved, crisis averted
      Thanks a lot! 🙏

  • @andreleao.prodemge
    @andreleao.prodemge 2 ปีที่แล้ว

    Olá, tudo bem? Alguém pode me ajudar em como faço pra usar o Graphics2D sem ser usando JFrame, JPanel ou Applets? Tipo, meu projeto é web, preciso que o desenho seja renderizado numa DIV. Alguém pode me ajudar? Já procurei em muitos sites e todos só falam de JFrame, JPanel, Applets...