I have to develop a GUI application similar to the one attached in the name "sample GUI". I don't know much abc of developing a GUI and I can't read any tutorials for the time being because I am really short of time.
It uses two classes I have, named DNA and Protein.
I have attached a file named "mine gui" which is the work I have done so far.
Now, I have got the following code for reference. But i don't know where to write that code.
1. First of all, the user clicks on the Browse button. The code against it should choose the path the user selects. What code does that?Code:[B]//Reference
//Change Value in ComboBox[/B]
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] {
"Item 1", "Item 2", "Item 3", "Item 4" }));
[B]//Change Selection Mode of RadioButton[/B]
jRadioButton1.setSelected(true);
jRadioButtonDNA.isSelected();
[B]//Get and Set Value from TextArea[/B]
jTextArea1.getText();
jTextArea1.setText(“Your text”);
[B]//Compare ComboBox Selected Text[/B]
if( jComboBox1.getSelectedItem().toString().equals("Name"))
{
//Code here
}
[B]//Set Text to Label[/B]
jLabel1.setText(“Your Text”);
[B]//JFileChoose Code[/B]
JFileChooser fc = new JFileChooser();
int returnVal = fc.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION)
System.out.println(fc.getSelectedFile() ); ///its give you file path which is selected
2. Then the code against the text field named TextFieldFilePath should paste the selested path in the text field. What code does that?
3. Then the user clicks on the Read button. This should invoke the method in the DNA class which reads text from the file. The file contains the name of the sequence and the sequence itself, separated by the tokenizer ">". But in the GUI, the name of the sequence has to be displayed in a text field and the sequence has to displayed in a text area, separately. How to achieve that?
The method which reads from the file has void return type. Even if I change it to string, what should it return- name of the sequence( which is to be displayed in the text field against the label saying "Sequence Name" ) or the sequence itself( to be displayed in the text area below the label saying "Sequence"). The method to read the file prints the name and the sequence separately, in console mode.
This is the code of the method:
4. Then there should be a code against the jTextFieldSequenceName which should display the name of the sequence. What code does that?Code:void readFromFile(String path){
String stringFromFile= new String();
try
{
FileReader fro = new FileReader( path );
BufferedReader bro = new BufferedReader( fro );
String strline= bro.readLine( );
stringFromFile= "";
while( strline!= null )
{ stringFromFile+= strline;
strline= bro.readLine( );
}
bro.close( );}
catch( FileNotFoundException filenotfoundexxption)
{
System.out.println( "FastaDNA.txt, does not exist" );
}
catch( IOException ioexception)
{
ioexception.printStackTrace( );
}
System.out.println("To test if the file, FastaDNA.text located in G drive, has been read:\nSEQUENCE NAME:" + stringFromFile.substring(0, stringFromFile.indexOf(">")));
System.out.println("SEQUENCE:"+ stringFromFile.substring(stringFromFile.indexOf(">")+1,stringFromFile.length()));
}
5.There should be a code against jTextAreaInput which should display the sequence in the text area.
6. Then the user selects one of the jRadioButtons. Shall I copy the reference code and paste it there?
7. Then the user selects from the jComboBox. Shall I copy the refernce code and paste it there?
The user's selection has to be bases on their selection from the two radio buttons. i.e. The options in the combobox have to be different for each of the two radiobuttons.
8. Then on the basis of user's selection from the jComboBox, relevant method has to be invoked from the class and then the output should be displayed in the jTextAreaOutput. How to do that?
9.What code against the jTextAreaOutput displays the output in it?

