本文概述
ColorInput产生类似于彩色Rectangle的输出。它不显示节点, 而是显示矩形框。它主要作为输入传递给其他效果。类javafx.scene.effect.ColorInput表示ColorInput效果。此类的对象作为其他效果的输入传递。
物产
下表中描述了类javafx.scene.effect.ColorInput的属性及其设置方法。
属性 | 描述 | 设置方法 |
---|---|---|
height | 它是双重类型的。它表示要填充的区域的高度。 | setHeight(double value) |
paint | 它表示要用该区域填充的油漆。 | setPaint(Paint value) |
width | 它是双重类型的。它表示要填充的区域的宽度。 | setWidth(double value) |
x | 它代表区域左上角的X坐标。 | setX(double value) |
y | 它表示该区域左上角的Y坐标。 | setY(double value) |
建设者
该类包含两个构造函数。
- public ColorInput():使用默认参数创建ColorInput的新实例。
- public ColorInput(double x, double y, double width, double height, Paint paint):使用指定的参数创建ColorInput的新实例。
例:
下面的示例说明ColorInput效果的工作。
package application;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.ColorInput;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
public class ColorInputExample extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
// TODO Auto-generated method stub
ColorInput color = new ColorInput();
color.setPaint(Color.RED);
color.setHeight(100);
color.setWidth(100);
color.setX(140);
color.setY(90);
Rectangle rect = new Rectangle();
rect.setEffect(color);
Group root = new Group();
Scene scene = new Scene(root, 400, 300);
root.getChildren().add(rect);
primaryStage.setScene(scene);
primaryStage.setTitle("ColorInput Example");
primaryStage.show();
}
}
评论前必须登录!
注册