¿Cómo puedo arreglar este código en JAVA Eclipse?

Tengo este código de Interfaz:

package Interfaz;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.security.auth.callback.LanguageCallback;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JTextField;

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;

import com.APIClient;
import com.APIException;

import java.lang.String;
import java.util.HashMap;
import java.util.Map;

public class ComboBoxDemo extends JFrame {

/**
* Serializable
*/
private static final long serialVersionUID = 1L;
/**
*/

// * JComboBox seleccion *//
public static String Languages = "["+
" { \"suite_mode\": 3, \"completed_on\": null, \"name\": \"DCL\", \"id\": 1, \"show_announcement\": true, \"is_completed\": false, \"url\": \"http://wiidpro-testos.cloud.go.com/testos/index.php?/projects/overview/1\", \"announcement\": \"android)\"}," +
" { \"suite_mode\": 3, \"completed_on\": null, \"name\": \"MDX\", \"id\": 2, \"show_announcement\": false, \"is_completed\": false, \"url\": \"http://wiidpro-testos.cloud.go.com/testos/index.php?/projects/overview/2\", \"announcement\": null }," +
" { \"suite_mode\": 3, \"completed_on\": null, \"name\": \"SDP\", \"id\": 3, \"show_announcement\": false, \"is_completed\": false, \"url\": \"http://wiidpro-testos.cloud.go.com/testos/index.php?/projects/overview/3\", \"announcement\": \"App\" }," +
" { \"suite_mode\": 3, \"completed_on\": null, \"name\": \"DLR\", \"id\": 4, \"show_announcement\": false, \"is_completed\": false, \"url\": \"http://wiidpro-testos.cloud.go.com/testos/index.php?/projects/overview/4\", \"announcement\": null }," +
" { \"suite_mode\": 3, \"completed_on\": null, \"name\": \"DLP\", \"id\": 5, \"show_announcement\": false, \"is_completed\": false, \"url\": \"http://wiidpro-testos.cloude.go.com/testos/index.php?/projects/overview/5\", \"announcement\": null }]";

public JTextField heading = new JTextField("Top TestRails - ");
public JTextField selectedLanguageField1 = new JTextField(15);
public JTextField selectedLanguageField2 = new JTextField(15);

public JComboBox boxOfLanguages = new JComboBox();
public JComboBox boxOfLanguages2 = new JComboBox();

{
// * Contador For de Languages1 y boxOfLanguages*/
for (int i = 0; i < 6; i++) {
boxOfLanguages.addItem(Languages +i);

}

heading.setEditable(false);
selectedLanguageField1.setEditable(false);
boxOfLanguages.addActionListener(new ActionListener() {

// * Accion del Combo Seleccion *//
@Override
public void actionPerformed(ActionEvent event) {
selectedLanguageField1.setText(((JComboBox) event.getSource())
.getSelectedItem().toString());
selectedLanguageField2.setText(((JComboBox) event.getSource())
.getSelectedItem().toString());
// * Lista de la selecion, O lo que traera y mostrara en el
// momento de hacer Click *//
int indiceBuscado = boxOfLanguages.getSelectedIndex();

if (indiceBuscado == 1) {
selectedLanguageField1.setText(" id : 1.");
selectedLanguageField2.setText("DCL.");
Languages.length();
} else if (indiceBuscado == 2) {
selectedLanguageField1.setText(" id : 2.");
selectedLanguageField2.setText("MDX.");
Languages.length();
} else if (indiceBuscado == 3) {
selectedLanguageField1.setText(" id : 3.");
selectedLanguageField2.setText("SDP.");
Languages.length();
} else if (indiceBuscado == 4) {
selectedLanguageField1.setText(" id : 4.");
selectedLanguageField2.setText("DLR.");
Languages.length();
} else if (indiceBuscado == 5) {
selectedLanguageField1.setText(" id : 5.");
selectedLanguageField2.setText("DLP.");
Languages.length();
}

}
});

// * TextField Donde Se vera el Resultado *//
this.setLayout(new FlowLayout());
this.setLocation(900, 400);
this.add(heading);
this.add(selectedLanguageField1);
this.add(boxOfLanguages);
selectedLanguageField1.setEditable(false);

// * TextField Donde Se vera el Resultado2 *//
this.setLayout(new FlowLayout());
this.add(selectedLanguageField2);
this.add(boxOfLanguages);
selectedLanguageField2.setEditable(false);

}

// * Titulo de la Ventana. *//
public static void main(String[] args) {
JFrame frame = new ComboBoxDemo();
frame.setTitle("TestRail QA");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(380, 330);
frame.setVisible(true);

//* Muestra El Resultado de los valores del Array por medio de la Consola *//
Object obj = JSONValue.parse(Languages);
JSONArray lista = (JSONArray)obj;
System.out.println(obj.toString());
for (int i = 0; i < lista.size(); i++) {
JSONObject list = (JSONObject) lista.get(i);
//* Muestra unicamente un objeto del Array ( name ) y ( id ) *//
System.out.println(list.get("name").toString());
System.out.println(list.get("id").toString());
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//Y quiero que en esta parte me la muestre no por consola sino en un combobox, //¿como puedo cambiar eso?

//Osea cambiar este: System.out.println(list.get("name").toString());
//Que es el resultado por consola, cambiarlo para que se visualize en el //ComboBox
}
}

0

Añade tu respuesta

Haz clic para o