Search:

Type: Posts; User: fkmk

Page 1 of 2 1 2

Search: Search took 0.19 seconds.

  1. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Norm, yes, I'm curious about it, but I still have no idea, why it happened. :/
  2. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Norm, I added test, as you said and it works! Thank you again! Let God bless you! :) Thank you for all your help! If you will have any problems with everything, ask me, and I will help you also!...
  3. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Norm, yes, Points[1] is null... but I don't know why. My code looks ok and I don't see any mistakes in it. :(
  4. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Norm, sorry, I cut something.
    Here is the full code:


    [java.awt.Point[x=286,y=371], null]
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at...
  5. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Norm, oh, sorry for that... :)

    Here is what shows in console:


    [java.awt.Point[x=400,y=219], java.awt.Point[x=404,y=219]]


    Printing before accessing shows nothing, empty field.
  6. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Norm, here is the code that defines pointsList:


    private final ArrayList<Point[]> pointsList = new ArrayList<>();


    and the code with the print statement:


    for(Point[] array:...
  7. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Norm, it prints only one point


    [Ljava.awt.Point;@3ff8bf54

    It is what it prints after one drawing with mouse.

    I don't know, if I understand what you mean, but printing before accessing...
  8. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Norm, ok, I printed a content with this code:


    for(Point[] array: pointsList) {
    System.out.println(array);
    }


    and in the console it printed:
  9. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Norm, I don't know why Points[1] have a null value... :/ in my opinion it should iclude any value.
    pointsList is a list with all points which mouse intercepted. :)
  10. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Norm, it is line 39:


    g.drawLine(p1.x, p1.y, p2.x, p2.y);


    Point p2 and Points[1] had a null value. :)
  11. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Norm, debugger said, that

    Point p2 = Points[1];
    g.drawLine(p1.x, p1.y, p2.x, p2.y);
    there is null. :)
  12. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Norm, should I have to create ArrayList of ArrayList in Drawing class? I have no idea, how to "include" there Arrays from e.g Pencil class (which include drawn points).
    Thanks :)

    edit//
    I have a...
  13. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Look: I press the button e.g Pencil and I draw something on my JPanel. After that, I want to sketch in something on JPanel by brush, so I press the button, which calls Action of Paintbrush. I draw...
  14. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Norm Ok, sorry. :)

    I changed the code a bit:

    Here is a part code of calling specific tools in one class:


    static int warunek;

    if(action.getSource() == newDrawingArea) {
  15. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Norm thank you, I have solved it! :)
    But another problem has occured...

    The problem is, that after pressing buttons, there is no action in JPanel. Take a look at this:

    Here is my code for...
  16. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Norm, thank you! :) But I just wonder if there is a way to connect these to classes (Drawing and Pencil). :)
  17. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Norm, I have added @Override adnotation before each MouseListener, and MouseMotionListener method already, but it still does not work, same problem occures. repaint() is undefined for the type...
  18. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Norm, yes, Pencil does not have repaint() method, but I need Pencil have it, without extending it with JPanel. :)
  19. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    For above code compiler shows:



    Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem:
    The method repaint() is undefined for the type Pencil

    at...
  20. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Hi guys! I have another problem...

    I have two classes:


    import java.awt.Color;
    import javax.swing.JPanel;
    import Toolkit.Pencil;

    public class Drawing extends JPanel {
  21. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Norm, I have deleted it, because I solved the problem. :) Thank you so much for all your help! I owe you a lot! :)
  22. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Norm, I have changed the code, and now there are no errors, but it still connects last Point with another from new List, so while drawing after Mouse Release and again Mouse Click last Point connects...
  23. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Norm, it stops before
    g.drawLine(p1.x, p1.y, p2.x, p2.y);
    I cant handle with it... what is the solution?
  24. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Norm, I don't see it. :( Hmm, maybe when I add the first item to the list, then it can't "appeal" to him? I have no idea how to solve it.
  25. Replies
    74
    Views
    4,973

    Re: Canvas and MouseListener...

    Norm I did, what you said. I created ArrayList of ArrayLists (of Points).
    Here is my code:


    import java.awt.BasicStroke;
    import java.awt.Color;
    import java.awt.Graphics;
    import...
Results 1 to 25 of 49
Page 1 of 2 1 2