guy madura

Greenhorn
+ Follow
since Oct 19, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by guy madura

Hi,

i too having the same problem .I went on to do the suggestions mentioned by Craig but i couldnt get the result.I need to get the values of a column from a JTable which has to undergo some validations when I click a button .If I change the focus to other column with the mouse ,before entering that button,I can fetch the value.Is there any possibility to change the focus explicitly when I click that button.

Suggestions please.

Kumar.
19 years ago
Hi Everybody,

I have a JTable which uses a table model and an editor .The table has two columns .I need to enter some value in one column cell and then I have to press button ,where some validations are being done with the value entered before in the Jtable.Moreover I have used table changed event.The porblem I faced is the table changed event doesnt get fired when I click the button .But after entering the values in Jtable ,if I changed the focus to the other column with the help of mouse ,the table changed event get fired.So I think the main problem is in focus change of columns in Jtable ,or the listener doesnt know whether the ediing is stopped or not.Can any one provide me solution for this.
Thanks in advance.
Kumar.
19 years ago
Here is the code for editor

class RadioButtonEditor extends DefaultCellEditor implements ItemListener {

public RadioButtonEditor(JCheckBox checkBox) {
super(checkBox);
ButtonGroup group = new ButtonGroup();
for (int row = 0;row < model.getRowCount();row++){
JRadioButton radio = (JRadioButton)model.getValueAt(row,0);
group.add(radio);
}

}
public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected, int row, int column) {

if (value==null) return null;
button = (JRadioButton)value;
button.addItemListener(this);
return (Component)value;

if (row%2 == 0) {
setBackground(Color.white);
}
else {
setBackground(new Color(220,220,220));
}
setForeground(Color.black);
if (isSelected) {

//selectedBorder is a solid border in the color
//table.getSelectionBackground().
setBackground(FXAppletUtil.LIGHT_BACKGROUND);
}


return (Component)value;


}

public Object getCellEditorValue() {
button.removeItemListener(this);
return button;
}

public void itemStateChanged(ItemEvent e) {
super.fireEditingStopped();

}
}

Any suggestions
19 years ago
The color change happens for all the rows and columns except the radiobutton column.I have added the code to editor and renderer.Moreover In editor getTableCellEditorComponent doesnt got executed.what should I do.
Any suggestions

Arun
19 years ago
Hi ,
Your question is not clear.
19 years ago
Hi everybody,

I need to add a column to JTable ( column of JRadioButtons).I had added through a customise renderer which implements default renderer.But the problem is the other columns works fine by having alternative color for each row except radio button column.Moreover the listener is not getting fired for radio button and also I have used customise editor which implements default cell editor.Can any one clear my doubt.
Thanks in advance.
Arun
19 years ago