« first day (2 days earlier)      last day (24 days later) » 

1:39 AM
@MadProgrammer Can I ask you another qustion?
 
1:58 AM
Sure
 
 
1 hour later…
3:26 AM
@MadProgrammer I tried to draw couple of pics but just one appers
public class Pictures extends JPanel {

private String path;
private int x;
private int y;
private List<Image> list;

public Pictures(String path, int x, int y) {
this.path = path;
this.x = x;
this.y = y;
list = new ArrayList<>();
}

@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
Image img;
try {

img = createImageWithText();

for (Image i : list) {
g.drawImage(i.getScaledInstance(100, 200, Image.SCALE_FAST), x, y, this);
}
} catch (IOException ex) {
@MadProgrammer can you tell me plz where I did wrong?
 
3:44 AM
1- You're drawing the miages at the same location
2- You're not adding anything to your list
If you want to use a single panel for drawing the images, I'd create a wrapper class which provided the x/y positions of the image and a reference to the actual image (not the path as images can come from lots of different locations)
 
i did add
but I changed x and y
 
Okay, the only image you added was the createImageWithText...what about the others? Why have a list? You're just going to have grow each time the paintComponent method is called?
 
I just followed same approche that you applied for the draw triangle
 
Also, you're frame is using a BorderLayout, so only the second panel will be shown, change the layout to a GridLayout instead
You don't need a List to draw a single image ;)
 
no what you saw is commented
does not count
no I use the list to draw pervious pictures
public class Pictures extends JPanel {

private String path;
private int x;
private int y;
private List<Image> list;

public Pictures(String path, int x, int y) {
this.path = path;
this.x = x;
this.y = y;
list = new ArrayList<>();
}

@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
Image img;
try {

img = createImageWithText();

for (Image i : list) {
g.drawImage(i.getScaledInstance(100, 200, Image.SCALE_FAST), x, y, this);
}
} catch (IOException ex) {
 
3:54 AM
But I still don't see why, you're adding the same image to the list, each time paintComponent is called, growing the list painting the images in the same place...
 
creatImageWithText return different image Am I right?
 
It's a new reference of the image you loaded last time...
 
so my thought is wrong
 
I don't know, what are you trying to do?
 
draw two pictures
from left to right
 
3:56 AM
Then yes, you process is wrong...
 
first I wanted to have 3 panles and draw each pic in each panel
but you said i must come up with a generic method and use it over and over again
How can I fix it plz?
as you see I change x and y coordinate
 
Give me a sec
 
plz take your time
I do not wanna the answer just hint so I can work on
 
Change the constructor to take a variable argument list of Image
Pictures(Image... images)
Add these to your list...
 
what is gonna happen to other arguments?
 
4:04 AM
list = new ArrayList<>(Arrays.asList(images));
You're going to let the Pictures panel deal with it...
 
add the list to my constructor?
 
Scale the images to fit within a pre-defined space (say 200x200)
Yes, the list is still within the constructur...
 
haha I changed my mind gimme a sample hah
 
who I am thinking to think that I am as same as you?
:D
 
4:06 AM
Always aim high ;)
 
no need to say I think about it everyday ;)
I never saw such thing
ist = new ArrayList<>(Arrays.asList(images));
Why arrays.aslist(images) there?
 
Neat trick, do it all the time ;)
 
and explantion?
is?
 
ArrayList can take a Collection as an argument it one it's constructors, adding each element to itself. Arrays.asList creates a non-mutable List out of the supplied array, just feeding the array (or the variable arguments) to a ArrayList ;)
 
oh i got it thank you
so what can I do to slove this plz?
 
4:34 AM
Well, that had me running around in circles for no reason :P
	import java.awt.Color;
	import java.awt.Container;
	import java.awt.Dimension;
	import java.awt.EventQueue;
	import java.awt.Graphics;
	import java.awt.Graphics2D;
	import java.awt.Image;
	import java.awt.Rectangle;
	import java.io.File;
	import java.io.FileFilter;
	import java.io.IOException;
	import java.util.ArrayList;
	import java.util.Arrays;
	import java.util.List;
	import javax.imageio.ImageIO;
	import javax.swing.JFrame;
	import javax.swing.JPanel;
	import javax.swing.JScrollPane;
	import javax.swing.JViewport;
Okay, basically, this is an image browser, point the File[] files = new File("/some/folder/full/of/images").listFiles(new FileFilter() { statement to a directory of images and it will attempt to load them, scale to fit within a 200x200 box and display them, four columns wide by how many ever rows it needs...
Now, the layout code basically assumes a 200x200 box, you might need to use the images actual width and height, but play around with it see what mess it can get you into...
 
5:04 AM
thank you so much
but this is crazy beyound my knowledge I have to study that and get back to you with the result
thank you os much for being nice and supportive to me
wowwwwwwwwww you are a god
m(--)m
 
Master of procrastination...
 
whome me?
lol
 
5:16 AM
No me ;)
I should be debugging ;)
 
5:39 AM
so the code that you gave me just draw picture as much as I want from left to right
?
 

« first day (2 days earlier)      last day (24 days later) »