smita
smita

Reputation: 29

text in textfield

After selecting file using browse button into textfield and selecting checkbox that checkbox radio buttons and run should be enabled.How can i do this in swing using java code?

Upvotes: 1

Views: 188

Answers (2)

trashgod
trashgod

Reputation: 205775

JFileChooser, suggested by Justin Nelson, has an addActionListener() method. By implementing the ActionListener interface, your actionPerformed() method will be called to signal various user actions. You can enable buttons and set fields there. The tutorial How to Use File Choosers shows several examples.

Upvotes: 0

jjnguy
jjnguy

Reputation: 138864

Lets start with selecting a file in Swing:

JFileChooser chooser = new JFileChooser();
int choice = chooser.showSaveDialog(MainFrame.this);
if (choice != JFileChooser.APPROVE_OPTION)
    return;
File selectedFile = chooser.getSelectedFile();

That block of code will open a File dialog and wait for a user to select a file. Then the selected file will be stored into selectedFile.

You need to better clarify what you are asking for if you need more help.

Upvotes: 2

Related Questions