Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

open dialog box for file chooice

hi,
I've to let the choice to user for a file !
So I've tried a simple JFrame with JfileChooser object in a routine call by tjavaflex ...
But I haven't got the time to choice anything 0683p000009MACn.png
The frame still open a very short time to disappear ...
problem of thread !??
I'm not enought java coder to find the reason why !!
here the code :

public class FileChooser extends JFrame implements ActionListener{
private JButton bouton = null;
private JPanel panel = null;
private String thePath = null;

public FileChooser(){
panel = new JPanel();
bouton = new JButton();

panel.setLayout(new FlowLayout());
bouton.addActionListener(this);
this.setVisible(true);
this.setSize(new Dimension(400,200));
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
Object source = e.getSource();
JFileChooser chooser = new JFileChooser();
File theFile = null;

if(source == bouton){
int returnVal = chooser.showOpenDialog(this);
if(returnVal == JFileChooser.APPROVE_OPTION){
theFile = chooser.getSelectedFile();
}
}

thePath = theFile.toURI().toString();
}

public String getPath(){
return thePath;
}
}


Hope it's not too long !
Why frame close just as it open !??
thanks for your help or suggestion

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Use component tJavaFlex.
Under Advanced settings enter: import javax.swing.JFileChooser;
Under Basic settings you can add code like:
JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog(null);

View solution in original post

4 Replies
Anonymous
Not applicable
Author

any idea so !?
I've tested by launching job like a script (.sh) ... but no more time to hope clicling on anything 0683p000009MACn.png
stay and wait for any suggestion (except do not 0683p000009MACn.png
++
Anonymous
Not applicable
Author

try with JOPtionPanel ( have a look on wich class is used on tMsgBox ) in a routines !
Can have a dialog box .... and still open
Just have to add a jfilechooser ...!!
more just play with Talend than work with it ! 0683p000009MACn.png
Anonymous
Not applicable
Author

Use component tJavaFlex.
Under Advanced settings enter: import javax.swing.JFileChooser;
Under Basic settings you can add code like:
JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog(null);
Anonymous
Not applicable
Author

hi
and thanks for your reply.
On the other hand there is a excellent and helpfully component on Talend Exchange.
Regards
laurent