gt:       int returnVal = m_FileChooser.showOpenDialog(this);
context: /*
   *   This program is free software: you can redistribute it and/or modify
   *   it under the terms of the GNU General Public License as published by
   *   the Free Software Foundation, either version 3 of the License, or
   *   (at your option) any later version.
   *
   *   This program is distributed in the hope that it will be useful,
   *   but WITHOUT ANY WARRANTY; without even the implied warranty of
   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   *   GNU General Public License for more details.
   *
   *   You should have received a copy of the GNU General Public License
   *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
   */
  
  /*
   *    SetInstancesPanel.java
   *    Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand
   *
   */
  
  package weka.gui;
  
  import java.awt.BorderLayout;
  import java.awt.FlowLayout;
  import java.awt.GridLayout;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.beans.PropertyChangeListener;
  import java.beans.PropertyChangeSupport;
  import java.io.File;
  import java.net.URL;
  
  import javax.swing.BorderFactory;
  import javax.swing.DefaultComboBoxModel;
  import javax.swing.JButton;
  import javax.swing.JComboBox;
  import javax.swing.JFileChooser;
  import javax.swing.JFrame;
  import javax.swing.JLabel;
  import javax.swing.JOptionPane;
  import javax.swing.JPanel;
  
  import weka.core.Attribute;
  import weka.core.Instances;
  import weka.core.converters.ConverterUtils;
  import weka.core.converters.FileSourcedConverter;
  import weka.core.converters.IncrementalConverter;
  import weka.core.converters.URLSourcedLoader;
  
  /** 
   * A panel that displays an instance summary for a set of instances and
   * lets the user open a set of instances from either a file or URL.
   *
   * Instances may be obtained either in a batch or incremental fashion.
   * If incremental reading is used, then
   * the client should obtain the Loader object (by calling
   * getLoader()) and read the instances one at a time. If
   * batch loading is used, then SetInstancesPanel will load
   * the data into memory inside of a separate thread and notify
   * the client when the operation is complete. The client can
   * then retrieve the instances by calling getInstances().
   *
   * @author Len Trigg (trigg@cs.waikato.ac.nz)
   * @version $Revision: 8034 $
   */
  public class SetInstancesPanel
    extends JPanel {
  
    /** for serialization. */
    private static final long serialVersionUID = -384804041420453735L;
  
    /** the text denoting "no class" in the class combobox. */
    public final static String NO_CLASS = "No class";
    
    /** Click to open instances from a file. */
    protected JButton m_OpenFileBut = new JButton("Open file...");
  
    /** Click to open instances from a URL. */
    protected JButton m_OpenURLBut = new JButton("Open URL...");
  
    /** Click to close the dialog. */
    protected JButton m_CloseBut = new JButton("Close");
  
    /** The instance summary component. */
    protected InstancesSummaryPanel m_Summary = new InstancesSummaryPanel();
  
    /** the label for the class combobox. */
    protected JLabel m_ClassLabel = new JLabel("Class");
    
    /** the class combobox. */
    protected JComboBox m_ClassComboBox = new JComboBox(new DefaultComboBoxModel(new String[]{NO_CLASS}));
    
    /** The file chooser for selecting arff files. */
    protected ConverterFileChooser m_FileChooser
      = new ConverterFileChooser(new File(System.getProperty("user.dir")));
  
    /** Stores the last URL that instances were loaded from. */
    protected String m_LastURL = "http://";
  
    /** The thread we do loading in. */
    protected Thread m_IOThread;
  
    /**
     * Manages sending notifications to people when we change the set of
     * working instances.
     */
    protected PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
  
    /** The current set of instances loaded. */
    protected Instances m_Instances;
  
    /** The current loader used to obtain the current instances. */
    protected weka.core.converters.Loader m_Loader;
    
    /** the parent frame. if one is provided, the close-button is displayed */
    protected JFrame m_ParentFrame = null;
  
    /** the panel the Close-Button is located in. */
    protected JPanel m_CloseButPanel = null;
  
    /** whether to read the instances incrementally, if possible. */
    protected boolean m_readIncrementally = true;
    
    /** whether to display zero instances as unknown ("?"). */
    protected boolean m_showZeroInstancesAsUnknown = false;
    
    /** whether to display a combobox that allows the user to choose the class
     * attribute. */
    protected boolean m_showClassComboBox;
    
    /**
     * Default constructor.
     */
    public SetInstancesPanel() {
      this(false, false);
    }
    
    /**
     * Create the panel.
     * 
     * @param showZeroInstancesAsUnknown	whether to display zero instances
     * 					as unknown (e.g., when reading data
     * 					incrementally)
     * @param showClassComboBox		whether to display a combobox
     * 					allowing the user to choose the class
     * 					attribute
     */
    public SetInstancesPanel(boolean showZeroInstancesAsUnknown, boolean showClassComboBox) {
      m_showZeroInstancesAsUnknown = showZeroInstancesAsUnknown;
      m_showClassComboBox = showClassComboBox;
      
      m_OpenFileBut.setToolTipText("Open a set of instances from a file");
      m_OpenURLBut.setToolTipText("Open a set of instances from a URL");
      m_CloseBut.setToolTipText("Closes the dialog");
      m_FileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
      m_OpenURLBut.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
  	setInstancesFromURLQ();
        }
      });
      m_OpenFileBut.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
  	setInstancesFromFileQ();
        }
      });
      m_CloseBut.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          closeFrame();
        }
      });
      m_Summary.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
  
      m_ClassComboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
  	if ((m_Instances != null) && (m_ClassComboBox.getSelectedIndex() != -1)) {
  	  if (m_Instances.numAttributes() >= m_ClassComboBox.getSelectedIndex()) {
  	    m_Instances.setClassIndex(m_ClassComboBox.getSelectedIndex() - 1);   // -1 because of NO_CLASS element
  	    m_Support.firePropertyChange("", null, null);
  	  }
  	}
        }
      });
      
      JPanel panelButtons = new JPanel(new FlowLayout(FlowLayout.LEFT));
      panelButtons.add(m_OpenFileBut);
      panelButtons.add(m_OpenURLBut);
  
      JPanel panelClass = new JPanel(new FlowLayout(FlowLayout.LEFT));
      panelClass.add(m_ClassLabel);
      panelClass.add(m_ClassComboBox);
  
      JPanel panelButtonsAndClass;
      if (m_showClassComboBox) {
        panelButtonsAndClass = new JPanel(new GridLayout(2, 1));
        panelButtonsAndClass.add(panelButtons);
        panelButtonsAndClass.add(panelClass);
      }
      else {
        panelButtonsAndClass = new JPanel(new GridLayout(1, 1));
        panelButtonsAndClass.add(panelButtons);
      }
      
      m_CloseButPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
      m_CloseButPanel.add(m_CloseBut);
      m_CloseButPanel.setVisible(false);
      
      JPanel panelButtonsAll = new JPanel(new BorderLayout());
      panelButtonsAll.add(panelButtonsAndClass, BorderLayout.CENTER);
      panelButtonsAll.add(m_CloseButPanel, BorderLayout.SOUTH);
      
      setLayout(new BorderLayout());
      add(m_Summary, BorderLayout.CENTER);
      add(panelButtonsAll, BorderLayout.SOUTH);
    }
  
    /**
     * Sets the frame, this panel resides in. Used for displaying the close 
     * button, i.e., the close-button is visible if the given frame is not null.
     * @param parent        the parent frame
     */
    public void setParentFrame(JFrame parent) {
      m_ParentFrame = parent;
      m_CloseButPanel.setVisible(m_ParentFrame != null);
    }
    
    /**
     * Returns the current frame the panel knows of, that it resides in. Can be
     * null.
     * @return the current parent frame
     */
    public JFrame getParentFrame() {
      return m_ParentFrame;
    }
  
    /**
     * closes the frame, i.e., the visibility is set to false.
     */
    public void closeFrame() {
      if (m_ParentFrame != null)
        m_ParentFrame.setVisible(false);
    }
  
    /**
     * Queries the user for a file to load instances from, then loads the
     * instances in a background process. This is done in the IO
     * thread, and an error message is popped up if the IO thread is busy.
     */
    public void setInstancesFromFileQ() {
      
      if (m_IOThread == null) {
  