Results 1 to 5 of 5
  1. #1
    linuxdoanpham is offline Member
    Join Date
    May 2012
    Posts
    3
    Rep Power
    0

    Default 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 address
    Last edited by DarrylBurke; 05-09-2012 at 04:19 PM. Reason: Removed email address

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,184
    Rep Power
    19

    Default Re: can you help me ! error Jtabel getSelectRow

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,184
    Rep Power
    19

    Default Re: can you help me ! error Jtabel getSelectRow

    Also How to ask questions the smart way

    You haven't asked a question.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    linuxdoanpham is offline Member
    Join Date
    May 2012
    Posts
    3
    Rep Power
    0

    Default 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
    can you help me ! error Jtabel getSelectRow-error.png
    But then I select 1 colum and click Button , message show
    JOptionPane.showMessageDialog(null, "No row is select");
    I don't know error where .

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,184
    Rep Power
    19

    Default 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.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 3
    Last Post: 05-08-2012, 05:26 PM
  2. problem in JTabel
    By jperson in forum AWT / Swing
    Replies: 2
    Last Post: 05-16-2010, 05:05 PM
  3. Updating JTabel
    By drwk in forum New To Java
    Replies: 2
    Last Post: 01-17-2010, 12:52 PM
  4. Replies: 1
    Last Post: 12-05-2009, 07:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •