Results 1 to 11 of 11
  1. #1
    madhav.dubey9 is offline Member
    Join Date
    Jan 2013
    Posts
    25
    Blog Entries
    1
    Rep Power
    0

    Default Problem handling mouse hovering

    Hello everyone!!
    I am making an application with both JCheckbox and JRadioButton in different JPanels but the problem is when we hover a mouse over them the JRadioButton get changed to JCheckBox .How to handle this hovering effect??

  2. #2
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    356
    Rep Power
    5

    Default Re: Problem handling mouse hovering

    Take a Look at the MouseListener Interface.

    MouseListener (Java Platform SE 6)

  3. #3
    madhav.dubey9 is offline Member
    Join Date
    Jan 2013
    Posts
    25
    Blog Entries
    1
    Rep Power
    0

    Default Re: Problem handling mouse hovering

    MouseListener does not helped..I applied it but nothing comes

  4. #4
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    356
    Rep Power
    5

    Default Re: Problem handling mouse hovering

    Can you post some of your code?

  5. #5
    madhav.dubey9 is offline Member
    Join Date
    Jan 2013
    Posts
    25
    Blog Entries
    1
    Rep Power
    0

    Default Re: Problem handling mouse hovering

    <code>
    import java.sql.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;

    class MyQuiz implements ActionListener,MouseListener
    {
    static JFrame f;
    static JSplitPane js;
    JPanel p1;
    CardLayout cl;
    int counter=1;
    JButton b1,b2,b3,b4,b5;
    ResultSet rs;
    int array[];
    static boolean flag=false;
    static JRadioButton optionA,optionB,optionC,optionD;
    Connection con;Statement stmt;int marks=0;
    static JCheckBox first,second,third,fourth;
    String ques_String="";
    JPanel p_radio,p_check;
    JLabel l;
    public MyQuiz()
    {



    JTextArea jta=new JTextArea();
    p1=new JPanel();

    p1.setLayout(new BorderLayout());
    l=new JLabel();
    l.setFont(new Font("Serif", Font.PLAIN, 25));
    p1.add(l,BorderLayout.NORTH);

    p_check=new JPanel();
    p_check.setLayout(new GridLayout(4,0));
    first=new JCheckBox();first.addActionListener(this);first.ad dMouseListener(this);
    second=new JCheckBox();second.addActionListener(this);second. addMouseListener(this);
    third=new JCheckBox();third.addActionListener(this);third.ad dMouseListener(this);
    fourth=new JCheckBox();fourth.addActionListener(this);fourth. addMouseListener(this);
    p_check.add(first);
    p_check.add(second);
    p_check.add(third);
    p_check.add(fourth);

    p_radio=new JPanel();
    p_radio.setLayout(new GridLayout(4,0));
    optionA=new JRadioButton();optionA.addActionListener(this);opt ionA.addMouseListener(this);
    optionB=new JRadioButton();optionB.addActionListener(this);opt ionB.addMouseListener(this);
    optionC=new JRadioButton();optionC.addActionListener(this);opt ionC.addMouseListener(this);
    optionD=new JRadioButton();optionD.addActionListener(this);opt ionD.addMouseListener (this);
    p_radio.add(optionA);
    p_radio.add(optionB);
    p_radio.add(optionC);
    p_radio.add(optionD);
    ButtonGroup button =new ButtonGroup();
    button.add(optionA);
    button.add(optionB);
    button.add(optionC);
    button.add(optionD);

    JPanel p3=new JPanel();
    p3.setLayout(new FlowLayout());
    p1.add(p3,BorderLayout.SOUTH);
    b1=new JButton("First");b1.addActionListener(this);
    b2=new JButton("<<Previous");b2.addActionListener(this);

    b3=new JButton("Next>>");b3.addActionListener(this);

    b4=new JButton("Last");b4.addActionListener(this);;
    b5=new JButton("Finish");b5.addActionListener(this);

    p3.add(b1);p3.add(b2);p3.add(b3);p3.add(b4);p3.add (b5);
    f=new JFrame();
    f.add(p1);
    ////////////////////////////////building a run time array //////////////////
    Random r=new Random();
    int i=0;
    boolean b =true;
    array=new int[10];
    int flag=0;

    outer:
    while(b)
    { flag=0;
    int temp=r.nextInt(20);

    if(temp==0)
    { continue;
    }
    else
    {

    for(int j=0;j<=i;j++)
    {
    if(array[j]==temp)
    {
    flag=1;
    continue outer;
    }
    }

    if(flag==0)
    {
    array[i]=temp;
    if(i==9)
    {
    b=false;
    }
    i++;
    continue outer;


    }

    }
    }










    ///////////////////////////////connection build/////////////////////
    try
    {

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con=DriverManager.getConnection("jdbc:odbc:stdsn", "sa", "thegamebegins");//("jdbc:sqlserver://localhost:1433;"+"databaseName=SCHOOL;"+"user=sa; password=thegamebegins");
    System.out.println("DATABASE NAME IS:"+ con.getMetaData().getDatabaseProductName());
    stmt=con.createStatement(ResultSet.TYPE_SCROLL_SEN SITIVE,ResultSet.CONCUR_UPDATABLE);
    rs=stmt.executeQuery("select * from QUES");




    rs.absolute(array[0]);

    String check="";

    check=rs.getString(8);
    if(check.equals("Yes"))
    { l.setText("Q."+counter+" "+rs.getString(2));

    first.setText(rs.getString(3));
    second.setText(rs.getString(4));
    third.setText(rs.getString(5));
    fourth.setText(rs.getString(6));
    p1.add(p_check,BorderLayout.CENTER);
    }
    else
    { l.setText("Q."+counter+" "+rs.getString(2));

    optionA.setText(rs.getString(3));
    optionB.setText(rs.getString(4));
    optionC.setText(rs.getString(5));
    optionD.setText(rs.getString(6));p1.add(p_radio,Bo rderLayout.CENTER);
    }
    f.setVisible(true);
    f.setSize(400,400);
    }



    catch(Exception e)
    {
    e.printStackTrace();
    }

    }

    public static void main(String args[])
    {
    MyQuiz mq=new MyQuiz();

    }



    public void actionPerformed(ActionEvent e)
    {
    try
    {

    if(e.getSource()==optionA)
    { int temp=array[counter-1];

    rs.absolute(temp);

    rs.updateString(11,"A");
    rs.updateRow();System.out.print("AAAAAAAAAAa");


    }
    else if(e.getSource()==optionB)
    {
    rs.absolute(array[counter-1]);
    rs.updateString(11,"B");
    rs.updateRow();System.out.print("BBBBBB");

    }
    else if(e.getSource()==optionC)
    {
    rs.absolute(array[counter-1]);
    rs.updateString(11,"C");
    rs.updateRow();
    }
    else if(e.getSource()==optionD)
    {
    rs.absolute(array[counter-1]);
    rs.updateString(11,"D");rs.updateRow();
    }
    else if(e.getSource()==first)
    {
    rs.absolute(array[counter-1]);
    String hi=rs.getString(11);
    if(hi.equals(""))
    {
    rs.updateString(11,"A");rs.updateRow();
    }
    else
    {

    char ch[]=hi.toCharArray();
    char newch[]=new char[4];
    int k=0;
    for(int i=0;i<ch.length;i++)
    {
    if("A".equals(ch[i]))
    {

    }
    else
    {
    ch[i]=newch[k];
    k++;
    }
    }
    String newstr=String.copyValueOf(newch);
    rs.updateString(11,"A"+newstr);rs.updateRow();
    }
    }
    else if(e.getSource()==second)
    {
    rs.absolute(array[counter-1]);
    String hi=rs.getString(11);
    if(hi.equals(""))
    {
    rs.updateString(11,"B");rs.updateRow();
    }
    else
    {

    char ch[]=hi.toCharArray();
    char newch[]=new char[4];
    int k=0;
    for(int i=0;i<ch.length;i++)
    {
    if("A".equals(ch[i]))
    {

    }
    else
    {
    ch[i]=newch[k];
    k++;
    }
    }
    String newstr=String.copyValueOf(newch);
    rs.updateString(11,"B"+newstr);rs.updateRow();
    }
    }
    else if(e.getSource()==third)
    {
    rs.absolute(array[counter-1]);
    String hi=rs.getString(11);
    if(hi.equals(""))
    {
    rs.updateString(11,"C");rs.updateRow();
    }
    else
    {

    char ch[]=hi.toCharArray();
    char newch[]=new char[4];
    int k=0;
    for(int i=0;i<ch.length;i++)
    {
    if("A".equals(ch[i]))
    {

    }
    else
    {
    ch[i]=newch[k];
    k++;
    }
    }
    String newstr=String.copyValueOf(newch);
    rs.updateString(11,"C"+newstr);rs.updateRow();
    }
    }
    else if(e.getSource()==fourth)
    {
    rs.absolute(array[counter-1]);
    String hi=rs.getString(11);
    if(hi.equals(""))
    {
    rs.updateString(11,"D");rs.updateRow();
    }
    else
    {

    char ch[]=hi.toCharArray();
    char newch[]=new char[4];
    int k=0;
    for(int i=0;i<ch.length;i++)
    {
    if("A".equals(ch[i]))
    {

    }
    else
    {
    ch[i]=newch[k];
    k++;
    }
    }
    String newstr=String.copyValueOf(newch);
    rs.updateString(11,"D"+newstr);rs.updateRow();
    }
    }

    else if(e.getActionCommand().equals("Next>>"))
    {


    counter++;
    if(counter==10)
    {
    b3.setEnabled(false);b5.setEnabled(true);
    }
    rs.absolute(array[counter-1]);
    String check=rs.getString(8);


    if(check.equals("NO"))
    { l.setText("Q."+counter+" "+rs.getString(2));
    p1.add(p_radio,BorderLayout.CENTER);
    optionA.setText(rs.getString(3));
    optionB.setText(rs.getString(4));
    optionC.setText(rs.getString(5));optionB.setSelect ed(true);
    optionD.setText(rs.getString(6));
    }
    else if (check.equals("YES"))
    { l.setText("Q."+counter+" "+rs.getString(2));
    p1.add(p_check,BorderLayout.CENTER);
    first.setText(rs.getString(3));
    second.setText(rs.getString(4));
    third.setText(rs.getString(5));
    fourth.setText(rs.getString(6));
    }
    }



    else if(e.getActionCommand().equals("<<Previous"))
    {


    counter--;
    if(counter==9)
    {
    b3.setEnabled(true);
    b4.setEnabled(true);
    b5.setEnabled(false);
    }
    if(counter==1)
    {
    b2.setEnabled(false);
    }
    rs.absolute(array[counter-1]);
    String check=rs.getString(8);


    if(check.equals("NO"))
    { l.setText("Q."+counter+" "+rs.getString(2));
    p1.add(p_radio,BorderLayout.CENTER);
    optionA.setText(rs.getString(3));
    optionB.setText(rs.getString(4));
    optionC.setText(rs.getString(5));
    optionD.setText(rs.getString(6));
    }
    else if(check.equals("YES"))
    { l.setText("Q."+counter+" "+rs.getString(2));
    p1.add(p_check,BorderLayout.CENTER);
    first.setText(rs.getString(3));
    second.setText(rs.getString(4));
    third.setText(rs.getString(5));
    fourth.setText(rs.getString(6));
    }
    }


    else if(e.getActionCommand().equals("First"))
    {


    counter=1;
    b1.setEnabled(false);
    b2.setEnabled(false);b5.setEnabled(false);
    rs.absolute(array[counter-1]);
    String check=rs.getString(8);
    b3.setEnabled(true);
    b4.setEnabled(true);

    if(check.equals("NO"))
    { l.setText("Q."+counter+" "+rs.getString(2));
    p1.add(p_radio,BorderLayout.CENTER);
    optionA.setText(rs.getString(3));
    optionB.setText(rs.getString(4));
    optionC.setText(rs.getString(5));
    optionD.setText(rs.getString(6));
    }
    else
    { l.setText("Q."+counter+" "+rs.getString(2));
    p1.add(p_check,BorderLayout.CENTER);
    first.setText(rs.getString(3));
    second.setText(rs.getString(4));
    third.setText(rs.getString(5));
    fourth.setText(rs.getString(6));
    }
    }


    else if(e.getActionCommand().equals("Last"))
    {


    counter=10;
    if(counter==10)
    {
    b3.setEnabled(false);
    b4.setEnabled(false);
    b5.setEnabled(true);
    }
    rs.absolute(array[counter-1]);
    String check=rs.getString(8);


    if(check.equals("NO"))
    { l.setText("Q."+counter+" "+rs.getString(2));
    p1.add(p_radio,BorderLayout.CENTER);
    optionA.setText(rs.getString(3));
    optionB.setText(rs.getString(4));
    optionC.setText(rs.getString(5));
    optionD.setText(rs.getString(6));
    }
    else
    { l.setText("Q."+counter+" "+rs.getString(2));
    p1.add(p_check,BorderLayout.CENTER);
    first.setText(rs.getString(3));
    second.setText(rs.getString(4));
    third.setText(rs.getString(5));
    fourth.setText(rs.getString(6));
    }
    }




    }
    catch(Exception ef)
    {

    }
    }
    public void mouseClicked(MouseEvent e){}
    public void mouseEntered(MouseEvent e){}
    public void mouseExited(MouseEvent e) {}
    public void mousePressed(MouseEvent e){}
    public void mouseReleased(MouseEvent e){}
    }
    </code>

  6. #6
    madhav.dubey9 is offline Member
    Join Date
    Jan 2013
    Posts
    25
    Blog Entries
    1
    Rep Power
    0

    Default Re: Problem handling mouse hovering

    Sorry for the entire code...this is database connectivity and i am trying to make a exam simulator.

  7. #7
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    356
    Rep Power
    5

    Default Re: Problem handling mouse hovering

    Can you go back and wrap your code in tags? Makes it easier to read.

  8. #8
    madhav.dubey9 is offline Member
    Join Date
    Jan 2013
    Posts
    25
    Blog Entries
    1
    Rep Power
    0

    Default Re: Problem handling mouse hovering

    Java Code:
    <code>
    import java.sql.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    
    class MyQuiz implements ActionListener,MouseListener
    {	
    static JFrame f;
    static JSplitPane js;
    JPanel p1;
    CardLayout cl;
    int counter=1;
    JButton b1,b2,b3,b4,b5;
    ResultSet rs;
    int array[];
    static boolean flag=false;
    static JRadioButton optionA,optionB,optionC,optionD;
    Connection con;Statement stmt;int marks=0;
    static JCheckBox first,second,third,fourth;
    String ques_String="";
    JPanel p_radio,p_check;
    JLabel l;
    public MyQuiz()
    {	
    
    
    
    JTextArea jta=new JTextArea();
    p1=new JPanel();
    
    p1.setLayout(new BorderLayout());
    l=new JLabel();	
    l.setFont(new Font("Serif", Font.PLAIN, 25));
    p1.add(l,BorderLayout.NORTH);
    
    p_check=new JPanel();
    p_check.setLayout(new GridLayout(4,0));
    first=new JCheckBox();first.addActionListener(this);first.ad dMouseListener(this);
    second=new JCheckBox();second.addActionListener(this);second. addMouseListener(this);
    third=new JCheckBox();third.addActionListener(this);third.ad dMouseListener(this);
    fourth=new JCheckBox();fourth.addActionListener(this);fourth. addMouseListener(this);
    p_check.add(first);
    p_check.add(second);
    p_check.add(third);
    p_check.add(fourth);
    
    p_radio=new JPanel();
    p_radio.setLayout(new GridLayout(4,0));
    optionA=new JRadioButton();optionA.addActionListener(this);opt ionA.addMouseListener(this);
    optionB=new JRadioButton();optionB.addActionListener(this);opt ionB.addMouseListener(this);
    optionC=new JRadioButton();optionC.addActionListener(this);opt ionC.addMouseListener(this);
    optionD=new JRadioButton();optionD.addActionListener(this);opt ionD.addMouseListener	(this);
    p_radio.add(optionA);
    p_radio.add(optionB);
    p_radio.add(optionC);
    p_radio.add(optionD);
    ButtonGroup button =new ButtonGroup();
    button.add(optionA);
    button.add(optionB);
    button.add(optionC);
    button.add(optionD);
    
    JPanel p3=new JPanel();
    p3.setLayout(new FlowLayout());
    p1.add(p3,BorderLayout.SOUTH);
    b1=new JButton("First");b1.addActionListener(this);
    b2=new JButton("<<Previous");b2.addActionListener(this);
    
    b3=new JButton("Next>>");b3.addActionListener(this);
    
    b4=new JButton("Last");b4.addActionListener(this);;
    b5=new JButton("Finish");b5.addActionListener(this);
    
    p3.add(b1);p3.add(b2);p3.add(b3);p3.add(b4);p3.add (b5);
    f=new JFrame();
    f.add(p1);
    ////////////////////////////////building a run time array //////////////////
    Random r=new Random();
    int i=0;
    boolean b =true;
    array=new int[10];
    int flag=0;
    
    outer:
    while(b)
    {	flag=0;
    int temp=r.nextInt(20);
    
    if(temp==0)
    {	continue;
    }
    else
    {
    
    for(int j=0;j<=i;j++)
    {	
    if(array[j]==temp)
    {	
    flag=1;
    continue outer;
    }
    }
    
    if(flag==0) 
    {
    array[i]=temp;
    if(i==9)
    {
    b=false;
    }
    i++; 
    continue outer;
    
    
    }
    
    }
    }
    
    
    
    
    
    
    
    
    
    
    ///////////////////////////////connection build/////////////////////
    try
    {
    
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con=DriverManager.getConnection("jdbc:odbc:stdsn", "sa", "thegamebegins");//("jdbc:sqlserver://localhost:1433;"+"databaseName=SCHOOL;"+"user=sa; password=thegamebegins");
    System.out.println("DATABASE NAME IS:"+ con.getMetaData().getDatabaseProductName());
    stmt=con.createStatement(ResultSet.TYPE_SCROLL_SEN SITIVE,ResultSet.CONCUR_UPDATABLE);
    rs=stmt.executeQuery("select * from QUES");	
    
    
    
    
    rs.absolute(array[0]);
    
    String check="";
    
    check=rs.getString(8);
    if(check.equals("Yes"))
    {	l.setText("Q."+counter+" "+rs.getString(2));
    
    first.setText(rs.getString(3));
    second.setText(rs.getString(4));
    third.setText(rs.getString(5));
    fourth.setText(rs.getString(6));
    p1.add(p_check,BorderLayout.CENTER);
    }
    else
    {	l.setText("Q."+counter+" "+rs.getString(2));
    
    optionA.setText(rs.getString(3));
    optionB.setText(rs.getString(4));
    optionC.setText(rs.getString(5));
    optionD.setText(rs.getString(6));p1.add(p_radio,Bo rderLayout.CENTER);
    }
    f.setVisible(true);
    f.setSize(400,400);
    }
    
    
    
    catch(Exception e)
    {
    e.printStackTrace();
    }
    
    }
    
    public static void main(String args[])
    {
    MyQuiz mq=new MyQuiz();
    
    }
    
    
    
    public void actionPerformed(ActionEvent e)
    {	
    try
    {
    
    if(e.getSource()==optionA)
    {	int temp=array[counter-1];	
    
    rs.absolute(temp);	
    
    rs.updateString(11,"A");
    rs.updateRow();System.out.print("AAAAAAAAAAa");
    
    
    }
    else if(e.getSource()==optionB)
    {
    rs.absolute(array[counter-1]);
    rs.updateString(11,"B");
    rs.updateRow();System.out.print("BBBBBB");
    
    }
    else if(e.getSource()==optionC)
    {
    rs.absolute(array[counter-1]);
    rs.updateString(11,"C");
    rs.updateRow();
    }
    else if(e.getSource()==optionD)
    {
    rs.absolute(array[counter-1]);
    rs.updateString(11,"D");rs.updateRow();
    }
    else if(e.getSource()==first)
    {
    rs.absolute(array[counter-1]);
    String hi=rs.getString(11);
    if(hi.equals(""))
    {
    rs.updateString(11,"A");rs.updateRow();
    }
    else
    {
    
    char ch[]=hi.toCharArray();
    char newch[]=new char[4];
    int k=0;
    for(int i=0;i<ch.length;i++)
    {	
    if("A".equals(ch[i]))
    {
    
    }
    else
    {
    ch[i]=newch[k];
    k++;
    }
    }
    String newstr=String.copyValueOf(newch);
    rs.updateString(11,"A"+newstr);rs.updateRow();
    }
    }
    else if(e.getSource()==second)
    {
    rs.absolute(array[counter-1]);
    String hi=rs.getString(11);
    if(hi.equals(""))
    {
    rs.updateString(11,"B");rs.updateRow();
    }
    else
    {
    
    char ch[]=hi.toCharArray();
    char newch[]=new char[4];
    int k=0;
    for(int i=0;i<ch.length;i++)
    {	
    if("A".equals(ch[i]))
    {
    
    }
    else
    {
    ch[i]=newch[k];
    k++;
    }
    }
    String newstr=String.copyValueOf(newch);
    rs.updateString(11,"B"+newstr);rs.updateRow();
    }
    }
    else if(e.getSource()==third)
    {
    rs.absolute(array[counter-1]);
    String hi=rs.getString(11);
    if(hi.equals(""))
    {
    rs.updateString(11,"C");rs.updateRow();
    }
    else
    {
    
    char ch[]=hi.toCharArray();
    char newch[]=new char[4];
    int k=0;
    for(int i=0;i<ch.length;i++)
    {	
    if("A".equals(ch[i]))
    {
    
    }
    else
    {
    ch[i]=newch[k];
    k++;
    }
    }
    String newstr=String.copyValueOf(newch);
    rs.updateString(11,"C"+newstr);rs.updateRow();
    }
    }
    else if(e.getSource()==fourth)
    {
    rs.absolute(array[counter-1]);
    String hi=rs.getString(11);
    if(hi.equals(""))
    {
    rs.updateString(11,"D");rs.updateRow();
    }
    else
    {
    
    char ch[]=hi.toCharArray();
    char newch[]=new char[4];
    int k=0;
    for(int i=0;i<ch.length;i++)
    {	
    if("A".equals(ch[i]))
    {
    
    }
    else
    {
    ch[i]=newch[k];
    k++;
    }
    }
    String newstr=String.copyValueOf(newch);
    rs.updateString(11,"D"+newstr);rs.updateRow();
    }
    }
    
    else if(e.getActionCommand().equals("Next>>"))
    {	
    
    
    counter++;
    if(counter==10)
    {
    b3.setEnabled(false);b5.setEnabled(true);
    }
    rs.absolute(array[counter-1]);
    String check=rs.getString(8);
    
    
    if(check.equals("NO"))
    {	 l.setText("Q."+counter+" "+rs.getString(2));
    p1.add(p_radio,BorderLayout.CENTER);
    optionA.setText(rs.getString(3));
    optionB.setText(rs.getString(4));
    optionC.setText(rs.getString(5));optionB.setSelect ed(true);
    optionD.setText(rs.getString(6));
    }
    else if (check.equals("YES"))
    {	l.setText("Q."+counter+" "+rs.getString(2));
    p1.add(p_check,BorderLayout.CENTER);
    first.setText(rs.getString(3));
    second.setText(rs.getString(4));
    third.setText(rs.getString(5));
    fourth.setText(rs.getString(6));
    }
    }
    
    
    
    else if(e.getActionCommand().equals("<<Previous"))
    {	
    
    
    counter--;
    if(counter==9)
    {
    b3.setEnabled(true);
    b4.setEnabled(true);
    b5.setEnabled(false);
    }
    if(counter==1)
    {
    b2.setEnabled(false);
    }
    rs.absolute(array[counter-1]);
    String check=rs.getString(8);
    
    
    if(check.equals("NO"))
    {	 l.setText("Q."+counter+" "+rs.getString(2));
    p1.add(p_radio,BorderLayout.CENTER);
    optionA.setText(rs.getString(3));
    optionB.setText(rs.getString(4));
    optionC.setText(rs.getString(5));
    optionD.setText(rs.getString(6));
    }
    else if(check.equals("YES"))
    {	l.setText("Q."+counter+" "+rs.getString(2));
    p1.add(p_check,BorderLayout.CENTER);
    first.setText(rs.getString(3));
    second.setText(rs.getString(4));
    third.setText(rs.getString(5));
    fourth.setText(rs.getString(6));
    }
    }
    
    
    else if(e.getActionCommand().equals("First"))
    {	
    
    
    counter=1;
    b1.setEnabled(false);
    b2.setEnabled(false);b5.setEnabled(false);
    rs.absolute(array[counter-1]);
    String check=rs.getString(8);
    b3.setEnabled(true);
    b4.setEnabled(true);
    
    if(check.equals("NO"))
    {	 l.setText("Q."+counter+" "+rs.getString(2));
    p1.add(p_radio,BorderLayout.CENTER);
    optionA.setText(rs.getString(3));
    optionB.setText(rs.getString(4));
    optionC.setText(rs.getString(5));
    optionD.setText(rs.getString(6));
    }
    else
    {	l.setText("Q."+counter+" "+rs.getString(2));
    p1.add(p_check,BorderLayout.CENTER);
    first.setText(rs.getString(3));
    second.setText(rs.getString(4));
    third.setText(rs.getString(5));
    fourth.setText(rs.getString(6));
    }
    }
    
    
    else if(e.getActionCommand().equals("Last"))
    {	
    
    
    counter=10;
    if(counter==10)
    {
    b3.setEnabled(false);
    b4.setEnabled(false);
    b5.setEnabled(true);
    }
    rs.absolute(array[counter-1]);
    String check=rs.getString(8);
    
    
    if(check.equals("NO"))
    {	 l.setText("Q."+counter+" "+rs.getString(2));
    p1.add(p_radio,BorderLayout.CENTER);
    optionA.setText(rs.getString(3));
    optionB.setText(rs.getString(4));
    optionC.setText(rs.getString(5));
    optionD.setText(rs.getString(6));
    }
    else
    {	l.setText("Q."+counter+" "+rs.getString(2));
    p1.add(p_check,BorderLayout.CENTER);
    first.setText(rs.getString(3));
    second.setText(rs.getString(4));
    third.setText(rs.getString(5));
    fourth.setText(rs.getString(6));
    }
    }
    
    
    
    
    }
    catch(Exception ef)
    {
    
    }
    }
    public void mouseClicked(MouseEvent e){}
    public void mouseEntered(MouseEvent e){}
    public void mouseExited(MouseEvent e) {}
    public void mousePressed(MouseEvent e){}
    public void mouseReleased(MouseEvent e){}
    }
    </code>

  9. #9
    bigsonny is offline Senior Member
    Join Date
    Nov 2010
    Posts
    167
    Rep Power
    4

    Default Re: Problem handling mouse hovering

    You are new to Java? FML

  10. #10
    madhav.dubey9 is offline Member
    Join Date
    Jan 2013
    Posts
    25
    Blog Entries
    1
    Rep Power
    0

    Default Re: Problem handling mouse hovering

    yeah ..you can say that..

  11. #11
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: Problem handling mouse hovering

    Unindented code is next to impossible to read. Learn about code formatting and other conventions: Code Conventions for the Java Programming Language: Contents

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. problem with mouse and keylistener
    By heman in forum AWT / Swing
    Replies: 3
    Last Post: 10-31-2012, 04:54 PM
  2. Problem with rect.contains mouse x and y
    By Lionlev in forum New To Java
    Replies: 5
    Last Post: 10-18-2012, 10:57 PM
  3. Url Handling Problem
    By talha06 in forum Web Frameworks
    Replies: 0
    Last Post: 09-12-2010, 05:13 PM
  4. Hovering mouse over a button and painting
    By gtraylo in forum AWT / Swing
    Replies: 2
    Last Post: 04-24-2008, 09:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •