java

What's wrong with this colored JTree? (custom renderer problem)

Hi, I want write custom TreeCellRenderer to have Root, nodes and leafs in different color. This is my code: tree.setCellRenderer(new DefaultTreeCellRenderer() { @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { { ...

How do I add a namespace attribute to an element in JAXB when marshalling?

I'm working with eBay's LMS (Large Merchant Services) and kept running into the error: org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize. After alot of trial and error I traced the problem down. It turns out this works: <?xml version="...

Can/should JPA be used to return values rather than entities?

I'm using JPA for a project and in most cases, want to get entities, but there are a few cases (reporting being one of them, but there are others) where I do not want or need to get entities, but rather want a selection of values. Does JPA support this? If so, does it make sense to use it or does it make sense to use straight JDBC in the...

Calling JMX MBean method from a shell script

Are there any libraries that would allow me to call a JMX MBean method from a shell script. We expose some operations/admin commands through JMX, and we could have our admins use JConsole, or VisualVM, but some tasks are better left to automation. In that automation we'd like to be able to call a JMX MBean method on our running server, p...

Are there any plans for Java to add generic collection covariance?

I was trying to write some code that looked like this: public List<IObject> getObject(){ ArrayList<ConcreteObject> objects = new ArrayList<ConcreteObject>(); return objects; } (Where ConcreteObject implements IObject) This doesn't work at all. It gives a compiler error. Does Java have plans to support this in the future? What is ...

Can't get AllPermission configured for intranet applet. Can anyone help?

Hello everyone, After doing a lot of reading and testing I've been unable to give all permissions to an intranet applet through the codeBase grant option. This applet need full permissions because it will have to acess driver libs for OCR readers (which also write image files to HDD) and other such external devices. I've configured my ...

Swap two elements in a list using JDO on Google Appengine

I have a TestEntity that has an ArrayList of ChildEntities. They are joined in a owned relationship. I want to get the Entity from the datastore, update an int field in the child entity, and then swap the position of the two child entities. However, as soon as I swap the entities, it appears as though the updates to the int field are e...

Match regexp in java

String text = "[! hello ¡world ¡] otra cosa ¡]"; String pt = "\\[!(.*)¡\\]"; Matcher mc = Pattern.compile(pt).matcher(text); while( mc.find() ){ System.out.println(mc.group(1)); } This code prints hello ¡world ¡] otra cosa. What would be a pattern that matches only hello ¡world? What I don't find is a way to negate a literal stri...

SASS implementation for Java?

I'm looking for SASS implementation in Java (could be used with JSP/JSF). For Python I've found CleverCSS, but there is nothing for Java. Anyone heard something about this sort of tool for generating CSS? ...

Why do errors no longer appear in Eclipse's package explorer?

My project used to be fine - errors showed up in the file margin, the editor breadcrumb, the problems view and in the package explorer tree as little red X marks. Somewhat spontaneously though, it's stopped working properly. If I introduce an error into my code, it shows up in the file margin, and nowhere else. It takes a 'project clea...

How to scale markers on Android, and set shadow and onTap correctly

I'm scaling markers on a MapView with the following code OverlayItem oi = new OverlayItem(point,"Title", "Desc"); oi.setMarker(getCustomMarker(0.5f, 0.5f)); itemizedOverlay.addOverlay(oi); and: private BitmapDrawable getCustomMarker(float scaleWidth, float scaleHeight){ int width = originalMarker.getWidth(); int height = orig...

Allocation latency seems high, why?

I have a (java) application that runs in a low latency environment, it typically processes instructions in ~600micros (+/- 100). Naturally as we've moved further into the microsecond space the things you see that cost latency change and right now we've noticed that 2/3 of that time is spent in the allocation of the 2 core domain objects...

configuring nutch regex-normalize.xml

I am using the Java-based Nutch web-search software. In order to prevent duplicate (url) results from being returned in my search query results, I am trying to remove (a.k.a. normalize) the expressions of 'jsessionid' from the urls being indexed when running the Nutch crawler to index my intranet. However my modifications to $NUTCH_HOME/...

Updating JTree nodes background color at runtime.

Hi, I need to change tree nodes color when business logic updates model, wait 1 second, and then change its color back. Basically I would like to create similar thing like here http://stackoverflow.com/questions/1664924/changing-jlist-row-color-at-runtime, but for JTree. So I could use a similar technique,but I also wont to change anc...

Font.createFont leaves files in temp directory

The code below does its work but leaves copies of the font file in the temp directory each time it is run. These files are named +~JF7154903081130224445.tmp where the number seems random for each created file. InputStream fontStream = this.getClass().getResourceAsStream("handsean.ttf"); Font baseFont = Font.createFont(Font.TRUETYPE_FONT...

Mobile development book

Hi, I want to start coding applications for mobile devices. Can anyone recommend me a good book to start coding in Java? (I am an experience programmer in .NET and PHP). ...

Java: convert List<String> to a join()d string

Javascript has Array.join() js>["Bill","Bob","Steve"].join(" and ") Bill and Bob and Steve Does Java have anything like this? I know I can cobble something up myself with StringBuilder: static public String join(List<String> list, String conjunction) { StringBuilder sb = new StringBuilder(); boolean first = true; for (String...

When to use ServiceTracker vs ServiceReference

I am just starting with OSGI programming and have come across two ways to listener for services being activated. The first way, from an EclipseRCP book, uses ServiceReference: String filter="(objectclass="+IModelCreator.class.getName()+")"; context.addServiceListener(this, filter); modelCreators = Collections.synchronizedMap( new H...

wcf and java interop

How can I interop easily between WCF and a Java app.? ...

Hibernate Second-Level Query Cache not working Eager Fetching

In NHibernate Profiler I observed that when I use eager fetching on an association, using "left join fetch" in an HQL Query or .SetFetchMode() in a Criteria Query the query no longer gets cached in the query cache. In fact from what I can see only very basic queries are cached. If anyone can give me some insight into what queries get c...