java-10

How do I change Swing Timer Delay inside actionPerformed()

微笑、不失礼 提交于 2019-12-06 13:27:26
So I'm building this music player app which plays notes which are dragged and dropped onto a JLabel. When I hit the play button, I want each note to be highlighted with a delay value corresponding to that note. I used a Swing Timer for this but the problem is, it just loops with a constant delay which is specified in the constructor. playButton.addActionListener(e -> { timerI = 0; System.out.println("Entered onAction"); Timer t = new Timer(1000, e1 -> { if (timerI < 24) { NoteLabel thisNote = (NoteLabel)staff.getComponent(timerI); NoteIcon thisIcon = thisNote.getIcon(); String noteName =

Jaxb package-info ignored when using Java 10

我是研究僧i 提交于 2019-12-06 12:57:09
I'm struggling with this, and any information would be greatly appreciated. I have a project that has been using JAXB for some time to construct a Java Model from an XML Schema and uses that model. This has been working in Java 8 for some tie now. However, I've upgraded to Open JDK 10 and I get this error when I attempt to Unmarshall an XML file into the Java objects.... java.lang.IllegalArgumentException: javax.xml.bind.UnmarshalException: unexpected element (uri:"http://www.minestar.cat.com/namespace/units", local:"units"). Expected elements are <{}units> at minestar.units.schema.parser

Use var in field declaration

試著忘記壹切 提交于 2019-12-06 08:38:29
So starting in Java 9, we can use var to declare local variables: var s = "cool"; is there a way to use a similar construct when declaring fields? class Container { final var s = "cool"; // does not compile tmk } doesn't seem like it from what I can tell. Jacob G. is there a way to use a similar construct when declaring fields? No. According to JEP 286: Local-Variable Type Inference : This treatment would be restricted to local variables with initializers, indexes in the enhanced for-loop, and locals declared in a traditional for-loop; it would not be available for method formals, constructor

how to add javafx dependencies in maven with java 10

血红的双手。 提交于 2019-12-06 07:23:46
I switched to ubuntu 18.04. Which has java 10 as default jvm Now my apps that use javafx cannot compile anymore. cannot find symbol [ERROR] symbol: class ObservableMap I tried to add parameters to the maven-compiler-plugin to load the javafx.graphics module. <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <compilerArgs> <arg>--add-modules</arg> <arg>javafx.graphics</arg> </compilerArgs> </configuration> </plugin> result : [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] module not found: javafx.graphics of course,

Host plug-in JavaSE has not been found in RCP application with Java 10

拜拜、爱过 提交于 2019-12-06 06:33:05
I moved my RCP application from Eclipse Oxygen to Photon, and also from Java 8 to Java 10. The code compiles and the application works fine if I start it from Eclipse. However, when I try to build my application, I get an error: plug-in JavaSE_0.0.0 has not been found Missing Constraint: Bundle-RequiredExecutionEnvironment: JavaSE-10 Host plug-in JavaSE_0.0.0 has not been found. I can't find any useful solution on Google. Maybe some of you can help me. My manifest file contains this header: Bundle-RequiredExecutionEnvironment: JavaSE-10 This seems to be an Eclipse bug. Eclipse seems not to

Local Variable Type Inference not being recognized

我与影子孤独终老i 提交于 2019-12-06 06:26:52
I installed JDK 10 to try out the new features, and I got a big hung up on var - for some reason, even though the JDK was added to IntelliJ (version 2018.1), the following code still won't compile, saying Java cannot find the symbol var : public class Variations { public static void main(String[] args) { var local = "foo"; System.out.println(local); } } Am I missing something obvious here, or is there an option in IntelliJ I should enable? EDIT: Both project and module SDK and Language Level are set to the Java 10 installation and lvl. 10 (though not the X - experimental level). Apparently,

Why can't we assign two inferred variables as an anonymous class to each other? [duplicate]

≯℡__Kan透↙ 提交于 2019-12-06 06:01:23
This question already has answers here : Can a local variable with an inferred type be reassigned to a different type? (2 answers) Closed last year . Java 10 allows to do an anonymous class with a var like: var a1 = new Object(){}; var a2 = new Object(){}; But this assignment will throw an error: a1 = a2; jshell> a1 = a2; | Error: | incompatible types: $1 cannot be converted to $1 | a1 = a2; | ^^ Based on the error log, why can't Java 10 assign two inferred var s as an anonymous class to each other, but it can do the same for other types like Long , String , etc.? Each new Object(){} creates a

Can I provide runtime compiler access when running with JRE in Java 9+?

牧云@^-^@ 提交于 2019-12-06 03:34:29
问题 I'm migrating an application to Java 10. Our application normally runs with the JRE, but we allow users to compile bits of their own custom code by bundling tools.jar and using reflection to load a JavacTool instance on demand. Our method looks like: public static JavaCompiler getJavaCompiler() { String toolJarName = "tools.jar"; File file = getResourceForClass("tools.jar"); try { file = file.getCanonicalFile(); } catch (IOException ignore) { } if (!file.exists()) throw new RuntimeException(

Advantages/Drawbacks of “var” in Java 10 [closed]

杀马特。学长 韩版系。学妹 提交于 2019-12-05 22:31:05
AFAIK, var is not keyword in Java . It is reserved type name . I wonder that in what circumstances we should use/avoid it. Are there principles about its usage? import java.util.HashMap; public class Test { public static void main(String[] args) { var x = new HashMap<> (); // legal var y = new HashMap<String, Integer>(); // legal var z = "soner"; // legal System.out.println(z); var umm = null; // xx wrong xx // var foo; // xx wrong usage without initializer xx // var var = 5; // legal } } I know one reason, that we actually use in our project. Whenever there is a variable that is "big" we

a.disableProperty().bind(b.visibleProperty()) causes invalid element rendering in Java FX 10

。_饼干妹妹 提交于 2019-12-05 20:03:31
This is a regression in Java 10, refer to the bug report for further updates: JDK-8204949 Consider the following Java FX code, where b starts invisible: a.disableProperty().bind(b.visibleProperty()) If an application utilizing such code is run on Java 10 VM, then from the first time b becomes visible, a will always be rendered as if it was disabled. Of course, during the time while a is not really disabled (despite being rendered with a gray overlay), you can still interact with that element. E.g. you can edit text in input controls, click buttons/links and so on, the events get propagated