java

How is a for loop structured in Java?

Is it different than C or C#? ...

How do I make a JLabel that has an imageIcon that is available to all methods and classes?

I want to have an ImageIcon in a JLabel that i will be able to update from another method. But I can't figure out a way to be able to create a static JLabel(so as to be able to acccess it from another method) and also instaiate it as a Jlabel that contains an imageIcon - is there another method other than JLabel label = new JLabel(imgIco...

Need FileDialog with a file type filter in Java

I have a JDialog with a button/textfield for the user to select a file. Here's the code: FileDialog chooser = new FileDialog(this, "Save As", FileDialog.SAVE ); String startDir = saveAsField.getText().substring( 0, saveAsField.getText().lastIndexOf('\\') ); chooser.setDirectory(startDir); chooser.setVisible(true); String fileName = cho...

Wicket: Conditional display in Template

Hy, I want to display a certain part (a div for example) of my wicket-template only under a certain condition (for example only if I have the data to fill it). The problem is: If I only add the panel (filling the div) if I got the data, an exception is thrown every time I call the page without the data (because the referenced wicket-id ...

Display a jpg image on a JPanel

What would be the most appropriate image type to display a jpg image (loaded from a local folder) on a JPanel? Cheers. ...

Spring Annotation-based controllers not working if it is inside jar file

Hi, I've some annotation-based controller inside a sub module. These modules are deployed as jar files. The annotation-based controllers from the jar file is not getting loaded to the spring configuration. I'm manually exporting the jar file using the export utility in eclipse. Did any one faced this problem? ...

Does Google App Engine Java support Hot Deployment in Eclipse?

It doesn't seem to do this by default, which is pretty shocking to me given all the other stuff they've set up to make development easy. Is there a way to enable this? If not, anybody know why it isn't supported? ...

Java UnsatisfiedLinkError when mixing AWT and SWT?

I'm an Eclipse newbie and I'm trying to build a mixed AWT/SWT application. Here's my code: public class HelloWorldSWT { public static void main(String[] args) { Frame frame = new Frame("My AWT Frame"); // java.awt.Frame frame.setLayout( new BorderLayout() ); Canvas canvas = new Canvas(); // java.awt.Canvas ...

Uses of 'for' in Java

I am fairly new to Java and in another Stack Overflow question about for loops an answer said that there was two uses of for in Java: for (int i = 0; i < N; i++) { } for (String a : anyIterable) { } I know the first use of for and have used it a lot, but I have never seen the second one. What is it used to do and when would I use it...

Which constructor is better for StreamResult()?

It's my first time posing a question here. I would like to know which constructor is better in terms of performance for a large xml dom to be written to a test.xml file: new StreamResult(new BufferedWriter(new OutputStreamWriter(new FileOutputStream("test.xml"), "UTF-8"))) Or new StreamResult(new FileOutputStream("test.xml")) Regar...

Why this code doesn't show the HTML file???

I wrote this code for showing the HTML file ,which I have chosen it from my computer!and when I choose the HTML file in my computer like FAQ.html this error messages will be shown: java.net.MalformedURLException: no protocol: FAQ.html at java.net.URL.<init>(Unknown Source) at java.net.URL.<init>(Unknown Source) at java.net.URL.<init>(Un...

scroll view issue Android

hi, I am adding layouts programmatically ,I am adding scrollview as a parent layout and and combination of horizontal and vertical linearlayouts when i add a list view in scrollview i am getting an issue that my ui is not taking full screen the listview height is set to fill parent .There is blank space added at the bottom and the h...

log4j logging to catalina.out in unix instead of log file

Hi, In my web application I am inititalizing logging in my web application by using the PropertyConfigurator.configure(filepath) function in a servlet which is loaded on startup. String log4jfile = getInitParameter("log4j-init-file"); if (log4jfile != null) { String propfile = getServletContext().getRealPath(log4jfile); ...

Get Device IP with Bonjour

Hi All I am using Java 6 update 14 for development and NetBeans 6.7. I am creating a sample client to detect particular type of service using Bonjour. I face a certain challenge where I want to get the IP address of the device. But the ResolveListener.serviceResolved(...) function, provides only Hostname and Port. The FullName also doe...

How can we set the exit button of JFileChooser???

we use setDefaultclose Operation(JFrame.EXIT_ON_CLOSE) for JFrame and those classes that implements JFrame. what can we do like this for JFileChooser????(the window that suddenly when you push browse button will pups up) ...

SOAPMessage GZIP implementation

I want to implement GZIP for SOAPMessage. Below is normal SOAP client call code - // Create a new SOAP message from the factory and set the SOAPAction header. MessageFactoryImpl factory = new MessageFactoryImpl(); SOAPMessage soapMsg = factory.createMessage(); // Set the SOAP envelope contents to our ebXML DOM. SO...

How to send out email notification for Maven build

Hi, Is there a simple way to send out email notifications in Maven for each build without outside CI tools, just like Ant? ...

simulation of static class in java

What do you think of the following way to simulate a static class in java? You can add non static methods but you wouldn't be able to call them. /** * Utility class: this class contains only static methods and behaves as a static class. */ // ... prevent instantiation with abstract keyword public abstract class Utilities { ...

Structural comparison of two ASTs in Eclipse

I am working on an incremental builder for Java code in Eclipse. Eclipse provides a ResourceDelta that tells me which resources have changed since the last build. However, I would like to have more detailed information, e.g. what methods or what field definitions changed. There seems to be functionality similar to what I want in the "com...

Is there ever justification for the "pseudo-typedef antipattern"?

I have a relatively complicated generic type (say Map<Long,Map<Integer,String>>) which I use internally in a class. (There is no external visibility; it's just an implementation detail.) I would like to hide this in a typedef, but Java has no such facility. Yesterday I rediscovered the following idiom and was disappointed to learn that ...