java

Planning view component in Swing

I need to build a Swing GUI like this where there are typically 40 tour columns. In each column there are typically up to 20 orders per tour. Orders may be grouped together within a tour. It should be possible to horizontally enlarge to columns, to D&D orders within a tour and to other tours. Later the representation might change includ...

What is the generic signature of a method that returns an instance of a given subclass?

Basically I want to create a method that has a signature like the following: public <T> T getShellTab(Class<T extends ShellTab> shellTabClass) but this isn't valid Java. I want to be able to pass a class that is a subclass of ShellTab and have an instance of that class returned. public <T> T getShellTab(Class<T> shellTabClass) wor...

Is a Java int always 32 bits?

Will Java's int always and everywhere be a 32 bit signed integer? ...

Will using multiple threads with a RandomAccessFile help performance?

I am working on a (database-ish) project, where data is stored in a flat file. For reading/writing I'm using the RandomAccessFile class. Will I gain anything from multithreading, and giving each thread an instance each of RandomAccessFile, or will one thread/instance be just as fast? Is there any difference in reading/writing, as you can...

Is there a way to "attach" Swing frames to one another?

We have a program with multiple top-level swing windows (frames). We are adding some "debug mode" where for each window of the original application there should be a specialized window that displays some information and offers some controls related to the original window. This is running in the same process as the original application s...

GWT Visualisation API DataTable Serialization

I am trying to follow this tutorial on how to connect to a database in GWT, but instead of creating a login program, I am trying to retrieve a GWT Visulation DataTable from my DB so that I can then create a Annotated TimeLine. I have gotten very far, but I hit the final wall I can't figure out. Unlike the tut, I am not returning a simpl...

Customize Internet Explorer for showing help

Hi all, The company I work for want to put their help files online and they want it to look like the online help in Excel. This is a browser with minimum functionality, the addressbar is removed and so are most of the buttons except for basic navigation. I am not even sure if this actually is Internet Explorer come to think of it. I can...

Java access to big file

I am looking for an efficient way to create a file whose size is unknown but can range from mb's to gb's and fill its content randomly. I may write first 200 bytes than jump to the end and write last 200 bytes and move to the middle and write there. Is RandomAccessFile efficient for doing this or are there any alternatives better suited ...

How to change XML based on regex matches to text (character data)

I am trying to match the text contents(character data) of an XML file with a series of regexs and then change the XML based on the matches. Example: <text> <para>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </para> </text> I want to match for instance ...

mixing autoproxycreator and proxyfactories in spring

How do I mix BeanNameAutoProxyCreator and (Transaction)ProxyFactoryBean in such a way that there is only one proxy? I want to create a proxy with JamonInterceptor, but some have also an transaction interceptor/factory bean defined and these show up as $ProxyXYZ in Jamon. I use spring 2.5.6 ...

how to personnalize item display in a JSF selectOneMenu component ?

Hello, I am actually using h:selectOneMenu to display items, given to it from f:selectItems tag. Rather than displaying a text, I wanna prefer to display an image. How is it possible, since there I have not found any way to render html coming from the selectItem "value" attribute ? Thanks, here is my current code, without any image d...

difficulties getting a simple envers example to work: problem #34

I'm trying to get a simple envers example to work. I have the Java code working (apparently), and I finally got the org.hibernate.tool.ant.EnversHibernateToolTask to work, but it only outputs SQL for the "regular" data, not the versioning data. I'm stumped for what to do next. What might I be forgetting to include? Here is the SQL it o...

Java Collections Implimentations (e.g. HashMaps vs HashSet vs HashTable ...), what is the cost of choosing the wrong one?

In my code I default to using ArrayList for all Lists, HashMap for all maps, HashSet for all sets. From a practical standpoint how much am I losing in flexibility, scalability, readability and performance by choosing the wrong implementation? When does it make sense to spend time to decide to use one rather than another? I certainly se...

Embedding a JPanel in a Frame

I created a Java application in NetBeans which consists of a bunch of components on a JPanel. I know want to embed this application on a frame which will be a completely separate application. I can't seem to be able to do this...any suggestions? ...

JAVA - Inserting a new line at the next space after 30 characters

I have a large block of text (200+ characters in a String) and need to insert new lines at the next space after 30 characters, to preserve words. Here is what I have now (NOT working): String rawInfo = front.getItemInfo(name); String info = ""; int begin = 0; for(int l=30;(l+30)<rawInfo.length();l+=30) { while(rawInfo.charAt(l)!=' '...

Is it possible to read the Process stdout InputStream into an NIO ByteBuffer?

Is it possible to use NIO to process the stdout from a Process? I have it working with java.io, but this is something of an exercise to learn a bit more about NIO and to explore the possibility of performance improvements. Basically I want to stream a large volume of text from stdout into a buffer as fast as possible without blocking, ...

Swing: How can I prevent flickering and "vibrating" of a component, when restricting its movement?

Hello! I need to restrict movement of a component (JInternalFrame) inside a JPanel. More exact: a component should only move along one axis when dragged by the user. I tried to do it by adding a component listener and reset the position of one axis everytime the component moves. But it "vibrates" (moves rapidly during dragging). I eve...

Java file upload applet - Suggestions needed

I want to build a simple file uploading applet in Java. It will be used to upload files to a regular linux web server. So if someone went to: http://site.com/file-upload-applet And uploaded a file there via the applet, it will be accessible at: http://site.com/uploads/your-file.jpg The user should be able to click 'Browse', and the...

MySQL MD5 and Java MD5 not equal

The next function in MySQL MD5( 'secret' ) generates 5ebe2294ecd0e0f08eab7690d2a6ee69 I would like to have a Java function to generate the same output. But public static String md5( String source ) { try { MessageDigest md = MessageDigest.getInstance( "MD5" ); byte[] bytes = md.digest( source.getBytes("UTF-8") ); ...

Iterate all XML node generations in java DOM

I want to check to see if an XML document contains a 'person' element anywhere inside. I can check all the first-generation elements very simply: NodeList nodeList = root.getChildNodes(); for(int i=0; i<nodeList.getLength(); i++){ Node childNode = nodeList.item(i); if (childNode.getNodeName() == "person") { //do something with ...