Results 1 to 5 of 5
- 05-09-2012, 12:35 PM #1
Member
- Join Date
- May 2012
- Posts
- 3
- Rep Power
- 0
can you help me ! error Jtabel getSelectRow
package roleView;
import java.awt.BorderLayout;
import java.sql.SQLException;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import net.linuxdp.java.controller.RoleController;
import net.linuxdp.java.daoConfig.SqlConnection;
import net.linuxdp.java.model.RoleModel;
@SuppressWarnings("serial")
public class RoleList extends JPanel {
private TableModel model = new TableModel();
JTable tableRole = new JTable();
JScrollPane jspList = new JScrollPane();
SqlConnection connection = new SqlConnection();
public RoleList() {
loadRole();
setLayout(new BorderLayout());
tableRole.setModel(model);
jspList.setViewportView(tableRole);
add(jspList);
}
public void loadRole() {
try {
for (RoleModel user : RoleController.instance.allRoles()) {
model.insertRow(0, user.toArray());
}
} catch (SQLException e) {
e.printStackTrace();
}
}
@SuppressWarnings("rawtypes")
public void editRole() {
int[] listRole = tableRole.getSelectedRows();
System.out.println("selected rows: " + listRole.length);
System.out.println("selected rows: " + tableRole.getSelectedRows());
if (listRole.length == 0) {
JOptionPane.showMessageDialog(null, "No row is select");
} else if (listRole.length > 1) {
JOptionPane.showMessageDialog(this, "Only choise 1 row to update");
} else {
Vector rowRole = new Vector();
int i = tableRole.getSelectedRow();
rowRole = (Vector) connection.vRow.get(i);
for(int j = 0;j<rowRole.size();j++){
System.out.println(j + " . " + rowRole.get(j));
}
new editRolePanel();
}
}
public class TableModel extends DefaultTableModel {
private static final long serialVersionUID = 1L;
public TableModel() {
super(new Object[][] {}, new String[] { "ID","Name", "Description" });
}
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
}
}
Moderator edit: removed email addressLast edited by DarrylBurke; 05-09-2012 at 04:19 PM. Reason: Removed email address
- 05-09-2012, 04:16 PM #2
Re: can you help me ! error Jtabel getSelectRow
Why do they call it rush hour when nothing moves? - Robin Williams
- 05-09-2012, 04:20 PM #3
Re: can you help me ! error Jtabel getSelectRow
Also How to ask questions the smart way
You haven't asked a question.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 05-10-2012, 01:19 PM #4
Member
- Join Date
- May 2012
- Posts
- 3
- Rep Power
- 0
Re: can you help me ! error Jtabel getSelectRow
My DB :
CREATE TABLE Roles(
RoleID INT IDENTITY(1,1) CONSTRAINT PK_Roles PRIMARY KEY,
RoleName NVARCHAR(100),
Description NVARCHAR(200)
);
then I run data , view data Ok

But then I select 1 colum and click Button , message show
JOptionPane.showMessageDialog(null, "No row is select");
I don't know error where .
- 05-10-2012, 04:33 PM #5
Re: can you help me ! error Jtabel getSelectRow
To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
java.lang.NullpointerException error in tomcat 5.5 / http status 500 error
By rahil in forum Apache CommonsReplies: 3Last Post: 05-08-2012, 05:26 PM -
problem in JTabel
By jperson in forum AWT / SwingReplies: 2Last Post: 05-16-2010, 05:05 PM -
Updating JTabel
By drwk in forum New To JavaReplies: 2Last Post: 01-17-2010, 12:52 PM -
Thread: Error 500--Internal Server Error java.lang.NullPointerException
By jackdear44 in forum New To JavaReplies: 1Last Post: 12-05-2009, 07:28 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks