File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Java
»
Swing / AWT / SWT
Author
problem in actionlistner
sagar khana
Greenhorn
Joined: Jan 15, 2012
Posts: 21
posted
Jan 17, 2012 07:24:25
0
i am having problem in this actionlistner while running first time it get called once and next time it called twice then four times and so on
here is code please give me any solution
thank you very much
public void launch() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:cone"); try { Statement st=con.createStatement(); String str="SELECT * FROM quizcontest"; ResultSet rs=st.executeQuery(str); while(rs.next()) { id[i]=rs.getInt("id"); ques[i]=rs.getString("ques"); a[i]=rs.getString("a"); b[i]=rs.getString("b"); c[i]=rs.getString("c"); d[i]=rs.getString("d"); cor[i]=rs.getString("cor"); //System.out.println(" "+id[i]+" "+ques[i]+" "+a[i]+" "+b[i]+" "+c[i]+" "+d[i]); i++; } i--; con.close(); } catch(SQLException e) { System.out.println("Table creation process denied");} } catch(Exception e) { e.printStackTrace(); } } public void display() { // System.out.println("value of g in display="+g+"\n\n"); if(g<=i) { //System.out.println(" "+id[g]+" "+ques[g]+" "+a[g]+" "+b[g]+" "+c[g]+" "+d[g]); // System.out.println("display"+g); //f1.dispose(); p1=new JPanel(); p2=new JPanel(); p3=new JPanel(); p4=new JPanel(); p5=new JPanel(); //p1.removeAll(); l1=new JLabel(ques[g]); r1=new JRadioButton(a[g]); r2=new JRadioButton(b[g]); r3=new JRadioButton(c[g]); r4=new JRadioButton(d[g]); p1.add(l1); b2.add(p1); p2.add(r1); p2.add(r2); b2.add(p2); p3.add(r3); p3.add(r4); b2.add(p3); p4.add(b1); b2.add(p4); f1.add(b2); f1.pack(); f1.setVisible(true); b1.addActionListener(this); }} // @Override public void actionPerformed(ActionEvent e) { if(g<i) g=g+1; p1.remove(l1); p2.remove(r1); p2.remove(r2); p3.remove(r3); p3.remove(r4); b2.remove(p1); b2.remove(p2); b2.remove(p3); System.out.println("submit"+g); display(); System.out.println("value of g in listner="+g); //l1.remove(ques); }
Matthew Brown
Bartender
Joined: Apr 06, 2010
Posts: 3786
1
I like...
posted
Jan 17, 2012 07:40:59
0
Duplicate of
http://www.coderanch.com/t/564698
Sagar, that's the third time you've posted the same question. Can you stop doing that, please? Thanks.
I agree. Here's the link:
http://jrebel.com/download
subject: problem in actionlistner
Similar Threads
problem in ActionListener
11 K&B questions. Question 3
Question on static
problem in erasing panel
problem in actionlistner
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter