Fwd: Re: java.lang.NullPointerException at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:1129)
Pavel Safrata
pavel.safrata at oracle.com
Tue Jul 23 05:51:13 PDT 2013
Forwarding to the list..
Pavel
-------- Original Message --------
Subject: Re: java.lang.NullPointerException at
com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:1129)
Date: Tue, 23 Jul 2013 15:48:20 +0300
From: Peter Penzov <peter.penzov at gmail.com>
To: Pavel Safrata <pavel.safrata at oracle.com>
With the help of Pavel Safrata I found the problem. I have this css file
which sets the style and the images of the toggle buttons:
#pill-left {
-fx-padding: 5;
-fx-border-image-source: url("/com/dx57dc/images/left-btn.png");
-fx-border-image-slice: 4 4 4 4 fill;
-fx-border-image-width: 4 4 4 4;
-fx-border-image-insets: 0;
-fx-border-image-repeat: stretch;
-fx-background-color: null !important;
}
#pill-left:selected { -fx-border-image-source:
url("/com/dx57dc/images/left-btn-selected.png"); }
#pill-left .label {
-fx-text-fill: #d3d3d3;
-fx-effect: dropshadow( one-pass-box , rgba(0,0,0,0.75) , 0, 0.0 ,
0 , -1 );
}
#pill-left:selected .label {
/* -fx-text-fill: black; */
-fx-text-fill: white;
-fx-effect: dropshadow( one-pass-box , white , 0, 0.0 , 0 , 1 );
}
#pill-center {
-fx-padding: 5;
-fx-border-image-source: url("/com/dx57dc/images/center-btn.png");
-fx-border-image-slice: 4 4 4 4 fill;
-fx-border-image-width: 4 4 4 4;
-fx-border-image-insets: 0;
-fx-border-image-repeat: stretch;
-fx-background-color: null !important;
}
#pill-center:selected { -fx-border-image-source:
url("/com/dx57dc/images/center-btn-selected.png"); }
#pill-center .label {
-fx-text-fill: #d3d3d3;
-fx-effect: dropshadow( one-pass-box , rgba(0,0,0,0.75) , 0, 0.0 ,
0 , -1 );
}
#pill-center:selected .label {
-fx-text-fill: black;
-fx-effect: dropshadow( one-pass-box , white , 0, 0.0 , 0 , 1 );
}
#pill-right {
-fx-padding: 5;
-fx-border-image-source: url("/com/dx57dc/images/right-btn.png");
-fx-border-image-slice: 4 4 4 4 fill;
-fx-border-image-width: 4 4 4 4;
-fx-border-image-insets: 0;
-fx-border-image-repeat: stretch;
-fx-background-color: null !important;
}
#pill-right:selected { -fx-border-image-source:
url("/com/dx57dc/images/right-btn-selected.png"); }
#pill-right .label {
-fx-text-fill: #d3d3d3;
-fx-effect: dropshadow( one-pass-box , rgba(0,0,0,0.75) , 0, 0.0 ,
0 , -1 );
}
#pill-right:selected .label {
-fx-text-fill: black;
-fx-effect: dropshadow( one-pass-box , white , 0, 0.0 , 0 , 1 );
}
The images are placed at the Java package: com.dx57dc.images
What is the proper way to load images from css in Java 8?
On Tue, Jul 23, 2013 at 1:51 PM, Pavel Safrata <pavel.safrata at oracle.com
<mailto:pavel.safrata at oracle.com>> wrote:
Hi Peter,
it's enough to report on one place, let's discuss the issue in the
bug. I'll put there a comment soon.
Pavel
On 23.7.2013 12:37, Peter Penzov wrote:
Hi,
I'm working on JavaFX example which uses Toggle button:
private void initMainStage(final Stage mainStage)
{
// Set Main Window Label
// Set Icon of the main stage
Image img = new
Image(getClass().getResource("/com/dx57dc/images/internet-icon.png").toExternalForm());
mainStage.getIcons().add(img);
// Main Stage
root = new BorderPane();
final VBox vbox = new VBox();
// Set Style
String pillButtonCss =
DX57DC.class.getResource("/com/dx57dc/css/PillButton.css").toExternalForm();
// Create 3 toggle buttons and a toogle group for them
ToggleButton tb1 = new ToggleButton("Infrastructure");
tb1.setId("pill-left");
ToggleButton tb2 = new ToggleButton("Agents");
tb2.setId("pill-center");
ToggleButton tb3 = new ToggleButton("Live Performance");
tb3.setId("pill-right");
final ToggleGroup group = new ToggleGroup();
tb1.setToggleGroup(group);
tb2.setToggleGroup(group);
tb3.setToggleGroup(group);
// Select the first button by default
group.selectToggle(tb1);
// Some test data
final Rectangle rect2 = new Rectangle(300, 300);
rect2.setFill(Color.SILVER);
final Rectangle rect3 = new Rectangle(300, 300);
rect3.setFill(Color.DODGERBLUE);
tb1.setUserData(root);
tb2.setUserData(rect2);
tb3.setUserData(rect3);
final HBox hBox = new HBox();
// Listener which changes toggle buttons content
group.selectedToggleProperty().addListener(new
ChangeListener<Toggle>()
{
@Override
public void changed(ObservableValue<? extends
Toggle> ov,
Toggle toggle, Toggle new_toggle)
{
if (new_toggle == null)
{
}
else
{
vbox.getChildren().set(2, (Node)
group.getSelectedToggle().getUserData());
}
}
});
hBox.getChildren().addAll(tb1, tb2, tb3);
hBox.setPadding(new Insets(5, 5, 5, 5)); // Padding
between the
main menu and the content
hBox.getStylesheets().add(pillButtonCss); // Add the
css style
// Content of the main stage
leftHBox = getLeftHBox(mainStage, root);
rightHBox = getRightHBox(mainStage);
footerVBox = getFooter(mainStage);
centerPane = getCenterPane(mainStage);
// default resizer with drag insets(5,5,5,5);
//RegionResizerFX.register(leftHBox, rightHBox,
footerVBox,
centerPane);
root.setRight(rightHBox);
root.setBottom(footerVBox);
root.setLeft(leftHBox);
root.setCenter(centerPane);
RegionResizerFX.register(centerPane);
// Vbox which holds main menu, toggle buttons and main
content
vbox.getChildren().addAll(getMenu(mainStage, root),
hBox, (Node)
group.getSelectedToggle().getUserData());
// Set main stage size and color
Scene scene = new Scene(vbox, 1200, 650,
Color.WHITESMOKE); // Set
main Stage color
// Application Close Confirmation Dialog
dialog = new DialogPanels();
dialog.initClosemainAppDialog(mainStage);
// Application Hot Keys Utilization
hotkey = new HotKey();
hotkey.initApplicationHotKeys(mainStage, scene);
mainStage.setScene(scene);
Rectangle2D primaryScreenBounds =
Screen.getPrimary().getVisualBounds();
// Set Stage boundaries to visible bounds of the main
screen
mainStage.setX(primaryScreenBounds.getMinX());
mainStage.setY(primaryScreenBounds.getMinY());
mainStage.setWidth(primaryScreenBounds.getWidth()); //
Maximum
width of the display
mainStage.setHeight(primaryScreenBounds.getHeight());
// Maximum
height of the display
//mainStage.show();
}
I tried to run the code on JVM 8b99 but I get error which I
described here:
https://javafx-jira.kenai.com/browse/RT-31859
Is this JVM bug or I have a bug into my code?
More information about the openjfx-dev
mailing list