java

Best way to close a stream an SAX parser is reading during the parsing process?

Hello dear Stackoverflow community! Let's get straight to my question: I have a socket and all input coming via this socket / stream is parsed by my SAX parser. Now, upon a certain parsing event I'd like to close the socket / stream from within my SAX event handler. Also, I want to close the stream from outside in a certain case while t...

How can I update my JTable data automatically when the database is updated?

How can I update my JTable data automatically when my database is updated? Thanks. ...

Binary Trees question. Checking for similar shape

Hi I'm stuck doing this, not sure how to go about it. If I have two binary trees, how would I check if the have the same shape? Data in the nodes doesn't matter, just if the tree structures are equal. Any ideas on how to solve this problem? ...

How to force redraw of an ex-invisible group's content in SWT?

Hi all, I'm a total noob in SWT, just getting started, but I have previously worked with GUI frameworks such as Swing. I have a Composite which contains a Group and a Button. The Group is initially set to invisible (using group.setVisible(false)), and is set to visible when clicking the button. This starts a thread which perform some c...

TreeViolationException problem

Hi Im having some trouble when inserting to the right of a node in a binary tree... I just dont see why the exception is happening. This is the method to inset: public void attachRight(BinaryTree<T> tree) { if (right != null) { throw new TreeViolationException(); } if (tree != null) { tree.parent = this; right = tree; } } ...

Class introspection in Common Lisp

Java's java.lang.Class class has a getDeclaredFields method which will return all the fields in a given class. Is there something similar for Common Lisp? I came across some helpful functions such as describe, inspect and symbol-plist after reading trying out the instructions in Successful Lisp, Chapter 10 (http://www.psg.com/~dlamkins/s...

LongClick event also triggers Click event

I use onLongClick and onClick events of a button to get user inputs. Whenever; the user long click and triggers onLongClick event, the onClick event is also triggered. I couldn't find my problem. The code of two methods are shown in below: @Override public void onClick(View v) { switch(((Button) v).getId()) { case R.i...

What is the most commonly used Java web framework?

Which of the following frameworks is the most commonly used in Java right now and, if different, which framework is growing in popularity the fastest in terms of adoption? Stripes Spring MVC Struts Struts 2 Tapestry Wicket JSF No Framework - Pure JSP/Servlet Grails Some other framework not mentioned here ...

Can I add classes to sun's rt.jar file?

I downloaded the Javax.mail package. I have jdk1.6.0_11. Problem is...I cannot get javac or java to find those classes! I can get apps to compile using JCreator LE ( by adding the mail jar to its search list ) but, when I try to run the app in a command window, it fails. Can I add these new classes to the rt.jar without hurting my jdk ...

Sequenced video playback (cutlists) in Java.. can it be done?

If I have a bunch of video files, all in precisely the same format, shape, whatever, then can I play them back seamlessly without jumps or gaps? The effect from the end user's point of view would be as though they are watching one video. I understand that this is possible in DirectX, but I'd rather use Java if possible. ...

How captured value in anonymous methods are implemented in .NET

I am curious about the actual .NET implementation and the decision behind it. For example in Java, all captured values used in an anonymous classes are required to be final. This requirement seems to be dropped in .NET. Also, is there a difference in an implementation of captured values for value types as opposed to reference types? T...

How do I parse text into lists in Java?

I have the following file saved as a .txt: I Did It Your Way, 11.95 The History of Scotland, 14.50 Learn Calculus in One Day, 29.95 Feel the Stress, 18.50 Great Poems, 12.95 Europe on a Shoestring, 10.95 The Life of Mozart, 14.50 I need to display the title of the books and the prices on different JLists in Java. How do I do that? A...

How to determine if binary tree is balanced?

It's been a while from those school years. Got a job as IT specialist at a hospital. Trying to move to do some actual programming now. I'm working on binary trees now, and I was wondering what would be the best way to determine if the tree is height-balanced. I was thinking of something along this: public boolean isBalanced(Node r...

Keyboard Polling System

I'm looking for an efficient keyboard input system for a game in Java. At present I'm using some code I found here: Keyboard Input Polling System it seems a little inefficient however (please comment as to your thoughts on the code). The full code is available here: Pastebin Code I've only just started looking into a new solution a...

Java Swing - JList custom cell rendering - capturing actions

Any time I make a custom cell renderer for a JList, any elements I add to it don't ever respond to actions. For instance, If I have the cell renderer return a JPanel with elements on it, one of which has an ActionListener, it doesn't respond at all. Why is this? ...

How to get executable file of Java programm...

Im trying to export a program written in java (JDK 1.6.0) to a .jar file. To my project, I have added one Java library(which was available on internet) and some Java source files. So when i create the jar file, the classpath should be set by default and the person should be able to run the project directly either from command prompt or...

Acquiring a spring configuration value from a custom class

I'm considering using Spring to assemble the components of my application, but I've got a problem. Our application uses a configuration repository that is global to the VM, and is similar (but not precisely) to the system properties. This configuration API is accessed like so: Configuration.getDb ().get ("some_property_name") Is the...

What is the fastest way to learn JPA ?

I'm looking for the best resources (books, frameworks, tutorials) that will help me get up to speed with JPA. I've been happily using iBatis/JDBC for my persistence needs, so I need resources that will hopefully provide comparable functions on how to do things. e.g. how to I set the isolation level for each transaction ? I know there m...

JAVA - Difficulties with a simple server seeing the clients

Hello, I am trying to make a simple game that goes across a TCP network. The server does something like this to check for connections, in Server.java: try { server = new ServerSocket(port); System.out.println("Server started on port " + port); while (true) { socket = server.accept(); System.out.println(...

Tags and attributes in Lucene shared across documents

My app needs to keep an index of files in which the files are known by tags and attributes, suggesting a Lucene (Java) document schema like: tags: i s (indexed, stored) attributes: i s content: i fileId: i s (The actual file is looked up by id in sqlite.) However, while a file has only one set of tags/attributes, it may have multiple ...