I want to control the number of clicks in my button group which is inside DefaultTableModel of JTable. Like only one click for a certain Radiobutton.
Suppose I have 3 radio buttons in a button group:
1) A
2) B
3) C
If a user clicks A he can select it only once by one click. For Second or third click it gets blocked. Now the problem is that I am not able to use
e.getClickCount()
method in my Button group Actionlistner.
Here is my code.
JTable MouseListner:-
jtable.addMouseListener(new MouseListener() {
public void mouseClicked(MouseEvent evt) {}
public void mouseEntered(MouseEvent evt) {}
public void mouseExited(MouseEvent evt) {}
public void mousePressed(MouseEvent e) {
int selectRow,selectColumn;
Point p = e.getPoint();
selectRow = getTable().rowAtPoint(new Point(e.getX(),e.getY()));
if(e.getClickCount() == 1) {
row = selectRow+1;
setRow(row);
}
else if(e.getClickCount() > 2) {System.out.println("NOT ALLOWED");}
}
public void mouseReleased(MouseEvent evt) {}
});
For jButton ActionListner like this:-
buttons[i].addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand().equals("myRadioButton")){
//System.out.println("value");
if (e.getClickCount() == 1) {}
System.out.println(getRow());
buttons[1].setEnabled(false);
}
}
});
Would appreciate any help :P
Thanks