I am printing a Swing component that contains text. The Swing component renders the text just fine on the screen, but, when I print it (to a .tif file), the characters are all smashed together. Why is this?
Run this code to see what I mean:
import javax.swing.*;
import javax.swing.text.MutableAttributeSet;
import javax.swing.text.Sim...
I am programming in Java in Eclipse. I was wondering if there is a way to search for all non final static variables in my code base.
For example:
private static int MY_VAR = 0;
But not:
public static final int MY_CONSTANT = 1;
...
If you have an instance of a Collection, say something like:
Collection<String> addresses = new ArrayList<String>();
Which were to then be populated with a bunch of values, which is the "best" way, if any, to make use of the toArray() method without requiring a type cast?
String[] addressesArray = addresses.toArray(new String[] {});
...
I'd like to create a routine that does some logging, takes some other actions, and then throws an Exception. I'd like this routine to be called from many different locations. However, creating Exceptions in this routine means they will have this routine in their stack trace. I would rather the stack trace not report this utility routi...
I have a system that I need to distrubte that works as follows. Servlets served by tomcat start up and spawn off threads with a large number of shared (distributed) fields. Ergo, I set the thread as a root and attempt to spawn the threads as normal from my servlet constructor. However, logging indicates that the Runnable I'm attempting t...
For context, we are storing most of our data as JSON strings. This works very well with Hadoop on the backend and is easy to handle in Ruby on the front end. My data types fit the natural pattern for inheritance.
For simplicity, lets say I have a class Pet and a process FeedPet that feeds a pet. I also have a process WalkDog that only a...
I'm writing a small program (a twitter client) in Java, aimed at Mac OS X. As part of its functionality, it needs to have a place to store the twitter username/password. The natural place would be the mac keychain, but I can't find any way of accessing it.
Is there any way of accessing the mac keychain from Java, or failing that, what i...
Hi!
What's the rationale behind the javax package? What goes into java and what into javax?
I know a lot of enterprise-y packages are in javax, but so is Swing, the new date and time api (JSR-310) and other J2SE packages.
...
Hi,
does anyone know of a Java library to fetch webpages through https?
...
Is there a way to override Jena's default method for generating anonymous node IDs?
Ideally, I'd like to pass Jena a functor that would generate IDs so that I can make them globally unique (rather than just unique to the machine). The functor should be used whenever an AnonId is constructed.
public interface IdGenerator {
public St...
Hello!
I am writing a server program which is used to run unit tests of an API
(displaying lots of information and providing web access to control
/ monitor the whole thing)...
This API is known to the server during compile time and is provided
as a JAR.
To be able to compare between unit test results of different versions
of the API ...
Is there a way to configure log4j so that it outputs different levels of logging to different appenders?
I'm trying to set up multiple log files. The main log file would catch all INFO and above messages for all classes. (In development, it would catch all DEBUG and above messages, and TRACE for specific classes.)
Then, I would l...
This is actually two questions rolled into one.
Is there a particular type of Java functionality that people are using JRuby for or is it mainly because of the performance advantage that JRuby gives versus the MRI?
The reason I ask is, I'd like to add some Java functionality to a Rails project (just to show that it's possible). Idea...
I'm developing a system that allows developers to upload custom groovy scripts and freemarker templates.
I can provide a certain level of security at a very high level with the default Java security infrastructure - i.e. prevent code from accessing the filesystem or network, however I have a need to restrict access to specific methods.
...
Dear all,,
I want to know what could be the equivalent keyword in java which could perform same function as "Static keyword in C".. I want to do recursion in java, performing same function that a static keyword in C does...
Please help..
...
JSF 1.1, using a backing bean with a nested objects inside I can read all properties of the nested object.
For example assuming a backing bean named "foo" with a nested object "bar" can I set/write via h:form all the properties of foo.bar?
I mean something like this:
f:view
h:form
h:inputText value...
I'm trying to use Java annotations, but can't seem to get my code to recognize that one exists.
What am I doing wrong?
import java.lang.reflect.*;
import java.lang.annotation.*;
@interface MyAnnotation{}
public class FooTest
{
@MyAnnotation
public void doFoo()
{
}
public static void main(String[] a...
I'm currently deciding on a platform to build a scientific computational product on, and am deciding on either C#, Java, or plain C with Intels compiler on Core2 Quad CPU's. It's mostly integer arithmetic.
My benchmarks so far show Java and C are about on par with each other, and dotNET/C# trails by about 5%- however a number of my cow...
How can I run a servlet programme?How can i set the classpath?
...
Hi
I do a
rs.getTimestamp("datetime")
in Java.
In the database, this datetime is 2009/03/06 02:47:18
but the time is returned as 14:47:18
I'm not very knowledgeable about MySQL dates, so I would appreciate any explanation as to why this is happening.
...