Click here to Skip to main content
15,887,027 members
Home / Discussions / Java
   

Java

 
GeneralRe: How to build a simple web crawler that gets events for a future date? Pin
Richard MacCutchan8-Dec-17 23:07
mveRichard MacCutchan8-Dec-17 23:07 
GeneralRe: How to build a simple web crawler that gets events for a future date? Pin
Member 135663578-Dec-17 23:18
Member 135663578-Dec-17 23:18 
GeneralRe: How to build a simple web crawler that gets events for a future date? Pin
Richard MacCutchan8-Dec-17 23:23
mveRichard MacCutchan8-Dec-17 23:23 
GeneralRe: How to build a simple web crawler that gets events for a future date? Pin
Member 135663578-Dec-17 23:28
Member 135663578-Dec-17 23:28 
Questionhuffman codeing Pin
Member 125740473-Dec-17 19:48
Member 125740473-Dec-17 19:48 
AnswerRe: huffman codeing Pin
Afzaal Ahmad Zeeshan3-Dec-17 21:18
professionalAfzaal Ahmad Zeeshan3-Dec-17 21:18 
AnswerRe: huffman codeing Pin
Patrice T5-Dec-17 12:13
mvePatrice T5-Dec-17 12:13 
Questionjava swing program problem Pin
Member 135535202-Dec-17 5:16
Member 135535202-Dec-17 5:16 
my problem is that the result appears with the previous question choices and i don't know how to fix it

import java.awt.*;  
import java.awt.event.*;  
import javax.swing.*;  
  
class OnlineTest extends JFrame implements ActionListener  
{  
    JLabel l;  
    JRadioButton jb[]=new JRadioButton[5];  
    JButton b1,b2;  
    ButtonGroup bg;  
    int count=0,current=0,x=1,y=1,now=0;  
    int m[]=new int[10];      
    OnlineTest(String s)  
    {  
        super(s);  
        l=new JLabel();  
        add(l);  
        bg=new ButtonGroup();  
        for(int i=0;i<5;i++)  
        {  
            jb[i]=new JRadioButton();     
            add(jb[i]);  
            bg.add(jb[i]);  
        }  
        b1=new JButton("Next");  
        b2=new JButton("Bookmark");  
        b1.addActionListener(this);  
        b2.addActionListener(this);  
        add(b1);add(b2);  
        set();  
        l.setBounds(30,40,450,20);  
        jb[0].setBounds(50,80,600,30);  
        jb[1].setBounds(50,110,600,30);  
        jb[2].setBounds(50,140,600,30);  
        jb[3].setBounds(50,170,600,30);  
        b1.setBounds(100,240,100,30);  
        b2.setBounds(270,240,100,30);  
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
        setLayout(null);  
        setLocation(250,100);  
        setVisible(true);  
        setSize(600,350);  
    }  
    public void actionPerformed(ActionEvent e)  
    {  
        if(e.getSource()==b1)  
        {  
            if(check())  
                count=count+1;  
            current++;  
            set();    
            if(current==10)  
            {  
                b1.setEnabled(false);  
                b2.setText("Result");  
            }  
        }  
        if(e.getActionCommand().equals("Bookmark"))  
        {  
            JButton bk=new JButton("Bookmark"+x);  
            bk.setBounds(480,20+30*x,100,30);  
            add(bk);  
            bk.addActionListener(this);  
            m[x]=current;  
            x++;  
            current++;  
            set();    
            if(current==9)  
                b2.setText("Result");  
            setVisible(false);  
            setVisible(true);  
        }  
        for(int i=0,y=1;i<x;i++,y++)  
        {  
        if(e.getActionCommand().equals("Bookmark"+y))  
        {  
            if(check())  
                count=count+1;  
            now=current;  
            current=m[y];  
            set();  
            ((JButton)e.getSource()).setEnabled(false);  
            current=now;  
        }  
        }  
      
        /*if(e.getActionCommand().equals("Result"))  
        {  
            if(check())  
                count=count+1;  
            current++;  
            //System.out.println("correct ans="+count);  
            JOptionPane.showMessageDialog(this,"correct ans="+count);  
            System.exit(0);  
        }  */
        
        	 if(e.getActionCommand().equals("Result")) 
        {
        	   count=count+1;  
            current++;
        	if (count>=6)
        	        	l.setText("You have passed the exam " );
        		else
        			
        	l.setText( " Repeat the exam after 2 months " );    
        }
    }  
    void set()  
    {  
        jb[4].setSelected(true);  
        if(current==0)  
        {  
            l.setText("Que1: The only time you can cross two solid yellow lines is when ?");  
           jb[0].setText(" You need to pass");jb[1].setText(" Turning left at an intersection");jb[2].setText(" The car in front of you is driving under the speed limit");jb[3].setText(" You should never cross double solid yellow lines ");
      
            
        }  
        if(current==1)  
        {  
            l.setText("Que2: It is always illegal to park:");  
            jb[0].setText(" Three feet of a fire hydrant");jb[1].setText(" At a red curb");jb[2].setText(" In a double parked position ");jb[3].setText(" All of the above");  
        }  
        if(current==2)  
        {  
            l.setText("Que3: Always leave extra space in front of you when :");  
            jb[0].setText(" driving in bad weather");jb[1].setText(" When being followed closely");jb[2].setText(" Y  ou're following a motorcycle"); jb[3].setText(" all of  the above ");
        }  
        if(current==3)  
        {  
            l.setText("Que4: When is it ok to drive faster than the posted speed limit?");  
            jb[0].setText(" It is never ok");jb[1].setText(" When being followed closely ");jb[2].setText(" To keep pace with traffic flow");jb[3].setText(" If you have an emergency ");  
        }  
        if(current==4)  
        {  
            l.setText("Que5: What does an orange sign mean?");  
            jb[0].setText(" State highway ahead");jb[1].setText(" Merging lanes ahead ");jb[2].setText(" Construction work ahead ");jb[3].setText(" Divided highway ahead ");  
        }  
        if(current==5)  
        {  
            l.setText("Que6: If you see a car approaching in your lane you should:");  
            jb[0].setText(" Slow down");jb[1].setText(" Sound your horn ");jb[2].setText(" flash your lights");jb[3].setText(" All of the above");  
        }  
        if(current==6)  
        {  
            l.setText("Que7: When driving in heavy fog you should drive with your? ");  
            jb[0].setText(" Headlights off ");jb[1].setText(" Headlights on low beam ");jb[2].setText(" Parking lights on");  
                        jb[3].setText(" Headlights on high beam");  
        }  
        if(current==7)  
        {  
            l.setText("Que8: How far ahead should you look when you are on the highway?");  
            jb[0].setText(" 3 to 5 seconds ");jb[1].setText(" 5 to 10 seconds");jb[2].setText(" 10 to 15 seconds.");  
                        jb[3].setText(" 15 to 20 seconds");         
        }  
        if(current==8)  
        {  
            l.setText("Que9: What does a flashing yellow light mean?");  
            jb[0].setText(" Pedestrian crossing ");jb[1].setText(" Proceed with caution ");jb[2].setText(" School crossing ");jb[3].setText(" Non of the above");  
        }  
        if(current==9)  
        {  
            l.setText("Que10: What does a yellow sign mean?");  
            jb[0].setText(" State highway ahead ");jb[1].setText(" Construction work ahead");jb[2].setText(" A special situation ahead");  
                        jb[3].setText(" Construction work ahead");  
        }  
        	/*if(current==10)
        	{}*/
        	
        l.setBounds(30,40,450,20);  
        for(int i=0,j=0;i<=90;i+=30,j++)  
            jb[j].setBounds(50,80+i,200,20);  
    }  
    boolean check()  
    {  
        if(current==0)  
            return(jb[1].isSelected());  
        if(current==1)  
            return(jb[3].isSelected());  
        if(current==2)  
            return(jb[3].isSelected());  
        if(current==3)  
            return(jb[0].isSelected());  
        if(current==4)  
            return(jb[2].isSelected());  
        if(current==5)  
            return(jb[3].isSelected());  
        if(current==6)  
            return(jb[1].isSelected());  
        if(current==7)  
            return(jb[3].isSelected());  
        if(current==8)  
            return(jb[1].isSelected());  
        if(current==9)  
            return(jb[2].isSelected());
           
        return false;  
    }  
    public static void main(String s[])  
    {  
        new OnlineTest("Online Driving Test ");  
    }  
}

