MDIDialog
interface allows to present a popup dialog. Inn that case you will need to handle the cration of the dialog windown by yourselfMDIDialogBuilder
interface allows the framework to handle the creation of the dialog window, delegating all the heavy lifting to the frameworkMDIDialog
instance must be a subclass of JComponent
.
MDIDialogBuilder
has only one mandatory method to implement:null
(the default), then if will be impossible to open any instance of the particular class implementing the MDIDialogBuilder
interfacenull
, then if will be impossible to open any instance of the particular class implementing the MDIDialogBuilder
interface with the same IDpublic class AnalyseImageMenuBuilder implements MDIDialogBuilder { private final BufferedImage image; public AnalyseImageMenuBuilder(BufferedImage image) { this.image = image; } @Override public short getDialogType() { return MDIDialogBuilder.OK_DIALOG; } @Override public String getDialogTitle() { return "Analyze Image"; } @Override public JComponent createDialogContent() { JPanel pane = new JPanel(); pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS)); pane.add(Box.createVerticalStrut(5)); pane.add(new JLabel("Width: " + image.getWidth())); pane.add(Box.createVerticalStrut(5)); pane.add(new JLabel("Height: " + image.getHeight())); return pane; } }To show this dialog, you just need to do, for example in an action:
public class AnalyzeImageAction extends AbstractMDIAction { public AnalyzeImageAction(MDIApplication appli, String name) { super(appli, name); this.setDescription("Analyze", "Analyze Image"); } @Override public void run() throws Exception { GUIApplication gui = ((GUIApplication) app); BufferedImage image = (BufferedImage) gui.getSelectedProperties().getObject(); AnalyseImageMenuBuilder builder = new AnalyseImageMenuBuilder(image); gui.showDialog(builder); } }with the following result:
Copyright 2006-2023 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences