-
-
Save uncoded-ro/f644d0ad51c1c12cf3b57072dd4ab988 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ro.virtualcampus.gui; | |
import java.awt.*; | |
import javax.swing.*; | |
import java.awt.event.*; | |
public class ComboBoxPanel extends JPanel implements ItemListener { | |
private static final long serialVersionUID = 1L; | |
private JComboBox list; | |
private JLabel text1, text2; | |
public ComboBoxPanel() { | |
setLayout(new GridLayout(3, 1)); | |
text1 = new JLabel("Selecteaza echipa favorita !"); | |
String[] listModel = { "Universitatea Craiova", "Poli Timisoara", "Steaua Bucuresti" }; | |
list = new JComboBox(listModel); | |
list.setSelectedIndex(1); | |
text2 = new JLabel(""); | |
add(text1); | |
add(list); | |
add(text2); | |
list.addItemListener(this); | |
} | |
public void itemStateChanged(ItemEvent e) { | |
Object choice = list.getSelectedItem(); | |
text2.setText(choice.toString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment