Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
if jCHeckBox of one form is checked then how come the checkbox in another form is tobe made checked...?Especially if the checkbox is in a particular column of a jTable.....

What I have tried:

In DefaultValue.java
private void jCheckBox1MouseClicked(java.awt.event.MouseEvent evt) {
               // TODO add your handling code here:
       if(jCheckBox1.isSelected()==true)
       {
           jTextField1.setText("True");
       }
       else
       {
           jTextField1.setText("False");
       }
       }

in the constructor of data.java
for(int k=0;k<i;k++)
			{
				for(int l=0;l<Num(columnNameList);l++)	
				{
					if((dataTp[k][l]=="bool") && (key[k][l]=="Default"))
					{
						//table.setDefaultRenderer(String.class,new def());
						table.getColumnModel().getColumn(l).setCellRenderer(new chkBoxTableCellRenderer());
						
					}
					
				}
			}

In the same file --data.java
class chkBoxTableCellRenderer extends DefaultTableCellRenderer
{

	@Override
	public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
		JCheckBox chk=new JCheckBox();
		if(DefaultValue.strValue=="True")
		{
			
			chk.setSelected(true);
			return chk;
		}
		else 
		{
			chk.setSelected(false);
			return chk;
		}
	}
	
}

I cannot see
Posted
Updated 24-Feb-23 0:37am
v2
Comments
Richard Deeming 24-Feb-23 4:31am    
Nobody can help you fix a problem with your code without seeing it.

Click the green "Improve question" link and update your question to add the relevant parts of your code.
Member 12712527 24-Feb-23 6:12am    
class chkBoxTableCellRenderer extends DefaultTableCellRenderer
{

@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JCheckBox chk=new JCheckBox();
if(DefaultValue.strValue=="True")
{

chk.setSelected(true);
return chk;
}
else
{
chk.setSelected(false);
return chk;
}
}

}
in Data.java
for(int k=0;k
Richard Deeming 24-Feb-23 6:24am    
Read my comment again. Don't try to post your code in the comments; click the green "Improve question" link and add the code to your question.
Richard MacCutchan 24-Feb-23 5:45am    
That is because your secret code has a bug.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900