AnswerRe: java swing program problem Pin
Richard MacCutchan2-Dec-17 6:05
mveRichard MacCutchan2-Dec-17 6:05 
QuestionI need code source code for genetic synthesis and particle Swarm optimization in the netbeans environment to simulate cloudsim . Can anyone help me ? Pin
Member 1149240730-Nov-17 12:15
Member 1149240730-Nov-17 12:15 
AnswerRe: I need code source code for genetic synthesis and particle Swarm optimization in the netbeans environment to simulate cloudsim . Can anyone help me ? Pin
Richard MacCutchan30-Nov-17 21:13
mveRichard MacCutchan30-Nov-17 21:13 
AnswerRe: I need code source code for genetic synthesis and particle Swarm optimization in the netbeans environment to simulate cloudsim . Can anyone help me ? Pin
jschell1-Dec-17 7:59
jschell1-Dec-17 7:59 
QuestionWhat are the best methods to measure your test quality? Pin
Sealights 27-Nov-17 3:02
Sealights 27-Nov-17 3:02 
AnswerRe: What are the best methods to measure your test quality? Pin
Richard MacCutchan28-Nov-17 6:12
mveRichard MacCutchan28-Nov-17 6:12 
Questiongetting virus warning message from virustotal.com; can someone help me to understand this code Pin
Member 1353976424-Nov-17 7:15
Member 1353976424-Nov-17 7:15 
AnswerRe: getting virus warning message from virustotal.com; can someone help me to understand this code Pin
Richard Deeming28-Nov-17 2:32
mveRichard Deeming28-Nov-17 2:32 
QuestionBrand new Android Studio Install: Gradle synch failed Pin
Soujanya Naganuri24-Nov-17 1:21
professionalSoujanya Naganuri24-Nov-17 1:21 
QuestionDevelopment Platform: Thumb Drive Pin
C-P-User-321-Nov-17 3:08
C-P-User-321-Nov-17 3:08 
AnswerRe: Development Platform: Thumb Drive Pin
Jochen Arndt21-Nov-17 3:21
professionalJochen Arndt21-Nov-17 3:21 
GeneralRe: Development Platform: Thumb Drive Pin
C-P-User-321-Nov-17 4:59
C-P-User-321-Nov-17 4:59 
GeneralRe: Development Platform: Thumb Drive Pin
Richard MacCutchan21-Nov-17 5:05
mveRichard MacCutchan21-Nov-17 5:05 
GeneralRe: Development Platform: Thumb Drive Pin
Jochen Arndt21-Nov-17 5:08
professionalJochen Arndt21-Nov-17 5:08 
GeneralRe: Development Platform: Thumb Drive Pin
C-P-User-321-Nov-17 13:26
C-P-User-321-Nov-17 13:26 
AnswerRe: Development Platform: Thumb Drive Pin
Richard MacCutchan21-Nov-17 3:38
mveRichard MacCutchan21-Nov-17 3:38 
GeneralConnection to server Pin
Member 1351533210-Nov-17 22:42
Member 1351533210-Nov-17 22:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.