Sharad

Greenhorn
+ Follow
since Aug 04, 2008
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 Sharad

ok ok....
My first & last name are already there...I have only modified the Display Name
I think "Add checkbox in Jtable" subject moved to "Add first & last Name" :roll:


Now back to thread...
I am displaying 10 rows(data is setted in model) in my Jtable with checkboxes & on clicking delete button, 5 selected rows are deleted from model(& i.e model is updated successfully with the remaining 5 records only.

But, still my table is displaying all the 10 records. All the time i need to restart my application to get the affected result..

My requirement is, if data model is upadated the JTable should also gets updated automatically with the new records only and user didnt need tio restart the application again.


Please le me know how to implemment this.

Thanks
Sharad
15 years ago
Maneesh,

long back when i created my user id on this website.. i just entered it as Sharad Golu....

Now i have make the correction and it will display only sharad further.
I haven't dropped the 2nd part by mistake
15 years ago
Thanks for all your suggesstions Rob..
Its working now.
15 years ago
Rob
Last thread was reagrding adding checkbox and this is for checkbox is not working.

I create an another thread with proper subject line..hope this is ok..

well your suggesstion for setValueAt() will come later..because after clicking on the checkbox it is not showing even the selected(right tick) icon.

even though i didnt click anywhere else..checkbox state is as it is...
15 years ago
Rob
Last thread was reagrding adding checkbox and this is for checkbox is not working.

I create an another thread with proper subject line..hope this is ok..

well your suggesstion for setValueAt() will come later..because after clicking on the checkbox it is not showing even the selected(right tick) icon.

even though i didnt click anywhere else..checkbox state is as it is...
15 years ago
I am working on swing application(displaying checkbox in Jtable) and facing this problem..

As an ouput MiscPanel is displaying a list of data in table format.
Column 0 = displaying checkbox
Column 1 = displaying types(string)

1) Onclicking checkboxes, ideally checkbox should selected. But nothing is happening.
2) On selecting on the types column cell, if I update the value and click on another cell then the
value on previously modified cell is unchanged and still displaying the default value in cell.

Did i need to any kind of listeners to table/tablemodel?
any other interface needs to be implemented?

Please let me know in detail how to resolve this.


//Code snippet

public JPanel getMiscPanel()
{
private String [] pNames = {"select","type"};
myMmodel= new MYTablemodel();
table = new JTable(myMmodel);
}

protected class MYTablemodel extends AbstractTableModel
{
Vector productDetails ;
MYTablemodel(){
productDetails = model.getProductDetails(); //model is storing all the data.
}
public Object getValueAt(int rowIndex, int columnIndex)
{
if (productDetails.size()>0)
{
Hashtable ht = (Hashtable) productDetails.get(rowIndex);
String str = "" ;
if(ht.containsKey(pNames[columnIndex]) && columnIndex!=0)
{
str = (String) ht.get(pNames[columnIndex]);
return str;
}else if(columnIndex==0){
return (Boolean)ht.get(pNames[columnIndex]);
}
}
return null;
}
public boolean isCellEditable(int row, int col)
{
return true;
}
public Class getColumnClass(int column)
{
if (column == 0) {
return Boolean.class;
}else{
return Object.class;
}
}
}

Thanks
15 years ago
Thanks a lot for all your suggesstions.
But its not working...


I tried below mentioned way to display checkbox and displayed it successfully. but to make it visible i need to click on that particular cell.

//code snippet
EachRowEditor1 rowEditor1 = new EachRowEditor1();
table.getColumn("Select").setCellEditor(rowEditor1);

class EachRowEditor1 implements TableCellEditor
{
protected TableCellEditor defaultEditor;
public EachRowEditor1()
{
defaultEditor = new DefaultCellEditor(new JCheckBox());
}
}

After trying this code,I am facing tese issues..

1) I need to click on every cell then only checkbox is visible.
2) Once i click another cell then checkbox of that particular cell is only visible and previouly clicked cell is again displaying nothing(just like blank TextField.


Your valuable sugesstions are highly needed.

Thanks in advance
Sharad
15 years ago
I am working on Swing application and my requirement is add new column that dispay the checkboxes, so user have the access to check/uncheck row for further process.
In application 3 tabbedpanes are there & in the 3rd tabbedpane table data is displaying.


//Code snippet


I tried following ways-
1)

here output is dispaying complete details of Checkbox


2)
till this point its working fine... but in above code method public Object getValueAt(int rowIndex, int columnIndex)
I am checking if(Column==0)
return Class.forName("java.lang.Boolean");

here it is throwing ClassCastException.. java.lang.Class cannot be cast to java.lang.Boolean

Please provide me solution aas soon as possible...coz from past 2 days i m stucking on this and due to this not able to move ahead on my application development.

Thanks in Advance
Sharad

[RP] added code tags [/RP]
[ October 08, 2008: Message edited by: Rob Prime ]
15 years ago
Thanks Maneesh.

It is working.
15 years ago
I am working on swing application.

In a panel, there are three tabs and when i am opening a starting my application, by default the 1st tab is displaying...

My requirement is - I need to display 3rd tab as a default , with out changing the order of tab.

Code snippet :-

JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.addTab("1st", panel1);
tabbedPane.addTab("2nd", panel2);
tabbedPane.addTab("3rd", panel3);

please let me know how to achieve this.

Thanks in advance
Sharad
15 years ago