java-7

Java 7 JColorChooser: Disable Transparency Slider

无人久伴 提交于 2019-12-29 07:35:19
问题 JDK 7 added a new transparency slider to the JColorChooser: The problem is that I do not want to allow my users to pick transparent colors. Unfortunately, there doesn't seem to be an easy way to disable the slider. One way to get rid of the transparency is to just create a new color based on the selected one but removing the alpha value. However, this gives a false impression to the user as the slider now effectively does nothing and I would hate to have a useless UI element around. So my

Android Studio: what compiler settings when including Google Maps

[亡魂溺海] 提交于 2019-12-29 07:29:06
问题 I created a new project in Android Studio and added a Google Maps activity. I get these warnings: warning: com/google/android/gms/maps/GoogleMap.class(com/google/android/gms/maps:GoogleMap.class): major version 51 is newer than 50, the highest major version supported by this compiler. It is recommended that the compiler be upgraded. warning: com/google/android/gms/maps/SupportMapFragment.class(com/google/android/gms/maps:SupportMapFragment.class): major version 51 is newer than 50, the

Java Web Start broken since JDK 1.7

ぃ、小莉子 提交于 2019-12-29 04:23:05
问题 HERES THE ANSWER: It appears (through our testing) that Java 7 Web Start requires you to host your resources on a server using an SSL certificate. Your cert does NOT have to be signed, but unsigned certs will prompt the client with a trust message that they can ignore. See the below answer for more details We have an internal application which we have been using for many years now. In order to make maintenance easier for this application we have not provided an installable version of the

Any new method to get current time with accuracy in microseconds in Java now?

泄露秘密 提交于 2019-12-28 20:00:38
问题 I checked the below page that there is no method to get current time with accuracy in microsecond in Java in 2009. Current time in microseconds in java The best one is System.currentTimeMillis() which gives current time with accuracy in millisecond, while System.nanoTime() gives the current timestamp with accuracy in nanoseconds, but this timestamp could not be used to convert to current time with high accuracy. May I know if there is any new update in this for Java after 6 years? Thanks.

Why can't Java 7 diamond operator be used with anonymous classes?

只愿长相守 提交于 2019-12-28 12:16:08
问题 Consider this Java code which attempts to instantiate some List s: List<String> list1 = new ArrayList<String>(); List<String> list2 = new ArrayList<>(); List<String> list3 = new ArrayList<String>() { }; List<String> list4 = new ArrayList<>() { }; List<String> list5 = new ArrayList<Integer>() { }; list1 and list2 are straightforward; list2 uses the new diamond operator in Java 7 to reduce unnecessary repetition of the type parameters. list3 is a variation on list1 using an anonymous class,

Java: print contents of text file to screen

烈酒焚心 提交于 2019-12-28 11:54:07
问题 I have a text file named foo.txt , and its contents are as below: this is text How would I print this exact file to the screen in Java 7? 回答1: Before Java 7: BufferedReader br = new BufferedReader(new FileReader("foo.txt")); String line; while ((line = br.readLine()) != null) { System.out.println(line); } add exception handling add closing the stream Since Java 7, there is no need to close the stream, because it implements autocloseable try (BufferedReader br = new BufferedReader(new

How to set a java compiler in Netbeans

人走茶凉 提交于 2019-12-28 03:04:37
问题 I'm getting into Java7 development and I've added JDK7 into Java Platforms and have selected it in the project properties. But when I'm compiling, I get messages like: warning: java/lang/Boolean.class(java/lang:Boolean.class): major version 51 is newer than 50, the highest major version supported by this compiler. It is recommended that the compiler be upgraded. and javac: invalid target release: 1.7 /Applications/NetBeans/NetBeans 7.1.app/Contents/Resources/NetBeans/harness/suite.xml:184:

Which JDK version (Language Level) is required for Android Studio?

感情迁移 提交于 2019-12-27 12:16:28
问题 I am a new comer to the android world and with a .NET background. I am trying to install the Android Studio but I am having a mismatch on Android.com about the JDK version required for developing Android applications. From the SDK web page it states that JDK 6 is required (under system requirements section). Jim Wilson also insist in his course on Pluralsight (which is quite new, from last May) that using version 7 with the Android SDK will create a lot of headache and makes it clear to only

Java Thread priority has no effect

跟風遠走 提交于 2019-12-27 12:03:45
问题 This is a test about thread priority. The code is from Thinking in Java p.809 import java.util.concurrent.*; public class SimplePriorities implements Runnable { private int countDown = 5; private volatile double d; // No optimization private int priority; public SimplePriorities(int priority) { this.priority = priority; } public String toString() { return Thread.currentThread() + ": " + countDown; } public void run() { Thread.currentThread().setPriority(priority); while (true) { // An

Android import java.nio.file.Files; cannot be resolved

本小妞迷上赌 提交于 2019-12-27 11:06:17
问题 I am trying out the new Gmail API and the samples use the classes in the java.nio.file package, e.i. Files and FileSystems . These classes was introduced in Java jdk 1.7 for the record, and since I am running jdk 1.7.0_65 in my Android app I have no idea why Android Studio cannot find these classes. The imports are: import java.nio.file.FileSystems; import java.nio.file.Files; My build.gradle file of course tells the system to use v. 1.7 like this android { compileSdkVersion 19