Hello, I have several Objects in switch I need to set the text that should be in a string, ill show an example of how i have done it. It´s all made in a JPanel using NetBeans.
private void comboBoxMajorChoosingActionPerformed(java.awt.event.ActionEvent evt) {
comboBoxMinorChoosing1.addItem("English");
comboBoxMinorChoosing1String = comboBoxMinorChoosing1.getSelectedItem().toString();
}
private void comboBoxMinorChoosing1ActionPerformed(java.awt.event.ActionEvent evt) {
if (blabla = true) {
comboBoxMinorChoosing1.addItem("Math");
comboBoxMinorChoosing1String = comboBoxMinorChoosing1.getSelectedItem().toString();
}}
public String comboBoxMinorChoosing1String {
return comboBoxMinorChoosing1String;
}
String comboBoxMinorChoosing1String = "";
It all works as long as I´m not trying to define the text twice, i know it isnt needed in the example I have given but in my actual application I do need to do this, so anyone have any advices?
it is about how to get a String to be defined twice so to say. Let me try to explain in the program you first choose one thing through a combobox (called the MajorChoosing) which then builds up a combobox (called MinorChoosing) and inserts things into this combobox. After that it makes a String so I can compare the SelectedItem later on. This is all defined in the first part(note it is not the actual coding im displaying since it would make it more confusing):
private void comboBoxMajorChoosingActionPerformed(java.awt.event.ActionEvent evt) {
comboBoxMinorChoosing1.addItem("English");
comboBoxMinorChoosing1String = comboBoxMinorChoosing1.getSelectedItem().toString();
then whenever the MinorChoosing combobox is clicked on or changed I want it to replace the old String with the new SelectedItem so I can compare them that way. Hope you understand it now.
Thanks in advance