Wameed
Wameed

Reputation: 3

Make dialogue box with header and label

How can I make a dialogue box with JOptionPane that looks like this with a header and description?

Upvotes: 0

Views: 92

Answers (1)

fabian
fabian

Reputation: 82461

I recommend using Alert for this purpose instead of JOptionPane:

Alert alert = new Alert(AlertType.INFORMATION);
alert.setHeaderText("Total: $3.45");

GridPane content = new GridPane();
content.setHgap(10);
content.setVgap(3);
content.addColumn(0, new Text("Order:"), new Text("Tax:"), new Text("Total:"));
content.addColumn(1, new Text("3.25"), new Text("0.20"), new Text("3.45"));

alert.getDialogPane().setContent(content);
alert.showAndWait();

Upvotes: 1

Related Questions