Hi and thanks for viewing my thread,
i have a problem with JComboBox.
in my situation, i have a code that display JTextArea and JComboBox.
this is my code:
public class JScrollPanes extends JApplet
{
//--------------------------------------------------
static String[] t_value2 = { "2", "3", "4", "5", "6" };
// -----------------------------------------------
private JButton generate_btn = new JButton("GO ");
private Label label = new Label ("Enter Parameter Values");
private Label labelt = new Label ("Choose t Value");
private JTextArea
t1 = new JTextArea("", 1, 20),
t3 = new JTextArea("", 6, 20),
t4 = new JTextArea("",13, 20);
private JComboBox t2 = new JComboBox(t_value2);
class B4L implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
t3.setText("");
t4.setText("");
// get input from JTextArea
String data_str=t1.getText();
// get input from JComboBox...how??
// count parameter
int p = data_str.replaceAll("[^,]","").length();
p++; // as an array size
data = new int [p];
int k =0;
t3.append("Pairwise Test Set\n");
t3.append("Parameters ="+Integer.toString(p)+"\n");
}
}
public void init()
{
//setting and initializing....
}
public static void main(String[] args)
{
run(new JScrollPanes(), 300, 500);
}
public static void run(JApplet applet, int width, int height)
{
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(applet);
frame.setSize(width, height);
applet.init();
applet.start();
frame.setVisible(true);
}
}
i hope u guys understand my code....i cut the rest and juz show my problem...as u can see my combobox as t2...
my questions:
1) How to get index from dropdown menu. like JtextArea we use getText==> String data_str=t1.getText();
How we do in JComboBox. i want to get the data because i want to convert string to integer.
2) How to display the menu that user selected in t3(textarea 3)