Using arrowbuttons in JTable

When I use the arrowbuttons to move the "bar" (vertical) in my JTable, the ScrollPane doesn't scroll when I reach the top/bottom. The "bar" just keep moving out of sight and I have to use the mouse on the scrollbar. How do I fix that?

ok, I was wrong. It's not when I use arrowbuttons. I've made two buttons, up and down, to move items in the table. The "bar" follows the "moving" row. This way a user can move the row out of view.
So basicly what I need to know is how to scroll the ScrollPane manually.

Similar Messages

  • Plz tell me how to use JSpinner with JTable

    I have retrieve records from database but as the number of records(rows) are more than 1000 , i want to use JSpinner with JTable . plz solve my problem by giving the appropriate code for the same.

    hi
    check this links
    http://www.exampledepot.com/egs/javax.swing.table/CustRend.html
    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
    hope this will help you.. this explains exactly what you want.
    regards
    Aniruddha

  • How to use checkboxes in jtable ?

    I am trying to use checkboxes in
    JTable,I set the property in the jtable column to boolean.The proplem is that i do no know how to use this property in java program.My intension is that,I will have a java form and a java button on it,by clicking the button, i will have to write a code,for example a code that fetches records from a table and displays them on the jtable(on the user interface),when I select the check box corresponding to any row,It should let me either delete or edit that row and this modification has to be reflected to the table in the database. At this time,i can fetch and display but i can not delete or modify any row because I do no know how to use the check box inside the jtable.
    Thank you for your help!

    Multi-post: http://forum.java.sun.com/thread.jspa?threadID=5273661&tstart=0

  • How to use AbstractTableModel in JTable

    hi
    i want how to use AbstractTableModel in Jtable
    plz give code

    Multi-post: http://forum.java.sun.com/thread.jspa?threadID=5273661&tstart=0

  • Use JSpinner with JTable

    I have retrieve records from database but as the number of records(rows) are more than 1000 , i want to use JSpinner with JTable. How can i do so?

    you can start by being more clear on what your requirements are.

  • How to use vector in JTable? Please help......

    Hi there
    I can use JTable using object array to manupulate data but it has a limitation of defining number of rows of the array. Alternatively i want to use vector. Anyone help me how to convert to using vector.
    Regards.
    mortoza, Dhaka

    hi,
    you could either use javax.swing.table.DefaultTableModel because this class uses a java.util.Vector for data storage or you could implements your own TableModel by extending javax.swing.table.AbstractTableModel.
    best regards, Michael

  • How to use JCombobox (using ComboboxModel) in JTable?

    I have a question first, let imagine that i have 2 tables: Location(IDLocation, Place), Employee(ID, Name, Location)
    And I get all data in Location table into ArrayList, then setup a model (that extends ComboboxModel) and use this arraylist.
    After that i get all data in Employee table into Arraylist, then setup a MyTableModel (that extends AbstractTableModel) and use this arraylist.
    I could setup combobox in Location column, but i just wonder that how do i know how many comboboxes i need?. And if i use one model for all of these comboboxed and when i change selected item in one combobox, it will change data in other comboboxes in other rows. :(
    Anybody helps me, please?

    you just need only one combobox as the editor for all cell in location column.
    because, initially, all the cell in location column is "rendered" as non-combobox, the combobox appears only when you edit one cell, so you use only one combobox for every edition of a cell (in location column).
    The way to do this is to setCellEditor of your JTable to (new DefaultCellEditor(editComboBox)), so that every time you click on a cell (in location column), the combobox appears and your selected value will be the new value in that cell, all you have to do is just set the CellEditor as combobox, java 's done the rest for you.
    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#combobox : perfect in this situation
    import javax.swing.DefaultCellEditor;
    import javax.swing.JComboBox;
    public class TableComboBox extends javax.swing.JFrame {
        public TableComboBox() {
         initComponents();
        private void initComponents() {
            scrollPane = new javax.swing.JScrollPane();
            myTable = new javax.swing.JTable();
            getContentPane().setLayout(new java.awt.FlowLayout());
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            // create a table
            myTable.setModel(new javax.swing.table.DefaultTableModel(
                new Object [][] {
                    {"E01", "John Bolton", "Boston"},
                    {"E02", "Vannessa", "Ohio"},
                    {"E03", "Hellboy", "Alaska"}
                new String [] {
                    "ID", "Name", "Location"
            // create a combobox which model will be created from the database as the editor
            JComboBox locations = new JComboBox(new String[]{"Boston", "Ohio", "Alaska"});
            // create a default cell editor
            DefaultCellEditor editor = new DefaultCellEditor(locations);
            // set that cell editor as the location column cells editor (column number 2 is location column), then use setCellEditor() method
            myTable.getColumnModel().getColumn(2).setCellEditor(editor);
            scrollPane.setViewportView(myTable);
            getContentPane().add(scrollPane);
            java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
            setBounds((screenSize.width-380)/2, (screenSize.height-117)/2, 380, 117);
        public static void main(String args[]) {
         java.awt.EventQueue.invokeLater(new Runnable() {
             public void run() {
              new TableComboBox().setVisible(true);
        private javax.swing.JTable myTable;
        private javax.swing.JScrollPane scrollPane;
    }Edited by: bobbi2004 on Oct 28, 2008 9:59 AM

  • Bug when using JComboBox as JTable CellEditor

    Hello! I have a JTable that displays database information, and one of the columns is editable using a JComboBox. When the user selects an item from the JComboBox, the database (and consequently the JTable) is updated with the new value.
    Everything works fine except for a serious and subtle bug. To explain what happens, here is an example. If Row 1 has the value "ABC" and the user selects the editable column on that row, the JComboBox drops down with the existing value "ABC" already selected (this is the default behavior, not something I implemented). Now, if the user does not select a new value from the JComboBox, and instead selects the editable column on Row 2 that contains "XYZ", Row 1 gets updated to contain "XYZ"!
    The reason that is happening is because I'm updating the database by responding to the ActionListener.actionPerformed event in the JComboBox, and when a new row is selected, the actionPerformed event gets fired BEFORE the JTable's selected row index gets updated. So the old row gets updated with the new row's information, even though the user never actually selected a new item in the JComboBox.
    If I use ItemListener.itemStateChanged instead, I get the same results. If I use MouseListener.mousePressed/Released I get no events at all for the JComboBox list selection. If anyone else has encountered this problem and found a workaround, I would very much appreciate knowing what you did. Here are the relavent code snippets:
    // In the dialog containing JTable:
    JComboBox cboRouteType = new JComboBox(new String[]{"ABC", "XYZ"));
    cboRouteType.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent ev) {
              doCboRouteTypeSelect((String)cboRouteType.getSelectedItem());
    private void doCboRouteTypeSelect(String selItem) {
         final RouteEntry selRoute = tblRoutes.getSelectedRoute();
         if (selRoute == null) { return; }
         RouteType newType = RouteType.fromString(selItem);
         // Only update the database if the value was actually changed.
         if (selRoute.getRouteType() == newType) { return; }
         RouteType oldType = selRoute.getRouteType();
         selRoute.setRouteType(newType);
         // (update the db below)
    // In the JTable:
    public RouteEntry getSelectedRoute() {
         int selIndx = getSelectedRow();
         if (selIndx < 0) return null;
         return model.getRouteAt(selIndx);
    // In the TableModel:
    private Vector<RouteEntry> vRoutes = new Vector<RouteEntry>();
    public RouteEntry getRouteAt(int indx) { return vRoutes.get(indx); }

    Update: I was able to resolve this issue. In case anyone is curious, the problem was caused by using the actionPerformed method in the first place. Apparently when the JComboBox is used as a table cell editor, it calls setValueAt on my table model and that's where I'm supposed to respond to the selection.
    Obviously the table itself shouldn't be responsible for database updates, so I had to create a CellEditListener interface and implement it from the class that actually does the DB update in a thread and is capable of reporting SQL exceptions to the user. All that work just to let the user update the table/database with a dropdown. Sheesh!

  • How can I use JTextField as JTable cell editor while using AbstractTableMod

    I use this code but can not edit field
    import javax.swing.table.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.text.*;
    public class Main extends JFrame {
    JTable table;
    MyTableModel tableModel;
    public Main() {
    super("Colored JTable Demonstration");
    tableModel = new MyTableModel(10, 5);
    table = new JTable(tableModel);
    DefaultTableCellRenderer colorRenderer = new DefaultTableCellRenderer() {
    public void setValue(Object value) {
    if (value instanceof ColoredItem) {
    Color fcolor = ((ColoredItem) value).getForeground();
    Color bcolor = ((ColoredItem) value).getBackground();
    this.setForeground(fcolor);
    this.setBackground(bcolor);
    setText(((ColoredItem) value).getValue());
    table.setDefaultRenderer(Object.class, colorRenderer);
    //table.setDefaultEditor(Object.class, new DefaultCellEditor(new JTextField()));
    //Set up real input validation for the integer column.
    TableCellEditor editor = new DefaultCellEditor(new JTextField()) {
    public Component getTableCellEditorComponent(JTable table,
    Object value, boolean isSelected, int row, int column) {
    super.getTableCellEditorComponent(table, value, isSelected,row, column);
    JTextField myField = (JTextField) getComponent();
    //myField.setDocument(new ValidDocument());
    return myField;
    //if(value==null) return null;
    //return null;
    int numbercolumn = table.getColumnCount();
    for(int i = 0; i< numbercolumn ; i++){
    table.getColumnModel().getColumn(i).setCellEditor(editor);
    // table.getColumnModel().getColumn(i).setCellRenderer(new ColorRenderer());
    //table.validate();
    JScrollPane scrollPane = new JScrollPane(table);
    getContentPane().add(scrollPane, BorderLayout.CENTER);
    JPanel radioPanel = new JPanel(new GridLayout(1, 5));
    JRadioButton redRadio = new JRadioButton("Red");
    JRadioButton greenRadio = new JRadioButton("Green");
    JRadioButton blueRadio = new JRadioButton("Blue");
    JRadioButton yellowRadio = new JRadioButton("Yellow");
    JRadioButton blackRadio = new JRadioButton("Black");
    // Group the radio buttons.
    ButtonGroup group = new ButtonGroup();
    group.add(redRadio);
    group.add(greenRadio);
    group.add(blueRadio);
    group.add(yellowRadio);
    group.add(blackRadio);
    radioPanel.add(redRadio);
    radioPanel.add(greenRadio);
    radioPanel.add(blueRadio);
    radioPanel.add(yellowRadio);
    radioPanel.add(blackRadio);
    RadioListener radioListener = new RadioListener();
    redRadio.addActionListener(radioListener);
    greenRadio.addActionListener(radioListener);
    blueRadio.addActionListener(radioListener);
    yellowRadio.addActionListener(radioListener);
    blackRadio.addActionListener(radioListener);
    // add radiopanel to container
    JPanel panel = new JPanel(new GridLayout(2, 1));
    panel.add(new JLabel("Select color for selected cell:"));
    panel.add(radioPanel);
    getContentPane().add(BorderLayout.SOUTH, panel);
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    class ValidDocument extends PlainDocument {
    public void insertString(int index, String s, AttributeSet a)
    throws BadLocationException {
    if ((s == null) || (s.length() == 0)) {
    return;
    StringBuffer t = new StringBuffer(getLength() + s.length());
    t.append(getText(0, index));
    t.append(s);
    t.append(getText(index, getLength() - index));
    if(s.equals("1") && t.toString().equals("1")){               
    super.insertString(index, s, a);
    if(s.equals("0") && t.toString().equals("0")){
    super.insertString(index, s, a);
    if(s.equals(".") && t.toString().equals("0.")){
    super.insertString(index, s, a);
    if(s.equals("5") && t.toString().equals("0.5")){
    super.insertString(index, s, a);
    if(s.equals("b") && t.toString().equals("b")){
    super.insertString(index, s, a);
    //if (super instanceof ColoredItem) {
    // Color fcolor = ((ColoredItem) value).getForeground();
    // Color bcolor = ((ColoredItem) value).getBackground();
    // this.setForeground(fcolor);
    // this.setBackground(bcolor);
    //super.setText(t.toString());
    System.out.println("hehe");
    class RadioListener implements ActionListener {
    public void actionPerformed(ActionEvent ae) {
    int row = table.getSelectedRow();
    int column = table.getSelectedColumn();
    ColoredItem ci = (ColoredItem) tableModel.getValueAt(row, column);
    if (ae.getActionCommand().equals("Red"))
    ci.setBackground(Color.red);
    else if (ae.getActionCommand().equals("Green"))
    ci.setBackground(Color.green);
    else if (ae.getActionCommand().equals("Blue"))
    ci.setBackground(Color.blue);
    else if (ae.getActionCommand().equals("Yellow"))
    ci.setBackground(Color.yellow);
    else if (ae.getActionCommand().equals("Black"))
    ci.setBackground(Color.black);
    System.out.println(ci.getValue());
    // necessary to cause a fireTableCellUpdated event
    tableModel.setValueAt(ci, row, column);
    private class ColoredItem {
    private String value;
    private Color foreground;
    private Color background;
    public ColoredItem(String value, Color foreground, Color background) {
    this.value = value;
    this.foreground = foreground;
    this.background = background;
    public void setValue(String value) {
    this.value = value;
    public void setForeground(Color foreground) {
    this.foreground = foreground;
    public void setBackground(Color background) {
    this.background = background;
    public String getValue() {
    return value;
    public Color getForeground() {
    return foreground;
    public Color getBackground() {
    return background;
    class MyTableModel extends AbstractTableModel {
    String [] columnNames;
    ColoredItem [][] data;
    MyTableModel(int rows, int columns) {
    columnNames = createColumnElements(columns);
    data = createTableElements(rows, columns);
    public int getColumnCount() {
    return columnNames.length;
    public int getRowCount() {
    return data.length;
    public String getColumnName(int col) {
    return columnNames[col];
    public Object getValueAt(int row, int col) {
    return data[row][col];
    public Class getColumnClass(int c) {
    return getValueAt(0, c).getClass();
    public void setValueAt(ColoredItem value, int row, int col) {              
    data[row][col] = value;
    //System.out.println((ColoredItem)value.getValue());
    //temp.setValue((ColoredItem)value.getValue());
    fireTableCellUpdated(row, col);
    private String[] createColumnElements(int columns) {
    String[] data;
    data = new String[columns];
    for (int i=0; i<columns; i++) {
    data[i] = new String("Column " + i);
    return data;
    private ColoredItem [][] createTableElements(int rows, int columns) {
    ColoredItem [][]data;
    data = new ColoredItem[rows][];
    for (int i=0; i<rows; i++) {
    data[i] = new ColoredItem[columns];
    for (int j=0; j<columns; j++) {
    data[i][j] = new ColoredItem("", Color.black, Color.white);
    return data;
    public boolean isCellEditable(int rowIndex, int columnIndex) {
    return true;
    public static void main(String []args) {
    Main main = new Main();
    main.pack();
    main.setVisible(true);
    }

    JTextField jtxf=new JTextField();
         private void setColumns() {
    TableColumn column = null;
    if(this.getRowCount()>0){
    for (int i = 0; i < this.getColumnCount(); i++) {
    column = this.getColumnModel().getColumn(i);
              DefaultCellEditor dce = new DefaultCellEditor(jtxf);
              column.setCellEditor(dce);
              dce.setClickCountToStart(1);
    simply call this method in constructor it will help u

  • Re: Using JScrollPane With JTable

    >
    myNamePane.setVisible(true);This is meaningless, a component becomes visible by default when you add it to a visible container
    if(e.getSource().equals(newStudent))
           JFrame newFrame = new JFrame("Please select a student");
           newFrame.setContentPane(myNamePane);
           newFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
           newFrame.setResizable(false);
           newFrame.pack();
           newFrame.setVisible(true);
         }Which brings us to the main issue, you need to add the JScrollPane to you frame
    newFrame.add(myNamePane);Read the tutorial: [Using Top-Level Containers|http://java.sun.com/docs/books/tutorial/uiswing/components/toplevel.html]

    Hello Rodney,
    Thanks for the information and the tutorial.. I've worked with containers before but never got around to reading that one, which has clarified a few things for me.
    Unfortunately however, my problem persists. I obviously can't set the content pane as the JScrollPane and add it to the Frame, so rather than setting the JScrollPane as the content pane (which I did previously), I added it to the frame as you suggested:
    if(e.getSource().equals(newStudent))
         JFrame newFrame = new JFrame("Please select a student");
    //     newFrame.setContentPane(myNamePane);
         newFrame.add(myNamePane);
         newFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         newFrame.setResizable(false);
         newFrame.pack();
         newFrame.setVisible(true);
    }But the same thing happens! All I see is a new, empty JFrame. I feel like my understanding of the JScrollPane may be flawed, but I'm really not sure :/
    Edit: In fact, it is most definitely a problem either with my JTable or my JScrollPane. I used the setPreferredSize() method to check if the JScrollPane was being displayed in the JFrame, and it is. There is no JTable in the pane however.
    Edit #2: The problem was, in fact, with my JTable. The ResultSet I was using was TYPE_FORWARD_ONLY, and I was trying to call studentNameSet.first(), which prevented the JTable from ever being created. Thanks for your help, Rodney. Although I do have one more question.. Do you know a better way for me to find the number of student names given that ResultSet? I can't iterate through it twice as I had done earlier, so now for testing purposes I've simply hardcoded the number in, but I'd rather have the program find the total number of entries dynamically.
    Edited by: Pheer on Jul 22, 2008 10:07 AM
    Edited by: Pheer on Jul 22, 2008 10:09 AM

  • Hi, I can't use addRow in JTable

    Hi, I can't use addRow in tableModel1.addRow. I am new in Java
    here some code
    public class Class1 extends JInternalFrame implements TableModelListener
    public Class1(Connection srcCN, JFrame getParentFrame) throws SQLException
        try
        cnCus = srcCN;
              stCus = cnCus.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                        ResultSet.CONCUR_UPDATABLE);
              strSQL = "SELECT * FROM customer ORDER BY n_customer ASC";
        rsCus = stCus.executeQuery(strSQL);
          jbInit();
        catch(Exception e)
          e.printStackTrace();
      private void jbInit() throws Exception
        jScrollPane1.getViewport().add(jTable1, null);
        DefaultTableModel tableModel1 = MyModel();
        this.setClosable(true);
        this.setTitle("REVISION");
        this.setMaximizable(true);
        this.setSize(new Dimension(800, 600));
        this.setResizable(true);
        this.setIconifiable(true);
        this.addKeyListener(new java.awt.event.KeyAdapter()
            public void keyPressed(KeyEvent e)
              this_keyPressed(e);
    private DefaultTableModel MyModel(){
      DefaultTableModel m = new DefaultTableModel(){
      public void setValueAt(Object value, int iRows, int iCols) {
                        try {
                             rsCus.absolute(iRows + 1);
                             rsCus.updateString(iCols + 1, value.toString());
                             rsCus.updateRow();
                             super.setValueAt(value, iRows, iCols);
                        } catch (SQLException e) {
                   public boolean isCellEditable(int iRows, int iCols) {
                        if (iCols == 0)
                             return false;
                        if (iCols == 1)
                             return false;
                        return true;    
               public void addRow(Vector data){} 
    m.setDataVector(Content, ColumnHeaderName);
    return m;
    private void this_keyPressed(KeyEvent e)
    tableModel1.addRow(new Vector[]{"r5"});

    Here is an example of building a DefaultTableModel using the data in a ResultSet:
    import java.awt.*;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class TableFromDatabase extends JFrame
         public TableFromDatabase()
              Vector columnNames = new Vector();
            Vector data = new Vector();
            try
                //  Connect to the Database
                String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
    //            String url = "jdbc:odbc:Teenergy";  // if using ODBC Data Source name
                String url =
                    "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=c:/data/database.mdb";
                String userid = "";
                String password = "";
                Class.forName( driver );
                Connection connection = DriverManager.getConnection( url, userid, password );
                //  Read data from a table
                String sql = "Select * from Page";
                Statement stmt = connection.createStatement();
                ResultSet rs = stmt.executeQuery( sql );
                ResultSetMetaData md = rs.getMetaData();
                int columns = md.getColumnCount();
                //  Get column names
                for (int i = 1; i <= columns; i++)
                    columnNames.addElement( md.getColumnName(i) );
                //  Get row data
                while (rs.next())
                    Vector row = new Vector(columns);
                    for (int i = 1; i <= columns; i++)
                        row.addElement( rs.getObject(i) );
                    data.addElement( row );
                rs.close();
                stmt.close();
            catch(Exception e)
                System.out.println( e );
            //  Create table with database data
            JTable table = new JTable(data, columnNames);
            JScrollPane scrollPane = new JScrollPane( table );
            getContentPane().add( scrollPane );
            JPanel buttonPanel = new JPanel();
            getContentPane().add( buttonPanel, BorderLayout.SOUTH );
        public static void main(String[] args)
            TableFromDatabase frame = new TableFromDatabase();
            frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
            frame.pack();
            frame.setVisible(true);
    }

  • Using colors in Jtable

    I have a JTable which will show up several records. For ease of distinguishing between the various categories to which the records belong, I wish to differentiate between the categories with different colors. For eg I will use red color for records that need immediate attention, green colors for records that are perfectly OK and so on. Can somebody suggest me how should I go about it?
    Thanx in advance

    You should use a TableCellRenderer and set the colour depending upon the object that you are rendering. For more information, see the How to Use Tables tutorial; you'll find a link to it in the API documentation for JTable.

  • Problem using actionlisteners on Jtable

    i have used actionlistener on a jtable1 on panel1 but the same actionlistener is being called by jtable2 on panel2 on the event and gives me error.Both panels are on same internal frame. Any way to avoid this error?

    public void tableChanged(TableModelEvent e) {       
            System.out.println(e.getSource());
            try{
            if (e.getType() == TableModelEvent.UPDATE)
                int row = e.getFirstRow();
                int column = e.getColumn();
                if (column == 3 || column == 4 || column == 6)
                    double ordervalue = 0.0;
                    double qty = 0.0;
                    if(String.valueOf(purchaseTableModel.getValueAt(row,3)).equals("")){
                        purchaseTableModel.setValueAt("0.0",row,3);
                    }else if(String.valueOf(purchaseTableModel.getValueAt(row,4)).equals("")){
                        purchaseTableModel.setValueAt("0.0",row,4);
                    }else if(String.valueOf(purchaseTableModel.getValueAt(row,6)).equals("")){
                        purchaseTableModel.setValueAt("0.0",row,6);
                    }else{
                        lblMessage.setText("");
                        double extAmt = Double.parseDouble(purchaseTableModel.getValueAt(row,3).toString()) * Double.parseDouble(purchaseTableModel.getValueAt(row,4).toString());
                        purchaseTableModel.setValueAt(extAmt,row,5);
                        for(int i=0;i<tablePurchaseDetails.getRowCount();i++){
                            ordervalue = ordervalue + Double.parseDouble(purchaseTableModel.getValueAt(i,5).toString()) + Double.parseDouble(purchaseTableModel.getValueAt(i,6).toString());
                            qty = qty + Double.parseDouble(purchaseTableModel.getValueAt(i,3).toString());
                        txtOrdervalue.setText(String.valueOf(ordervalue));
                        txtTotalUnits.setText(String.valueOf(qty));
            }catch(Exception ex){
                ex.printStackTrace();
        }I am using checkbox in jtable2. On selection of checkbox of jtable2, the tableChanged() method is called which i have written for jtable1.
    java.lang.ArrayIndexOutOfBoundsException: 0 >= 0
    at java.util.Vector.elementAt(Vector.java:432)
    at javax.swing.table.DefaultTableModel.getValueAt(DefaultTableModel.java:621)

  • Which EventListener should I use for a jTable?

    I want to update a jLabel with the data in the jTable
    I want it to happen whenever a cell is done being edited.
    any suggestions would be appreciated.

    I can't figure out how to put that listener in, it's not an option in the netbeans 6 IDE and when I try to code it in myself, it doesn't work. :(
    in the future, i'll try to remember to post things in the correct places, but I think my new to java factor overrides everything else at this point. also, since i've been reprimanded for cross posting, twice, i'm not sure it's a good idea to repost this there, so I won't.

  • How to use JEditorPane in Jtable

    Hi
    I'm trying to put HyperLinks in JTable but i don't not how to add Hand Cursor when mouse is over a hyperLink and how to active it when click it.
    Thanks
    DefaultTableModel tableModel = new DefaultTableModel(new String[][]{{"<a href=www.google.com>Google</a>, <a href=www.yahoo.com>Yahoo</a>"}}, new String[]{"URL"});
    JTable table = new JTable(tableModel);
    table.setRowHeight(24);
    table.setDefaultRenderer(Object.class, new EditorPaneTableCellRenderer());
    class EditorPaneTableCellRenderer extends JEditorPane implements TableCellRenderer
    EditorPaneTableCellRenderer()
    setContentType("text/html");
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
    String link = String.valueOf(value);
    setText(link);
    setBackground(isSelected? table.getSelectionBackground() : table.getBackground());
    return this;
    }

    Multi-post: http://forum.java.sun.com/thread.jspa?threadID=5273661&tstart=0

Maybe you are looking for