java

How do I give this CPU-intensive Java application a GUI?

I'm writing a little genetic algorithm in Java, as a school assignment. Up until now I've pretty much stuck to doing console applications. However I think a UI would be really helpful for this program, so I'd like to make one. I'm having trouble figuring out how to reconcile a GUI which is event-driven, and a console application which ha...

Same instance referred to by multiple constructors

I have an instance of Class A that I want to refer to in the constructor of multiple instances of B. How can I refer to that particular instance of Class A in each new instance of B? ...

Need help with scanner class for creating tokens

Errors im getting: cannot find symbol constructor method Token. but i do have a constructor in Token class cannot find symbol variable tokenCode. i clearly use it alll over and i think i initialized it properly so whats wrong? cannot find symbol variable scantest. i have that in same folder where all classes ar...

display image after after on the panel with a time gap

import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.image.*; import java.io.*; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; public class Video implements ActionListener { static int width=480; static int he...

parse CSV files that contain unicode character using OpenCSV

hi everybody, i parse a .csv file with OpenCSV in netbeans 6.0.1. my file contains some unicode character and when i write it in output the character appears in other form(like (HJ1'-E/;) when i open this file in notepad, it is ok. the code that i used: CSVReader reader=new CSVReader(new FileReader("d:\\a.csv"),',','\'',1); String[...

ClassNotFoundException

I'm getting the following error when I try to run a Java class which interacts with Java DB. I try loading driver with : Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); In libraries, "derby.jar" do exist. I'm using NetBeans IDE 6.0. Could anyone help me to solve this problem? ...

Problems with java app and remote dbase

Hi. I'm having trouble with my java app on the database side of things. It uses connectorJ to communicate with a mysql dbase and works perfectly fine locally. When communicating with a remote dbase, it performs dismally. It's takes ages to start and windows that are supposed to open to display dbase data just say 'Exception in thread "...

what is shared variable in java

is there any concept of shared variable in java and if it is what is it? ...

Iframe not showing object from struts action class.

Hi all, This is in continuation with my previous question which was not framed properly. I have an iframe in a jsp class which is calling a struts2 action class in its src, but instead of opening inside the frame the file is getting downloaded, Inside file TempContentPage.jsp: <s:form> <iframe id="displayFrame" src="ContentPage.actio...

HTTP Request Object

Is there an object within the standard Java SE that can accept a HTTP request from a socket? I have found how to create and send one, however I have not found a way to retrieve a HTTP object from a socket. I can create one my self, but I would rather rely on a heavily tested object. This seems like something that would be readily avail...

converting java projects to c# with visual studio 2010

hello, i remember that previous versions of visual studio contained a converter, that automatically attempt to convert java projects to the corresponding c# code. however in visual studio 2010 beta 2 i cant find this anymore? has it been removed? thanks! ...

Can Sun JVM handle gigantic heap sizes without problems, and how?

I have heard several people claiming that you can not scale the JVM heap size up. I've heard claims of the practical limit being 4 gigabytes (I heard an IBM consultant say that), 10 gigabytes, 32 gigabytes, and so on... I simply can not believe any of those numbers and have been wondering about the issue now for a while. So, I have thr...

How to copy styled text in JTextPane

I'm trying to create a WYSIWYG editor using JTextPane. I'm using DefaultEditorKit.CopyAction to copy text in the editor. But this method does not preserve the style of the text. Can someone tell me how to copy the text in JTextPane and preserve the style, please ? ...

How to debug a DLL called from Java in Delphi?

With Delphi I wrote a DLL which can be called from Java via JNA (Java Native Access). Methods in this DLL are just simple operations, but for future use and more complex invocations I would like to know how I can use the Delphi debugger, if the DLL is called from Java directly (or from the Java IDE). ...

Runtime Exception while executing Contacts Demo in GD-API

I have downloaded the google data API plugin for eclipse. While dealing with the Contacts template (Demo.java), /* INSTRUCTION: This is a command line application. So please execute this template with the following arguments: arg[0] = username arg[1] = password */ /** * @author (Your Name Here) * */ import com.google.gda...

Spring integration with Struts 1 - injecting dependencies to the ActionForm

Hi all, We are expanding an old Struts 1 project to be Spring managed - yet we wish to change the code and the flow as little as possible. We have therefore decided to leave Struts to manage the requests and have delegated the actions via the org.springframework.web.struts.DelegatingActionProxy class. Example: The struts-config.xml co...

java: different return types when overloading

Hi, I have a class tree like this: master class abstract class Cell AvCell extends Cell FCell extends Cell i have an abstract method getValue() in Cell Is it posibble to make the method getValue() to return int for AvCell and String for FCell? Can i use generics for int String? Thanks! ...

How to get the name of the calling class in Java?

I would like some help on this matter, Example: public class A { private void foo() { //Who Invoked me } } public class B extends A { } public class C extends A { } public class D { C.foo(); } This is basically the scenario. My question is how can method foo() know who is calling it? EDIT: Basically ...

monitoring mysql for changes

I have a Java app using a MySQL database through hibernate. The database is really used as persistence layer: The database is read at the initial load of the program, and the records are then maintained in memory. However, we are adding extra complexity, where another process may change the database as well, and it would be nice for t...

Why can I "fake" the stack trace of an exception in Java?

If I run the following test, it fails: public class CrazyExceptions { private Exception exception; @Before public void setUp(){ exception = new Exception(); } @Test public void stackTraceMentionsTheLocationWhereTheExceptionWasThrown(){ String thisMethod = new Exception().getStackTrace()[0].getMe...