Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: draw can't be resolved. Help!

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default draw can't be resolved. Help!

    Hey. I'm trying to use draw. I'll post the code

    import javax.swing.*;

    public class Main {
    public static void main(String[] cmdLn){
    JFrame f = new JFrame("Draw");
    f.setVisible(true);
    f.setSize(500,500);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    draw objekt = new draw();




    }
    }

    The error I'm getting is: draw can't be resolved.
    I'm copying this code from a youtube tutorial, so it's weird that it doesn't work.
    Is there something else I should import?

    Thanks in advance.


  2. #2
    Junior Member
    Join Date
    Apr 2013
    Posts
    25
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default Re: draw can't be resolved. Help!

    Hi

    what is the draw class here , the object for which is created... have you created one?

  3. #3
    Junior Member
    Join Date
    Apr 2013
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: draw can't be resolved. Help!

    main:
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import java.io.*;
    import java.net.*;
    import java.util.LinkedList;
    import java.util.TreeSet;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    public class Main {
    public static void main(String[] cmdLn){
    JFrame f = new JFrame("Draw");
    f.setVisible(true);
    f.setSize(500,500);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    draw object = new draw();
    f.add(object);
    object.drawing();






    }
    }
    Second class:
    import javax.swing.*;
    import java.awt.*;
    public class Drawing {

    public void drawing(){

    repaint();
    }
    public void paintComponent(Graphics g){
    super.paintComponent(g);
    g.setColor(Color.BLUE);
    g.fillRect(10,15,100,2);




    }
    }
    import javax.swing.*;
    import java.awt.*;
    public class Drawing {

    public void drawing(){

    repaint();
    }
    public void paintComponent(Graphics g){
    super.paintComponent(g);
    g.setColor(Color.BLUE);
    g.fillRect(10,15,100,2);




    }
    }

    draw doesnt work.
    nor repaint();
    and The method paintComponent(Graphics) is undefined for the type Object

    --- Update ---

    Anyone?

    --- Update ---

    Solved. Sorry for my lack of skills.

  4. #4
    Junior Member
    Join Date
    Apr 2013
    Posts
    25
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default Re: draw can't be resolved. Help!

    Hi

    I feel u need to create object of Drawing class instead of draw. Because there is no class as draw here.
    So instead of draw object = new draw(); use Drawing object = new Drawing();
    and then object.drawing();

  5. #5
    Junior Member
    Join Date
    Apr 2013
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: draw can't be resolved. Help!

    Thanks mate!

Similar Threads

  1. StdDraw Cannot be Resolved??
    By jbarcus81 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: June 28th, 2014, 05:47 PM
  2. A method not being resolved?
    By inflames098 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 24th, 2012, 02:30 AM
  3. mp3 file cant be resolved
    By aNGaJe in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 2nd, 2012, 06:20 AM
  4. Change the random draw line here for a mouseListener draw
    By Panda23 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 10th, 2011, 02:29 AM
  5. cannot be resolved to a type
    By Teraphim in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 16th, 2010, 09:42 AM