package javafx_image;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Stage;
/**
*
* @web http://mobile-web-app.blogspot.com/
*/
public class JavaFX_image extends Application {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("java-buddy.blogspot.com: Load image");
Group root = new Group();
double width = 400;
double height = 300;
Scene scene = new Scene(root, width, height, Color.WHITE);
Image image = new Image(getClass().getResourceAsStream("duke_44x80.png"));
ImageView imageView = new ImageView();
imageView.setImage(image);
//Inner border
HBox hBox_inner = new HBox();
String style_inner = "-fx-border-color: red;"
+ "-fx-border-width: 1;"
+ "-fx-border-style: dotted;";
hBox_inner.setStyle(style_inner);
//Outter border
HBox hBox_outter = new HBox();
String style_outter = "-fx-border-color: black;"
+ "-fx-border-width: 10;";
hBox_outter.setStyle(style_outter);
hBox_inner.getChildren().add(imageView);
hBox_outter.getChildren().add(hBox_inner);
root.getChildren().add(hBox_outter);
primaryStage.setScene(scene);
primaryStage.show();
}
}
Saturday, February 11, 2012
JavaFX 2.0: Apply border on ImageView, using HBox with css style
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment