java

How to create a process in Java

Hi, I would like to create a process in my application. But after looking around and from Java's API I still don't quite get it. Basically I want to create a multi process application. But the new process is a class in my application. I know some of you might ask why not create a thread? Because the class is calling a matlab code, the...

Java PrintServiceLookup.lookupPrintServices() can't find Brother printers

I've run into a strange issue where printers manufactured by Brother (one in particular is the Brother HL-2140 printer) do not appear in the PrintService array returned in the following code: PrintService[] printers = PrintServiceLookup.lookupPrintServices(DocFlavor.BYTE_ARRAY.AUTOSENSE, new HashPrintRequestAttributeSet()); So far, th...

Right click on JButton

Hi guys, I am trying to write a Minesweeper clone in Java for fun. I have a grid of JButtons whose labels I will change to represent the danger count, flags, etc. My problem is, I don't know how to get a right click on a JButton to depress the button. I've done the following: button.addMouseListener(new MouseAdapter(){ public ...

Looking for SVG drawing application, open source based on Java apache batik library

Can you recommend a free, open source, drawing application, like Inkscape, but written in Java based on the Apache batik code library? ...

Create and fill an xml document with xmlbeans

Hello, Some time ago, I was using XmlBeans at work and had to create programmatically an xml from a schema. Back then, I compiled the schema using XmlBeans and then used some XmlBeans functionality (I cannot recall its name right now) to create a valid xml which had all the optional and required tags and attributes. I am leaving this q...

Java method call overloading logic

Hello, For the following code why does it print A, B? I would expect it to print B, B. Also, does the method call performed by the JVM is evaluated dynamically or statically? public class Main { class A { } class B extends A { } public void call(A a) { System.out.println("I'm A"); } public void...

How can I get a Unicode character's code?

Let's say I have this: char registered = '®'; or an umlaut, or whatever unicode character. How could I get its code? ...

Unable to change the jFrame icon / load a resource for a .jar with Eclipse.

I'm trying to load an ImageIcon as described here, but I'm getting an error. Tried the method here too, but ran into the same error. It says: "Uncaught error fetching image: java.lang.NullPointerException..." I couldn't find a solution to this. I can load the image icon using this: setIconImage(new ImageIcon("etc/image.png").getImage(...

How to leverage development tools

I want to learn how to make best use development tools such as - Maven, SVN, and Eclipse. While I know how to use these tools separately, I'm interested in learning how best to use them in concert to make development more efficient and effective. A couple of example questions follow: Once you've created a project using maven, what aspe...

Limit JTextPane memory usage

I have an application which continuously receives data on a socket, and then logs this data to a file while also displaying this data in a JTextPane. Naturally, as data is written to the underlying document of the JTextPane the memory usage continues to increase. Is there a simple way of limiting the memory which the JTextPane is allowe...

Tools for visualizing and implementing elliptic curve cryptography

I need to create a program which will show how elliptic curve cryptography works. I was considering using Java Swing to create the GUI, but the main problem is what tool to use to plot the elliptic curve itself, and how to integrate that with Java Swing. I would like the plot to be included in the user interface and also allow changes ...

Configuration reload with Jakarta Commons Daemon

Using Jakarta Commons Daemon is it possible to have my Java application perform an action (reload a configuration) when a SIGHUP signal is sent to the jsvc process? If not - what are my other options for reloading the configuration with this library - without stopping the process? I have looked at the documentation but didn't find it tha...

How to encapsulate an array in Java

Hi, i'm starting with Java and i'm learning about setters,getters and encapsulation. I have a very simple program, 2 classes: Container has a private int array (numArray) with his setter & getter. Main creates a Container object and uses it in totalArray method. public class Container { private int numArray[]= {0,0,0}; pub...

Java GUI and Multiple Instances of the SwingWorker Class

I'm making a GUI using Java (who isn't?). I know the Swing Worker class enables computation in the background to prevent the GUI from hanging, but I was wondering if there could be too much of a good thing here... For instance, if there were too many instances of those background threads running, would it impact the performance of th...

GUI for serial port using java

Hi geeks, I am explaining my full problem. So I am building one GUI for a device connected to my PC using serial port. I am using javacomm apis and eclipse as my tools. For writing data to serial port I am using thread and for reading I will use a thread or EventListener. So now my question is if I am sending any command to serial port ...

Loading Constants from db and reading them in an include file

I have a list of constant values which are stored in a database table. My application's search form is generated by a common include file which can be placed in any JSP page on the site. This search form should include the constants from the database table. A Spring bean manages the database layer and I'm having trouble finding an approp...

jProgressBar with Database

Hi, how do I display the progress in a jProgressBar when I write something in the database? Thanks ...

Hibernate UserType and a defined length

I have a hibernate Usertype something like this: public class UUIDHibernateType implements UserType { private static final int[] SQL_TYPES = new int[] { Types.CHAR }; public int[] sqlTypes () { return SQL_TYPES; } // ... } The problem I have is, that hibernate generates a sql script with the types CHAR(1)...

*Nix ls Command in Java

Anyone aware of a method/class/library that will allow me to easily reproduce the results of the *nix ls -l command in Java? Calling ls directly is not an option due to platform independence. eg. $ls -l myprogram.exe -rwxrwxrwx 1 auser None 1261568 Nov 15 17:41 C:\myprogram.exe ...

Getting all mapped Entities from EnitityManager

I have a piece of maintenance code that should grant select privileges to a certain user at certain points of time: grant select on A_DB.A_TABLE to READ_ONLY_USER; I want to do this for all tables. I could use select * from tab in Oracle or show tables in MySQL to get the complete list and then move on like that. But since I already ...