java

Do I need to synchronize if I have multiple threads that will insert to MySQL?

I'll be using a multi-threaded Java program to insert new records to a table in MySQL. Is it necessary to synchronize for this? Or is it OK since each insert is a different record in my case? ...

Override JComboBox Default Colors

I'm trying to override the defaults colors used by JComboBox when the L & F is Metal. I have overridden the following in UIManager to custom colors; ComboBox.font ComboBox.selectionBackground ComboBox.buttonShadow ComboBox.buttonHighlight ComboBox.disabledBackground and control controlDkShadow controlHighlight controlLtHighlight c...

Confusing "override a private method"

I have two question on this code public class Override { private void f() { System.out.println("private f()"); } public static void main(String[] args) { Override po = new Derived(); po.f(); } } class Derived extends Override { public void f() { System.out.println("public f()"); } } /* * Ou...

Buffers and bytes?

Could someone explain to me the uses of using buffers, and perhaps some simple (documented) examples of a buffer in use. Thanks. I lack much knowledge in this area of Java programming, so forgive me if I asked the question wrong. :s ...

Why does my off screen rendering Canvas3D not work?

I've been trying to make off screen rendering to work, using Java3D 1.5.2. In my source code I've been trying to attach an extended Canvas3D that will do off-screen rendering to SimpleUniverse, but doing so will break the render: 62. // FOR SOME REASON THIS BREAKS RENDERING 63. universe.getViewer().getView().addCanvas3D(canvas); The...

__LINE__ equivalent in Java ?

I'm searching a way to include __LINE__ as a compile-time constant in outputted messages. Various solutions seem to exist, but with a big runtime penalty as suggested in __LINE__ in JS and __LINE__ in C#. They are usually always based upon a runtime object StackFrame as log4j. Using the log4j possibility of enabling/disabling on a nee...

Java: Passing Variables across classes

This is probably a really simple problem, but I can't figure out how to do it. I have a GUI class with a listener which takes variables from comboboxes and sliders. I need it to pass these variables into a method in another class which will run on an object in that class. How can I do this? ...

How do I send messages from Javascript to Java?

Hi, I'm kind of stuck because I can get JavaScript to send a message to a Java applet. I can get it to work the other way round. Does anyone know a proper way to do this that works everywhere? ...

java xml validation JDK 1.5 JDK 1.6 difference

I have a problem with Java xml validation. I have the following xsd: <?xml version="1.0" encoding="utf-8"?> <xsd:schema elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; <xsd:element name="TEST"> <xsd:complexType> <xsd:sequence> <xsd:element name="LAST_NAME"> <xsd:simpleType>...

Axis2 - Date Format

Scenario The date format which is output as a response to the Web Service client by Axis2 is formatted as "2009-08-28+01:00". I would like to change this to show only the date without the timezone information (e.g.:"2009-08-28") Configuration Libraries Axis 2 1.4.1 WSDL <xsd:element name="StartDate" type="xsd:date" />; Question ...

Keyboard Navigation and Accessibility for custom SWT widgets

I am trying to build a simple custom SWT widget and i want to ensure that it is accessible. I know that accessbility encompasses a lot of factors, but as a starting point, i would at least like to make it navigable via the keyboard. This is a simplified view of my custom control. I have overridden the 'Canvas' class in SWT. The 'Thir...

java webcam chat jmf player readExternal writeExternal

Hi there, I am developing a webcam chat with jmf. I got a little problem, and i didnt find the answer with google, i hope it you all will be able help to me. So I am streaming camera's data to socket with ObjectOutputStream Code: public class CameraTcpSocket extends Thread { private final Container con; private Socket socket; ...

Java memory allocation performance (SunOS vs Windows)

I have a very simple unit test that just allocates a lot of Strings: public class AllocationSpeedTest extends TestCase { public void testAllocation() throws Exception { for (int i = 0; i < 1000; i++) { long startTime = System.currentTimeMillis(); String a = "dummy"; for (int j = 0; j < 1000; j++) { a ...

UnknkownHostException

Please help; Am trying to deploy a web application. The build is returning successful,and am not getting any errors on the sever.log however am getting a http 503 error:the requested service() is not currently available and also my Java DB Database Process has this message Warning: UnknkownHostException: intracare: intracare. Could not...

How do I put data into the datastore of Google's app engine?

I have a little application written in php+mysql I want to port to AppEngine, but I just can't find the way to port my mysql data to the datastore. How am I supposed to save the data into my datastore? Is that even possible? I can only see documentation for persistence of Java objects, does that mean I have to port my database to a bunc...

Java newbie: infinite loop searching for specific text in a file

I'm needing to locate a string on a particular line in a text file that is composed of several lines of strings. However, my loop to find the text or the end of the file is eternally searching. I know the string is in the file. Here is the code I am using to locate the text - but be warned, if you try it on your system even with a simple...

why can't I create color in java with new keyword?

I was trying to make a new color in java using Color temp = new Color(foo.getBackground()); and it kept telling me cannot find symbol. But this works Color temp = (foo.getbackground()); Why? ...

Can I use ObjectChangeListener to listen for changes on any object?

I've got an Integer called x; if it changes then i would like to update my table in a GUI. To listen to "x" I have tried ChangeEvent y = new javax.swing.event.ChangeEvent(x); and I implement javax.naming.event.ObjectChangeListener: class HDIManagementView extends FrameView implements ObjectChangeListener, ActionListener, T...

JavaFX or RIA desktop app (on dvd) also available on the web?

Is it possible to develop an application easily available on the web that also can be distributed on DVD (installer or started from the dvd)? For the moment, we use static html (frameset!) pages (generated by xml files), with one difference: pdf's are only on the DVD version, the web version only shows a preview of these files. Can thi...

Axis2 and customizing an XML schema in a bottom-up approach

I am using axis2 to create a web service from a java class I created. Everything works well, but I'd like to be able to customize the wsdl and I cannot figure out how to do it. I tried using some JAXB annotations with my objects (using axis1) but it had no effect on the wsdl generation. I'd like to be able to specify nillable=true f...