DialogBuilder
class implements the IDialogBuilder interface, so all there is a corresponding setter for all the methods allowing to configure the DialogBuilder
:DefaultMDIDialogBuilder
is done through one of the following methods:public class GenericDialogBuilder extends GenericDialog { public GenericDialogBuilder() { this.setDialogTitle("GenericDialogBuilder"); } @Override protected void createPanel() { DialogBuilder builder = new DialogBuilder(); JTextField widthField = new JTextField(10); JTextField heightField = new JTextField(10); JCheckBox cb = new JCheckBox("Set Size"); cb.setSelected(true); builder.addHorizontalDialogPart("size", "Dimensions", new JLabel("Width"), widthField, new JLabel("Height"), heightField); builder.addHorizontalDialogPart(cb); return builder.createDialogContent(); } }
DialogBuilder builder = new DialogBuilder(); JDialogBuilderDialog dialog = builder.createMessageDialog(null, "Dialog", IDialogBuilder.INFORMATION_MESSAGE, true, false, "Fist Line", "Second Line"); dialog.showDialog();with the following result:
DialogBuilder builder = new DialogBuilder("Set Size"); JTextField widthField = new JTextField(10); JTextField heightField = new JTextField(10); JCheckBox cb = new JCheckBox("Set Size"); cb.setSelected(true); builder.addHorizontalDialogPart("size", "Dimensions", new JLabel("Width"), widthField, new JLabel("Height"), heightField); builder.addHorizontalDialogPart(cb); JDialogBuilderDialog dialog = builder.createDialog(null); // enable disable the entire first vertical dialog part cb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.enableDialogPart("size", cb.isSelected()); } }); dialog.showDialog();with the following result:
BufferedImage image = ... DialogBuilder builder = new DialogBuilder("Analyze Image"); String type = getType(image); builder.addVerticalDialogPart("Size", new JLabel("Width: " + image.getWidth()), new JLabel("Height: " + image.getHeight())); builder.addVerticalDialogPart("Image Type", new JLabel(type)); JDialogBuilderDialog dialog = builder.createDialog(null); dialog.showDialog();with the following result:
Copyright 2006-2024 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences