- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create a ColorPicker using JavaFX?
A color picker gives you a standard color palette fro which you can select a required color. You can create a color picker by instantiating the javafx.scene.control.ColorPicker class.
Example
The following Example demonstrates the creation of a ColorPicker.
import javafx.application.Application; import javafx.geometry.Insets; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.ColorPicker; import javafx.scene.control.Label; import javafx.scene.layout.HBox; import javafx.scene.paint.Color; import javafx.scene.text.Font; import javafx.scene.text.FontPosture; import javafx.scene.text.FontWeight; import javafx.stage.Stage; public class ColorPickerExample extends Application { public void start(Stage stage) { //Setting the label Label label = new Label("Select Desired Color:"); Font font = Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 12); label.setFont(font); //Creating a Color picker ColorPicker picker = new ColorPicker(); //Creating a hbox to hold the pagination HBox hbox = new HBox(); hbox.setSpacing(20); hbox.setPadding(new Insets(25, 50, 50, 60)); hbox.getChildren().addAll(label, picker); //Setting the stage Group root = new Group(hbox); Scene scene = new Scene(root, 595, 300, Color.BEIGE); stage.setTitle("Color Picker"); stage.setScene(scene); stage.show(); } public static void main(String args[]){ launch(args); } }
Output
- Related Articles
- How to create a circle using JavaFX?
- How to create a Rectangle using JavaFX?
- How to create a Line using JavaFX?
- How to create a Polygon using JavaFX?
- How to create a Polyline using JavaFX?
- How to create a CubicCurve using JavaFX?
- How to create a QuadCurve using JavaFX?
- How to create a label using JavaFX?
- How to create a separator using JavaFX?
- How to create a Menu using JavaFX?
- How to create a ScrollBar using JavaFX?
- How to create a ListView using JavaFX?
- How to create a TreeView using JavaFX?
- How to create a pagination using JavaFX?
- How to create a ComboBox using JavaFX?

Advertisements