|
That is part of what I'm after. Thank you for that!
"The computer industry is the only industry that is more fashion-driven than women's fashion. Maybe I'm an idiot, but I have no idea what anyone is talking about. What is it? It's complete gibberish. It's insane. When is this idiocy going to stop?" -- Oracle CEO Larry Ellison
|
|
|
|
|
I need to include the web cam image in gui through applet.I finished capture the image in applet.It works perfectly.But when I include the applet into the gui,applet is crashed.
The crash report file is appeared.The error is java.lang.securityException.Please help me.
|
|
|
|
|
1. Go and look at Google for possible causes of SecurityException[^].
2. Look at your code and check what you are doing when the exception occurs.
3. If you are not catch ing the exception then do so.
The best things in life are not things.
|
|
|
|
|
public static void IzbrisZivali(ArrayList<Zivali>Seznam) throws ConcurrentModificationException
, IOException
{
BufferedReader vhod=new BufferedReader(new InputStreamReader(System.in)) ;
{
System.out.println("Vnesi točno ime živali, ki bi jo radi izbrisali: ");
String IzbrisZivali=vhod.readLine();
int v=0;
for(Zivali Element: Seznam)
if(IzbrisZivali.equals(Element.getIme()))
{
Seznam.remove(Element);
System.out.println("Žival " + IzbrisZivali + " je bila izbrisana");
v++;
}
if(v==0)
{
System.out.println();
System.out.println("Na seznamu ni živali z imenom " + IzbrisZivali);
System.out.println();
}
}
}
How can i fix that? What should be changed. Please solve me this problem as im sitting here and staring at my computer for 2 hours! Please!
The problem is ConcurrentModificationException
Regards,
Matjaž
|
|
|
|
|
You can't iterate this way over your list (Seznam) while removing elements at the same time. Instead you should you use an iterator and call remove on the iterator:
Iterator iter = Seznam.iterator();
while (Seznam.hasNext()) {
Zivali element = iter.next();
...
...
if (.....) {
iter.remove();
}
}
BTW: this is a forum not a chat, so you can't request "URGENT HELP!". Your question is not more urgent than other questions. If it is really urgent, then you should pay somebody to fix the problem for you. And please, use a better title next time you ask a question, everybody knows that if you ask a question, you want some help... Please, read the posting guidelines at the top of this message board.
|
|
|
|
|
This exception may be thrown by methods that have detected concurrent modification of an object when such modification is not permissible. For example, it is not generally permissible for one thread to modify a Collection while another thread is iterating over it.
That's what the documentation says. You might figure out what happens when you make your function non-static. And please debug your code.
- do not name variables with capital letter ("Element") That's really dangerous and can have side effects as Object names are started with a capital letter (e.g."System", "BufferedReader").
- always use English comments.
regards
Torsten
I never finish anyth...
|
|
|
|
|
I want to identify an image in an application window.
To be more specific, I want to know how i can identify if the image exists
and if it is at the right location in the window.
|
|
|
|
|
Where "identify" means what exactly?
If you mean you want to figure out that a picture, for example, has a dog in it then you need to research pattern matching algorithms (or maybe "image pattern" but something like that.)
The algorithms are independent of language.
|
|
|
|
|
I have PictureDrawable that I wish to save as an image (JPEG/PNG) but I can't seem to find any information how to go about this.
I tried this but it does not seem to work
PictureDrawable myDrawable = GetPictureDrawable();
Bitmap bitmap = Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888);
myDrawable.draw(new Canvas(bitmap));
bitmap.compress(CompressFormat.JPEG, 100, new FileOutputStream("/MyLocation/MyImage.jpg"));
What am I doing wrongly?
www.belfox.net
...Simplicity at its best
|
|
|
|
|
|
1.
public static void savePic(Bitmap bitmap, String saveFilePath) throws Exception {
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(saveFilePath));
bitmap.compress(Bitmap.CompressFormat.JPEG, 80, bos);
bos.flush();
bos.close();
}
2.
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> add in the file "AndroidManifest.xml"
3.
Bitmap bitmap=BitmapFactory.decodeResource(this.getResources(), R.drawable.g7);
try {
savePic(bitmap, "/mnt/sdcard/test.jpg");
} catch (Exception e) {
e.printStackTrace();
}
modified on Friday, June 3, 2011 1:22 AM
|
|
|
|
|
Your answer shows how to save a Bitmap to a the SDCard. However, my question was how to save a PictureDrawable to the memory card.
I needed to know how to convert the PictureDrawable to a Bitmap.
www.belfox.net
...Simplicity at its best
|
|
|
|
|
private static Bitmap pictureDrawable2Bitmap(PictureDrawable pictureDrawable){
Bitmap bitmap=Bitmap.createBitmap(pictureDrawable.getIntrinsicWidth(),pictureDrawable.getIntrinsicHeight(), Config.ARGB_8888);
Canvas canvas=new Canvas(bitmap);
canvas.drawPicture(pictureDrawable.getPicture());
return bitmap;
}
|
|
|
|
|
I need to embed an excel sheet into a java GUI.
Read online that it can be done using "owc".
Can someone please tell me how I can use "owc" in
my java code.
|
|
|
|
|
|
You need a Java-COM bridge tool which will wrap your Excel COM object in a Java proxy. Many moons ago we used a tool from J-Integra to run a Word mail merge from Java but someone may have produced an open source version which will work: JACOB
Disclaimer: We ran the Word merge from command line, not integrated into a Swing app. J-Integra appears to support Swing integrations, but it's a very old page and does the integration through a JBuilder (Jurassic version 3.5!) GUI tool.
|
|
|
|
|
Hi,
did you manage to achieve your goals? I'm looking into the same topic but do not find anything promising.
regards
|
|
|
|
|
Hi.
I'm new at Java... also helping my girlfriend to do her work (sigh:P)....
Anyway... im stuck a bit at adding text to an existing file...
Is there any simple way editing this?
try <br />
{<br />
PrintWriter inFile= new PrintWriter(new FileWriter("Text.txt"));<br />
PrintWriter inFile1= new PrintWriter(new FileWriter("Text1.txt"));<br />
<br />
<br />
for (SOMETHING Element:Something)<br />
{<br />
izhod.println(Element.inFile());<br />
izhod1.println(Element.inFile1());<br />
<br />
<br />
}<br />
inFile.close();<br />
inFile1.close();<br />
}<br />
catch(Exception e)<br />
{<br />
System.out.println("Error.");<br />
}
Or must i rewrite everything and use buffered reader? If thats so, can you show me what to do
Thanks in advance!
Regards,
Matjaž
|
|
|
|
|
japp, try to use BufferedReder and BufferedWriter - if allowed by your teacher
There are great Tutorials at oracle.com:Big Index @ oracle.com[^]
please bookmarks that one and refer to it when having trouble. They are really well made.
For your current situation I'd suggest File I/O operations[^]
regards
Torsten
I never finish anyth...
|
|
|
|
|
Ha ha! You are good! I come from China, I love programming, a student, my English is good bad, I came here to learn more technical and handed foreign friends, thank you! Is there any way I can chat with you, I want to speak English, MSN it? Or e-mail?
Hi ! My name lanmingle , i from china .
|
|
|
|
|
Hi,
I have a class "worldstore" that is derived from "Service" class and implements interface "ILamp".
I have a method called "getState" in ILamp interface which returns a "boolean" and another method is available with the same name in "Service" base class which returns an "int".
While implementing the methods of the interface in "worldstore" class, I get an error when implementing "getState" from ILamp. Whereby, eclipse detects it to belonging to the base "Service" class rather than that of the ILamp interface, and therefore asks me to change the return type to boolean.
All i want is to implement the "getState" method from the interface.
Any solutions please... I am using java 1.6
Thanks.
|
|
|
|
|
I think your question got answered here[^].
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
Thanks for the reference link...
But still i am unable to grasp the solution being a novice programmer.
Should i make another interface that links to my "ILamp" interface. And then implement the new one in my worldlamp class.
Ok for a little help here is my current current class structure:
package mw;
import org.mundo.bas.DoILamp;
import org.mundo.bas.ILamp;
import org.mundo.rt.Service;
import org.mundo.rt.Session;
import org.mundo.rt.Signal;
public class worldlamp extends Service implements ILamp {
private String CHANNEL_NAME = "";
private static final String ZONE_NAME = "lan";
private DoILamp doLamp;
public worldlamp(String ch) {
CHANNEL_NAME = ch;
}
public void init() {
try {
Signal.connect( getSession().subscribe(ZONE_NAME, CHANNEL_NAME), this);
doLamp = new DoILamp();
Signal.connect(doLamp, getSession().publish(ZONE_NAME, CHANNEL_NAME));
} catch (Exception x) {
x.printStackTrace();
}
}
@Override
public void setState(boolean b) {
doLamp.setState(b);
}
@Override
public boolean getState() {
return doLamp.getState();
}
}
And the ILamp Interface
package org.mundo.bas;
import org.mundo.rt.ActiveArray;
import org.mundo.rt.ActiveMap;
public interface ILamp
{
public void setState(boolean b);
public boolean getState();
}
I don't have the source for "Service". Its a Jar library.
And i can't change the ILamp interface too... It is generated from a script... so has to stay the same...
Kindly can you please give me a solution to this...
|
|
|
|
|
Getting an error while implementing the last method "getState"...
|
|
|
|
|
you should read the error message carefully, it is meant to tell you what is wrong. And if you can't figure it out, don't tell us there is "an error", give the detailed error message.
The clue is in the first answer at SO, basically in
void IControl.Paint()
{
System.Console.WriteLine("IControl.Paint");
}
void ISurface.Paint()
{
System.Console.WriteLine("ISurface.Paint");
}
you see the interface name is prefixed to the method name, that is how they get discriminatated when defining them, and if necessary also when calling one of them (it would be necessary if the "signature", i.e. the list of argument types, is the same and hence not telling the methods apart; the method matching is based on method name and parameter list, and NOT on the return type.
If you are convinced you need all this, and it is beyond your current knowledge of the language, my best advice for you is to choose, buy and study an introductory book on Java. That will teach you all the basics, in a consistent and speedy way.
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|