Home
Categories
Dictionary
Download
Project Details
Changes Log
Tutorials
FAQ
License

FileProperties



The FileProperties class allows to specify the component which will be put in a GUI application tab. This is a generic class which can be used in both JavaFX and Swing applications.

Overview

The FileProperties class allows to set:
  • The name of the tab
  • The associated component
  • The underlying object

It is also possible to add an optinoal URL to set the path of the file associated with the properties if necessary.

Example

For example, in the Basic tutorial, we add a tab for an Image:
      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:
  • The name argument is the name of the file used for the tab name
  • The image argument is the underlying object (which in this case is an Image)
  • The pane argument is the component (in this case a ScrollPane) which will be put in the tab

SwingFileProperties

The SwingFileProperties class is a Swing implement for which the component is a JComponent.

See also


Categories: gui | swing

Copyright 2006-2023 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences