Hi
i m trying to get selected from jradiobutton..i m using eclipse and windowbuilder for java
please check my code
JRadioButton btn1 = new JRadioButton("By Trading Name",true);
btn1.setBounds(22, 48, 149, 23);
contentPane.add(btn1);
JRadioButton btn2 = new JRadioButton("By Overshop",false);
btn2.setBounds(22, 75, 149, 23);
contentPane.add(btn2);
JRadioButton btn3 = new JRadioButton("By Address",false);
btn3.setBounds(22, 102, 149, 23);
contentPane.add(btn3);
JRadioButton btn4 = new JRadioButton("By Contact",false);
btn4.setBounds(22, 129, 149, 23);
contentPane.add(btn4);
ButtonGroup bg = new ButtonGroup();
bg.add(btn1);
bg.add(btn2);
bg.add(btn3);
bg.add(btn4);
}
////next record//////
private void btnSuivantActionPerformed(ActionEvent evt) {
count++;
try{
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost/cabinet","root","root");
Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
if(btn1).isSelected()){
String selectStuff =("Select * From customer WHERE tradingname = '"+search.getText()+"'");
ResultSet rows = st.executeQuery(selectStuff);
}
else if(btn2.isSelected()){
String selectStuff =("Select * From customer WHERE overshop = '"+search.getText()+"' ");
ResultSet rows = st.executeQuery(selectStuff);
}
else if(btn3.isSelected()){
String selectStuff =("Select * From customer WHERE address = '"+search.getText()+"' ");
ResultSet rows = st.executeQuery(selectStuff);
}
else if(btn4.isSelected()){
String selectStuff =("Select * From customer WHERE contact1 = '"+search.getText()+"' OR contact2 = '"+search.getText()+"' ");
ResultSet rows = st.executeQuery(selectStuff);
}