• Post Reply Bookmark Topic Watch Topic
  • New Topic

JFileChooser not as a dialog  RSS feed

 
gloria ran
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an application that uses one JFrame and interchanges JPanels depending on user feedback. There is one instance where I need to use a JFileChooser, but I do not want to use it as a dialog. (The program I am replacing did use it as a dialog, and we got complaints about it getting lost behind windows if you navigate away from the program and then back to the program.) So I really want to anchor this to the JFrame. I have it displayed, but I can't figure out how to communicate the results back. Here's what I have... (sorry it's a mess, some of it was auto-generated by netbeans).


package herbPureJava;

import javax.swing.*;
import java.io.*;

/**
*
*/
public class ConvertMesaPanel extends javax.swing.JPanel {
private JFrame parent;
private JFileChooser chooser;
public JLabel jLabel1;

/**
* Creates new form ConvertMesaPanel
*/
public ConvertMesaPanel(JFrame theParent) {
parent = theParent;
initComponents();
}

private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel1.setText("Browse to existing run file: (must be .xml)");

chooser = new JFileChooser();
chooser.addChoosableFileFilter(new XmlFileFilter());
chooser.setAcceptAllFileFilterUsed(false);

org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
.addContainerGap()
.add(chooser, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 512, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
.add(140, 140, 140)
.add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 350, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(64, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
.add(32, 32, 32)
.add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 14, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(40, 40, 40)
.add(chooser, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 310, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(33, Short.MAX_VALUE))
);


}

}
 
gloria ran
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course, it's not until after hours of googling and finally posting that I run accross a useful example... Thanks to all who may have started researching this.

http://java.sun.com/developer/TechTips/1999/tt0615.html
 
John Wetherbie
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for sharing what you found.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!