public void run() throws Exception { JFileChooser chooser = new JFileChooser("Open Image"); chooser.setDialogTitle("Open Image"); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); if (chooser.showOpenDialog(app.getApplicationWindow()) == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); BufferedImage image = ImageIO.read(file); // the object associated with the tab if (image == null) throw new Exception("Bad File type"); _ JScrollPane pane = new JScrollPane(new ImagePanel(image)); // the content of the panel to show in the tab String tabName = file.getName(); // the name of the tab SwingFileProperties properties = new SwingFileProperties(tabName, comp, image); app.addTab(properties); } }You see that:
name
argument is the name of the file used for the tab nameimage
argument is the underlying object (which in this case is an Image)pane
argument is the component (in this case a ScrollPane) which will be put in the tabJComponent
.Copyright 2006-2023 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences