I do not want to have my box this wide. I would like the text to wrap but I do not know how. Can I do this? I'd like my box to be 400,400 rather than 1250,200, but it is the only way I can get my text to fit. Or could I make a new box under the pull down menu that had this description in it. I do not know how to do it. - frame.add(panel3, BorderLayout.SOUTH); ???
public class ComboBox{
String course[] = {"Menu","CIS212","CIS222","CIS406","CIS407","CIS326","CIS328","CIS493"};
String desc[] = {"Please choose a class from the menu",
"System Modeling Theory: " +
"Class covers the principles and theory of discrete event system modeling and simulation.",
"Computer Ethics: " +
"This course focuses on ethical and legal issues, civil rights, and privacy considerations that organizations must take into account.",
"Java Programming I:" +
"Introduces the student to Internet Programming in the language of Java. " ,
"Java Programming II: " +
"Class covers advanced features of programming in the if Java.",
"Object Oriented Programming I:" +
" Class covers the traditional C language and object-oriented extensions that are found in the C++ language. ",
"Object Oriented Programming II: " +
"Develops a working knowledge of object-oriented concepts in areas of classes, inheritance, data structures, error handling, templates and file processing.",
"Creating Web Databasese: " +
"Class covers the concepts of Web database systems, their design, performance, scalability and reliability."};
JComboBox combo;
JLabel txt;
public static void main(String[] args) {
ComboBox b = new ComboBox();
}
public ComboBox(){
JFrame frame = new JFrame("Information System Class Description");
JPanel panel = new JPanel();
JPanel panel2 = new JPanel();
combo = new JComboBox(course);
combo.setBackground(Color.white);
combo.setForeground(Color.blue);
txt = new JLabel("Please choose a class from the menu.");
panel.add(txt);
frame.add(panel, BorderLayout.NORTH);
panel2.add(combo);
frame.add(panel2, BorderLayout.CENTER);
combo.addItemListener(new ItemListener(){
public void itemStateChanged(ItemEvent ie){
String str = (String)combo.getSelectedItem();
int index = combo.getSelectedIndex();
txt.setText(desc[index]);
}
});
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(1250,200);
frame.setVisible(true);
}