Well, let's say I wanted to do a puzzle.
It's not exactly what I'm trying to do, but I think a puzzle is a good way of describing the problem at hand. I want to lay out one new piece every time I choose the "new piece" option from a menu. Obviously the pieces I've already laid down should not move or disappear(until I say so at least). So you might say I got this incremental thing going on, with new images continously being added to my JPanel. I've tried this, and
it did not turn out well:
So, everytime repaint() is called this happens:
public void paintComponent(Graphics g)
super.paintComponent(g);
index=1;//
u =0;//the matrix placeholder for the x-coordinate;
v =0 ;//the matrix placeholder for the y-coordinate;
//x and y are updated elsewhere, and put in their respective slots
if(img[index] = null)
Rectangle rec = this.getBounds();
g.fillRect(0,0,(int)rec.getWidth(),(int)rec.getHeight());
for(temp=0;temp<index;temp++)//draw all previous images along with this
u++;
v++;
g.drawImage(img[index],imgCoordinates[u][v],this);
index++;//the next time a image loads, it's in the next slot
temp = 0;//zero's out so it's prepared for next redraw
//}//end if
}//end paintComponent
I'm sure the solution is quite within reach, but I just dont know where to start. The most important question is probably: Do I need to redraw the entire screen everytime I add another picture, or is it possible to just
draw the new one, leaving the other parts of the screen alone? Must I get involved with threads?
What about seralization? Please expand my knowledge of such things.
Best regards from frosty norway.
Sorry bout the bad coding above. Absolutely terrible. Have not used array's
for a while see. Here's what I actually meant to write:)
//let's say I have 20 pieces
private Image[] img= new Image[20];
private int[] coor = new int[20];
int x,y //actual x,y screen coordinates
int u=0;//x coordinates will be stored at only even numbers;
int v=1; //y coordinates will be stored at only odd numbers;
public void mousePressed(MouseEvent e
index++;// p.s I have a default image in img[0]
u =u+2;//2,4,6...
v =v+2;//3,5,7...
img[index] = source.getImage();//get the image
coor[u] = x;//store x
coor[v] = y;//store y
}//end mousePressed
public void paintComponent(Graphics g)
super.paintComponent(g);
if(img[index] != null)
Rectangle rec = this.getBounds();
g.fillRect(0,0,(int)rec.getWidth(),(int)rec.getHeight());
for(int i=0;i<index;i++)
g.drawImage(img,coor[i],coor[i+1],this);
}//end for
}//end if
}//end paintComponent
So what's wrong with this picture? As you see, the pieces are Images so they count as objects all right, but they hardly count as components(Image is not a subclass of Component).
Maybe it's time I got involved with Graphics 2D? And I have been wondering about this validate method
also. What's that about?
And last but not least what's a null-layout panel?
Thanks for cooperating.
Tore.
Similar Messages
-
Do I need to export multiple sizes for all standard print sizes? i.e.Say I crop the image in LR to 6'5" x 9' to fit within an 11" x 14" (overall) mat of a framed print.. Now let's say I want to reprint that same image in a 12" x 16" size ... to fit within a mat of with overall size of 20" x 24"? Or will the 1st export be "locked" at 6.5" X 9" (proportionately)?
So, for the first one Export it cropped to 6.5 x 9 - and in the Export Dialog box there is a capability to rename the file for exported output - which would allow you to add something like the crop or intention to the base name of the file. e.g. for _IMG0846.nef - setup the output filename to _IMG0846-65x9 for 11x14.jpg and output it at, say 300 or 360 dpi. So, it has a unique name and purpose in your output folder.
For best results, now, re-crop the picture in LR - just open the crop [R] dialog again, reframe the image to the new ratio, 12x16 and Export again - with an adjustment to the filename. e.g. _IMG0846-12x16 for 20x24.jpg
So, now you have two clearly identified image files in your output area and you can provide those to whomever is printing for you, etc. Discard them when you're done since you always have the original to return to to re-frame again as necessary.
This way you get output sharpening and resolution (in pixels) optimized for your output print size. Maybe not super important for smallish prints-but more important for larger ones. Output at 100 quality. -
How do you change a device's name in the sound setting? For example, Let's say I want to change " logo headset" to "log microphone." I need to do this in order for Rosetta Stone to recognize my USB Logitech headset. I'm extremely confused. Please, just help.
It is very difficult to offer troubleshooting suggestions when the "os version" you are using is unknown as each os has their own troubleshooting solutions.
You can also post in your installed os section of the message board. -
You know how you download apps, well let's say you have two devices and get an app on one and it goes to the other, how do you remove it from doing that?
Click here and use the instructions to turn off the automatic downloads.
(120206) -
what formula in numbers can I use when I want to know how much 19 % is of the numbers from (let's say) e6 up to e27 ? thank you
thanks a lot jerry.
Can I ask you another question?
it works well but it gives me a number like 14,567
and I would like it if it will automatic round up an give me the number 15 in this case.
I do know the seperate folmula to round up numbers but can I combine the two formula's ?
thank you and bye bye -
In the previous version of Firefox, I used to be able to browse any number of pages - for example, let's say I went to google. I started a search and then went to one of the links, browsed around the site for a while (each page registering in the history) and then I wanted to go back to the original google search. In the OLD version of Firefox, all I had to do was go to the arrow at the end of the navigation window, and I'd see all the places I had been and I could select one to go back to it. Now, when i hit that down arrow, I see an list of pages I go to frequently, not the pages I've been to in backward order. I really miss that feature. I am using 4.0.1.
You can get the drop down list by either right-clicking on the back/forward buttons, or holding down the left button until the list appears.
If you want the drop-down arrow you can add it with the Back/forward dropmarker add-on - https://addons.mozilla.org/firefox/addon/backforward-dropmarker -
Let's say I have a document that is 5 pages long. Now I want to insert the page numbers, starting on page 3 with the number "3" and leaving out pages 1 and 2. How do I do that?
I just found the answer myself. I don't know how to delete my question, so I'll just write the reply to the answer - just in case somebody needs to know: Insert a section brake after the second page and then choose "Start on 3".
-
ok So my for months I have been trying to fix this. A few months ago my credit card got turned off. Ever since then my iphone wont let me say 'no credit card' and I can't download anything or update anything. I have tried making a new Apple ID. Nothing is working. can somelme please help me
Hello uriah12345,
Thanks for the question. Based on what you stated, it seems like you dont want to use a credit card with the Apple ID and it wont let you. I would recommend that you read this article, it may be able to help you isolate or resolve the issue.
Why can’t I select None when I edit my Apple ID payment information? - Apple Support
Thanks for using Apple Support Communities.
Cheers,
Mario -
i have an iphone 3 and im trying to download apps but it wont let me says i need 4.4 or later but my itunes is on 11
It's not referencing your iTunes version. It's referencing your device's iOS version. An iPhone 3G has a maximum iOS of 4.2.1. If an app requires an iOS higher than that, it will not work on your iPhone 3G.
-
I am trying to update some apps but my ipad wont let me because it wants me to enter the security code for my credit card and I dont want to do that how can i fix this?
Try temporarily disabling your firewall and antivirus.
-
when i try to set up facetime with my Apple ID it does not let me saying it cannot verify my account? if i change my ID on the ipad deos it change it on my computer aswel?
Hi
I would try this since Apple TV is built to allow multiple Apple Ids
On you Apple TV
General > Settings >Itunes Store > Add New Account (put yours in here)
Then Switch account to your Apple Id
Cheers -
hello..i use firefox 4 beta 05..my question is..why when i open let's say 6 tabs..my windows show that i have 6 instancies of firefox instead of one like it does with firefox 3.6? thanks
maybe i am saying it wrong..when i press alt+tab there is only one firefox open..but in windows 7 in the taskbar..every tab open..appears as another window openIf you are referring to taskbar previews, you can turn them off by modifying a hidden preference.
# Type '''about:config''' into the location bar and press enter
# Accept the warning message that appears, you will be taken to a list of preferences
# In the filter box type '''previews'''
# Double-click on the preference browser.taskbar.previews.enable to change its value to '''false''' -
Hello,
My old emails address which I have used as my apple id for 10 years is being made redundant. I have changed the email address to a new gmail one and this is my new apple id. But my iMac has not recognised this. It keeps saying it wants the password for my old email address. I have seen some advice on these forums which suggest signing out of iCloud and then back in again. But when I start doing this it asks me if i want all the photos deleted that have not been downloaded onto the mac.
I have had an iCloud account for quite sometime and I'm afraid of losing everything in my cloud if i sign out and sign in with a new id.
Is this fear realistic?
I know I can change back to my old email, sign out and then sign in wight he new one...
Please help!This did not work for me. My old email account for iCloud still pops up on my screen every time I open my macbook. I've deleted it, reset it, every thing I can think of and it still shows up. I think six months of this is more than enough time to wait.
RDG -
On Pages, let's say you have two similar documents. Two versions of the same document, but not merged in Cloud and saved as two separate files. B ut you need to compare the two to see the differences, some things on one, but not in the other. In Word, they would merge the two and differences would be highlighted in red. Is there a way to do something like that?
Not actually in Pages, but there is third party software that purports to do this, google around.
Peter -
I have downloaded e-books from Leserskring on my computer. I would like to download it to my Samsung Tablet as well. It says I cannot as it was already installed by another user. I contact Leserskring and they said I installed it on my computer without creating an Adobe ID and cannot change the "authorization information" on my Adobe Digital Editions. If I do it now on my computer, after installing my books, I will loose all my books. Is this true or how can I correct it.
I have downloaded e-books from Leserskring on my computer. I would like to download it to my Samsung Tablet as well. It says I cannot as it was already installed by another user. I contact Leserskring and they said I installed it on my computer without creating an Adobe ID and cannot change the "authorization information" on my Adobe Digital Editions. If I do it now on my computer, after installing my books, I will loose all my books. Is this true or how can I correct it.
Maybe you are looking for
-
How to recover lost folders and files - Pls help, help...
Some days ago I lost all of my 15 GB folders and files that stored in my Macbook Pro hard drive called DATA. I brought my Macbook pro to an experienced computer tecnicians who providing data recovery services. To his and my suprise, after checking,
-
How do I add a new device to my existing email?
How do I add a new device to my email account?
-
Why does the save page command create a new folder
I am new to CS5. When I "save" a file I've modified, or use "save as" - either one seems to save the page in a complete folder including all graphics, etc. Want to merely save the page with its corrections in the usual way. Is there a setting in CS5
-
USMT Copies Data but does not restore data.
Can someone help me to shed some lite on a problem we are having? I am running an OSD task in SCCM2012R2. The Task Has the USMT option selected and enabled. When I run the OSD task on workstation I can see it run, I can even go to the directory an
-
Though there are "tons" of posts about this, I cannot find one that speaks to my level; nor one that seems to really fix the web sharing "Forbidden: You don't have permission to access /~shortname/ on this server" conundrum. I'm brand new to OS 10.5.