Norm, yes, I'm curious about it, but I still have no idea, why it happened. :/
Type: Posts; User: fkmk
Norm, yes, I'm curious about it, but I still have no idea, why it happened. :/
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!...
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. :(
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...
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.
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:...
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...
Norm, ok, I printed a content with this code:
for(Point[] array: pointsList) {
System.out.println(array);
}
and in the console it printed:
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. :)
Norm, it is line 39:
g.drawLine(p1.x, p1.y, p2.x, p2.y);
Point p2 and Points[1] had a null value. :)
Norm, debugger said, that
Point p2 = Points[1];
g.drawLine(p1.x, p1.y, p2.x, p2.y);
there is null. :)
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...
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...
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) {
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...
Norm, thank you! :) But I just wonder if there is a way to connect these to classes (Drawing and Pencil). :)
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...
Norm, yes, Pencil does not have repaint() method, but I need Pencil have it, without extending it with JPanel. :)
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...
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 {
Norm, I have deleted it, because I solved the problem. :) Thank you so much for all your help! I owe you a lot! :)
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...
Norm, it stops before
g.drawLine(p1.x, p1.y, p2.x, p2.y);
I cant handle with it... what is the solution?
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.
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...