java

Java Swing Fade Out Background

I have a Swing application and I'm trying to fade out the main application and show a window saying an operation is in progress (this is for long running operations that may need to block the UI). Is there an elegant way to do this in Swing (mainly the fading out the background) or maybe some swing library to help with this (maybe from s...

Total method time in Java VisualVM

In Java VisualVM, is there any way to display total method time, rather than "self time"? (The latter is not particularly useful, since it doesn't tell you anything about how much time methods actually take to run.) If not, is there any standalone free Java profiler that does calculate total method time? ...

How to configure & package a simple Java app to uss JPA

I'm trying to learn JPA and I want create a simple Java command line app that will use JPA to query and update a database table. I mapped out the the simple code needed to do this. But I don't know how to configure the directory structure, where to place the persistence.xml file, packaging and so on. This is just a quick and dirty lea...

JSON, JS to Java and Vice Versa, and other languages.

I want to use JSON to represent JS objects send them to a Java program, and vice versa. I would also like to do this for other languages. C# to Java maybe? What do I use to do this? (Not sure if it is refered to as serialization or data binding) Edit: Once a Java object is represented in JSON, does this mean that JavaScript can parse...

Detecting whether browser can load Java Applet successfully - Unexpected behaviour on Firefox

Hi, I have an ASP.NET page which loads a Java Applet. I am first checking that the client computer has the ability to run the applet (Java version etc) by giving the tag an ID of "AppletID" - then I call a function of this applet which always returns "true". So, the following line of code: var isRunning = document.getElementById('App...

Threading security policy

Suppose I'm writing some environment which execute clients code (Java). Clients send jar with manifest information. Environment creates some class instance from jar (suppose instance of Runnable) and run it in some thread. But I need guarantee that clients code will not start own threads or create own ExecutorService and so on. Is there...

BufferedWriter java

Write a program to keep your friends telephone numbers. You should be able to; Add a new name and number (Look up a number given a name) Save the data to an object file when you terminate the programme Restore the saved data when the program is rerun the part i am confused about is in the brackets above cla...

Need For Uniform Browser Engine

Hello There, Of course, we have been witnessing a lot of browsers differences in rendering elements, in displaying those, the support for CSS, the support for html/xhtml standards and more importantly different layout engines such as Trident, Tasman, Gecko, KHTML, WebKit and Presto which is mainly why there are differences. I just wond...

Getting Hibernate Exception : org.hibernate.QueryException: could not resolve property

Hello All... I have one table with composite key attribute.. For that i have made 2 beans for hibernate annotations mappings.. Now, it works fine for save, update and delete.. But when I am fetching using some criteria, it's giving me "could not resolve property" exception. My Beans are as follows : WBList.java @Entity public clas...

Can a single Java variable accept an array of either primitives or objects?

For example, for a single method that reads the elements of an array, how can the programmer allow either an array of objects or an array of primitives to be passed as the parameter? Object[] arrayName will only accept an array of Objects, and generic variables do not accept primitives. Is there a way to accept either type of array witho...

Java Swing JButton

I want to create button with custome look and feel. I have got different images to be set as background of button for normal, mouse over, mouse click, button disabled etc. I have created my own class, extending javax.swing.JButton and overrides paintComponent method. How can i change my button background for all the above given states. ...

Capitalize First Char of Each Word in a String Java

Is there a function built into Java that capitalizes the first character of each word in a String, and does not affect the others? Examples: jon skeet -> Jon Skeet miles o'Brien -> Miles O'Brien (B remains capital, this rules out Title Case) old mcdonald -> Old Mcdonald* *(Old McDonald would be find too, but I don't expect it to be ...

Why I have NullPointerException here?

I have created a class which name is Manager and I have a Frame which name is BirthList and this frame has a table.I work with MySQL and I have entered some data in the "birthtable" in MySQL.and i want to add those data from MySQL table in to the table which is in my frame . HINT: birthList is a list of Birth objects. but I will find thi...

how can I use font style for my whole frames or dialogs???

I have a main frame which has a menu bar and let user to change the font of all the texts in my program.I can just set the font for the main frame but how can i set that change for all my frames and dialogs??? ...

Curl syntax simulation in Java

I have a curl syntax in .sh file. I need to run the curl sytnax or curl command in Java replicating the same syntax, but I am facing problem in replicating the same. $AUTH_OPTION="--basic -u testuser:testpwd" $HTTP_METHOD=POST $FILE_OPTION="-d @$INPUT_FILE" $CONTENT_TYPE="application/xml" $ACCEPT_TYPE="application/xml" echo curl -o res...

Getting frames from Video Image in Android

I've implemented a simple application which shows the camera picture on the screen. What I like to do now is grab a single frame and process it as bitmap. From what I could find out to this point it is not an easy thing to do. I've tried using the onPreviewFrame method with which you get the current frame as a byte array and tried to de...

How do I register a service in OSGi (Apache Felix)?

Hello, everyone! I have successfully managed to start Apache Felix from code and register an own Bundle. Following relation between OSGI-projects is needed: [OsgiInterface] -- provides interfaces. [OsgiModuleA] -- (bundle) provides an implementation of those interfaces. knows [OsgiInterface] [OsgiUsage] -- makes use of one or more b...

how can I check the compiler and runtime in netbeans??

in one of my questions ,somebody said that I have to make sure that I'm not using compiler 1.6 and 1.5 runtime when i want to execute or debug my program,but I don't know how can i check compiler and runtime in NetBeans ,I am beginner with NetBeans. my question was: **I debug my project and the result was : debug: Have no FileObject fo...

Java Swing JButton

I have created customized Button. For that i have overrided paintComponenet method. How can I set Button Text on such button? I tried doing it using drawString method. But which x,y values should i give? (g.drawString("button text",x,y)). Please till me if anyone has handled this. @Override public void paintComponent(Graphics g) { s...

JFileChooser.showSaveDialog(…) - preserve suggested file name after changing directory

There are already some questions about how to set a default file name for a JFileChooser control. I'm having a few problems with preserving that default filename when switching directories. Right now, when I do that, the original filename I supplied get over overwritten by the path of the new directory itself. Is there anything can be ...