Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Swing / AWT / SWT
problem in actionlistner
sagar khana
Greenhorn
Posts: 21
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Posts: 4568
9
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Duplicate of
https://coderanch.com/t/564698
Sagar, that's the third time you've posted the same question. Can you stop doing that, please? Thanks.
Rototillers convert rich soil into dirt. Please note that this tiny ad is not a rototiller:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Question on static
problem in erasing panel
11 K&B questions. Question 3
problem in actionlistner
getText() is not working?
More...