H
Hiram Hunt
Hello,
I have some code that gets compile time errors in
some places but not others. I don't understand why
one situation is apparently legal and the other is not.
Here is the copy-and-paste of a minimal example:
/*
* Program: Minimal
* A minimal case of some code that is causing
* compile time errors. Compile with Java 7u3 and
* use JavaFX 2.0 library (jfxrt.jar) on 64 bit
* Windows 7.
*/
import javafx.geometry.Orientation;
import javafx.scene.control.Slider;
import javafx.scene.control.SliderBuilder;
class Minimal {
// No compile error on okslider1.
Slider okslider1 = SliderBuilder
.create()
.prefWidth(100.0)
.orientation(Orientation.HORIZONTAL)
.build();
// Swap width and orientation calls; still no compile error.
Slider okslider2 = SliderBuilder
.create()
.orientation(Orientation.HORIZONTAL)
.prefWidth(100.0)
.build();
// Create a SliderBuilder with the setting of several
// properties omitted for the sake of a minimal example.
SliderBuilder sliderbuilder = SliderBuilder
.create();
// Use the SliderBuilder I just made to make a Slider.
// Compile error for badslider1: cannot find method
// .orientation(Orientation) in class ControlBuilder.
Slider badslider1 = sliderbuilder
.prefWidth(100.0)
.orientation(Orientation.HORIZONTAL)
.build();
// Swap width and orientation calls.
// Compile error for badslider2: cannot find method
// .build() in class ControlBuilder. Thus, comparing
// with badslider1 case, the problem seems to be with
// using the result of .prefWidth(), but why doesn't
// the same problem appear when I make okslider1
// and okslider2?
Slider badslider2 = sliderbuilder
.orientation(Orientation.HORIZONTAL)
.prefWidth(100.0)
.build();
}
(End copy-and-paste.)
Can anyone explain this behavior? In particular, I don't just
want to know why the errors occur, but why they don't also occur
in the cases of okslider1 and okslider2. Thanks.
-- Hiram Hunt
I have some code that gets compile time errors in
some places but not others. I don't understand why
one situation is apparently legal and the other is not.
Here is the copy-and-paste of a minimal example:
/*
* Program: Minimal
* A minimal case of some code that is causing
* compile time errors. Compile with Java 7u3 and
* use JavaFX 2.0 library (jfxrt.jar) on 64 bit
* Windows 7.
*/
import javafx.geometry.Orientation;
import javafx.scene.control.Slider;
import javafx.scene.control.SliderBuilder;
class Minimal {
// No compile error on okslider1.
Slider okslider1 = SliderBuilder
.create()
.prefWidth(100.0)
.orientation(Orientation.HORIZONTAL)
.build();
// Swap width and orientation calls; still no compile error.
Slider okslider2 = SliderBuilder
.create()
.orientation(Orientation.HORIZONTAL)
.prefWidth(100.0)
.build();
// Create a SliderBuilder with the setting of several
// properties omitted for the sake of a minimal example.
SliderBuilder sliderbuilder = SliderBuilder
.create();
// Use the SliderBuilder I just made to make a Slider.
// Compile error for badslider1: cannot find method
// .orientation(Orientation) in class ControlBuilder.
Slider badslider1 = sliderbuilder
.prefWidth(100.0)
.orientation(Orientation.HORIZONTAL)
.build();
// Swap width and orientation calls.
// Compile error for badslider2: cannot find method
// .build() in class ControlBuilder. Thus, comparing
// with badslider1 case, the problem seems to be with
// using the result of .prefWidth(), but why doesn't
// the same problem appear when I make okslider1
// and okslider2?
Slider badslider2 = sliderbuilder
.orientation(Orientation.HORIZONTAL)
.prefWidth(100.0)
.build();
}
(End copy-and-paste.)
Can anyone explain this behavior? In particular, I don't just
want to know why the errors occur, but why they don't also occur
in the cases of okslider1 and okslider2. Thanks.
-- Hiram Hunt