java

Painting a custom JScrollBar

I want to completely change the look of a scollbar but overriding JScrollBar and the paintComponent method doesn't work, the track and thumb are painted but the left and right arrows stay the same. I am also using them inside a JScrollPane and using setHorizontalScrollBar( new CustomScrollBar() ) to set the scroll bars to my custom scrol...

How to draw a 2d overlay on a Java 3d scene?

I have a scene written in Java 3d, where the user's viewing position is set to some coordinate using the following code: ViewingPlatform vp = simpleUniverse.getViewingPlatform(); TransformGroup steerTG = vp.getViewPlatformTransform(); Transform3D t3d = new Transform3D(); steerTG.getTransform(t3d); t3d.lookAt( new Point3d(-5, 1...

Custom Java Iterator with type confusion

I have a generic class which bundles an Object and an order: public class OrderedObject<T> { private int order; private T object; public OrderedObject(int order, T object) { this.order = order; this.object = object; } public int getOrder() { return order; } public T getObject() { ...

Additions to the Java core since 1.3?

I started a little contract job that requires me to use Java. I was given a Java book by the project manager, but it covers Java 1.3 and I understand that Java is now around 1.6. I would like to know if there are any major core additions to the language that I can read up to after getting the basics down with this book? ...

Beginner Java (Help with class assignment)

This is a lab I am working for for a CSE 201. The program is supposed to read information about students and their scores from a file, and output the name of each student with all his/her scores and the total score, plus the average score of the class, and the name and total score of the students with the highest and lowest total score. ...

Syntax error on ArrayList declaration

Hi, I've got the following code: import java.util.*; public class Group { public static void main(String[] args) { ArrayList<Integer> list = new ArrayList<Integer>(); } } Eclipse (3.0.0) complains about the ArrayList declaration: syntax error on token "(", on both tokens "<", and then on token "=". I'm using java 1.5.0_0...

Query.executeUpdate() results in XAResource exception

I'm running Spring and Hibernate's implementation of JPA on Sun's GlassFish Enterprise Server with MySQL. When I try to delete stuff from the database: Query q = entityManager.createQuery("DELETE FROM SomeEntity e"); q.executeUpdate(); I get the error: Caused by: java.sql.SQLException: Error in allocating a connection. Cause: java.l...

Print gif using java on a 4x6" paper

What is the best way in Java to print a gif given as byte[] or ByteArrayInputStream on a paper with a size of 4x6 inches? This: PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); aset.add(new MediaSize(4, 6, Size2DSyntax.INCH)); aset.add(new Copies(1)); PrintService[] pservices = PrintServiceLookup.lookupPrintServices(...

dynamic filtering of java object

I have following java object Obj: ---- String id; List<A>; A: -- String A_ID; String A_PROPERTY; What I am looking for is to be able to search in a given object. ex: search in a list where A.A_ID = 123 I need to dynamically pass A_ID = 123 and it would give me A_Property I know I could search through a list through iterator, ...

What would make Ant execute 'javac' in Eclipse with UTF-8 instead of my system default Cp1252?

The last week I've been trying to figure out why some stream decoding my newly adopted application is doing was giving me some major encoding problems. Finally I figured out that the problem was that the JARs/WAR being built with Ant and deployed to the server were being compiled with the javac task using the encoding UTF-8 instead of th...

Spawning a separate process from within a unit test

I have some unit tests (yes, perhaps more integration-ey tests !) that I would like to spin up another jvm, and then run the test code from that "other" JVM (and wait for it to finish, collecting the results). Am interested if there is an easy/reliable way of doing that with junit (eg inherit the classpath of what is needed etc...) Any...

Why can't I query SolrJ for a URL?

I have a Solr schema that has a "url" field: <fieldType name="url" class="solr.TextField" positionIncrementGap="100"> </fieldType> <fields> <field name="id" type="string" stored="true" indexed="true"/> <field name="url" type="url" stored="true" indexed="false"/> <field name="chunkNum" type="long...

Java XML parsing using DOM to get nodevalue

try { String data = "<a><b c='d' e='f'>0.15</b></a>"; DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory .newInstance(); DocumentBuilder documentBuilder = documentBuilderFactory .newDocumentBuilder(); InputSource is = new InputSource(); is.set...

Problem In Adding an Icon to the Label of a JCheckBox Component

I try to describe an image through HTML tag as follow : http://www.exampledepot.com/egs/javax.swing/checkbox_AddIcon.html If I use the following HTML tag, it works <html><table cellpadding=0><tr><td><img src=file:C:\user\network-transmit-receive.png/></td><td width=3><td>Hello World</td></tr></table></html> However, when I use the f...

Manipulating fields in the jTable Java

I have populated my jTable with the following Code. It has two columns, the first has variable name and the second is a list of its dependencies. The user can change the dependencies by selecting them from the list in the jTable. When the user changes a value, I want to row to be added to another jTable (which would be no user editable....

JETTY 7.0.0.pre5 missing method LogFactory.setLogImplClassName

I'm trying to start JETTY from a shell script (previously we used Maven), and I'm coying over some dependent libraries into the JETTY_HOME/lib directory which appears to be causing Classpath conflicts, I'm trying to sort out where the proper LogFacotry.class exists, here's the exception I'm getting on startup. 2009-08-17 22:00:40.661::W...

How do I modify the set method signature that Eclipse auto generates?

My current project has the coding convention that instance variables are never referred to with the this. prefix and that parameters should never hide instance variables. This results in setters that look like: public void setFoo(final Foo aFoo) { foo = aFoo; } Unfortunately eclipse won't generate that for me by default. I've found...

Why is this invalid Java? Type of ternary operator output.

Check out this code. // Print object and recurse if iterable private static void deep_print(Object o) { System.out.println(o.getClass().toString() + ", " + o.toString()); boolean iter = false; Iterable<?> i1 = null; Object[] i2 = null; if (o instanceof Iterable<?>) { iter = true; i1 = (Iterable<?>) o; } else if (o ...

how do i populate JCombobox with arraylist

I need to populate jcombobox with ArrayList is there is any way to do this. Abdul Khaliq ...

ConcurrentHashMap vs Synchronized HashMap

What is the difference between using the wrapped class, SynchronizedMap, on a HashMap and ConcurrentHashMap? Is it just being able to modify the hashmap while iterating it (ConcurrentHashMap)? ...