Intermittent JTable Selection Problem

Hi,
Everyone once in a while, under NT with 1.4.x, I have problems selecting and highlighting row under JTable. It happens a good bit, but this does not happen all the time. When the table is buggy, it does not keep the row selected nor does it highlight the row. You may have the row selected on a mousedown, but once you release the mouse it's done.
Since this is happening for a variety of JTable's I didn't bother to send Java code. Has anyone else encountered this sort of thing? Or does anyone know what I should be looking at?
The intermittent part is what's killing me. It makes it hard to track down with any high degreee of confidence in the answers.
thanks for any input or suggestions,
Geoff

import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
public class Test extends JFrame {
  public Test() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container content = getContentPane();
    String[] head = {"One","Two","Three"};
    String[][] data = new String[40][3];
    for (int r=0; r<40; r++) {
      data[r] = new String[3];
      for (int c = 0; c < 3; c++) data[r][c] = "R" + r + "-C" + c;
    content.add(new JScrollPane(new JTable(data,head)));
    setSize(400, 400);
    show();
  public static void main(String args[]) { new Test(); }
}I've been clicking until my fingers bled. Can't see a problem.

Similar Messages

  • JTable select problem

    Hello,
    I have a great problem with my JTable. I have a JTable with few lines and two columns. The user can select one line and with the following statements
    int column = tblSearchResults.getSelectedColumn();
    int row = tblSearchResults.getSelectedRow();     
    Object value = tblSearchResults.getValueAt(row,column);
    I retrieve the value with which I display details of a second line in a new window (when the user presses a certain button). The problem is when I close this new window and want to select a new line the getSelectedColumn and the getSelectedRow returns always -1 which says that no line is marked although I have marked a line.
    Does anybody know what the problem can be? - it must concern the open and close of the detail window, because when I omit the code line which opens the detail window and only make System.out.println's with the getSelectedColumn and getSelectedRow it will always output the right line...
    thx
    pat

    Swing related questions should be posted in the Swing forum.
    You have not provided enough information to solve your problem. We don't know how you are invoking the dialog. Are you double clicking on a row, do you have a button the user clicks on to invoke processing?
    So for this, and future postings, you should learn how to create a simple demo program that shows your problem so we don't have to guess what you are doing.

  • JTable selection problem with jdk1.5.0_05

    Today I tried the new jdk1.5.0_05 release and noticed with a JTable I can only select a single column and row with the mouse. With jdk1.5.0_05 I could select multiple cols and rows with the mouse. I looking at the listselectionmodel for the jtable i see it is set to mulitple. Is this a bug in the new java 1.5 release?

    Yeah, the .jar files are definitely there and the
    small class I just wrote is in the Classes directory.Yes, but you're calling javac.exe, not some jars. Did you check that javac.exe is there? Stupid question, yes, but I've seen it all...
    I changed the path in Control Panel -> System ->
    Advanced -> Environment Variables. I've also beendoing this is the command prompt:
    set
    CLASSPATH=%CLASSPATH%;C:\Java\jdk1.5.0\bin;C:\Java\Cla
    ssesNo need to add the /bin directory to the classpath, there are no classes in it...

  • Jtable selection problems

    I'm trying the following code, but it doesn't work!
    the selection is not set to another row at all in my JTable.
    collectionsTableModel.collections.remove(collectionsTableModel.getCollection(num));
    setNewSelectionInsteadOf(num);
    collectionsTableModel.fireTableDataChanged();
    private void setNewSelectionInsteadOf(int num) {
    int newSelectedRow = num+1>collectionsTableModel.getRowCount() ? num-1: num;
    if (newSelectedRow>=0 && newSelectedRow < collectionsTableModel.getRowCount()) {
    collectionsTable.setRowSelectionInterval(newSelectedRow,newSelectedRow);
    }

    Actually the bug is just here:
    collectionsTable.setRowSelectionInterval(newSelectedRow,newSelectedRow);
    where collectionsTable is my JTable
    and newSelectedRow is an int that set the new selected row.
    it does not set the selected row at all...
    could this be because I do not fire the fireTableDataChanged in the right time?

  • Selection Problem with JTable

    Hello,
    i have a selection problem with JTable. I want to allow only single cell selection and additionally limit the selection to the first column.
    I preffered the style from MS Outlook Express where you can select the email accounts to edit.
    It is a table like this:
    Account name  |   Type  |   ...
    --------------|---------|---------------------
    Hotmail       |   POP3  |
    GMX           |   IMAP  |The selection should be only avaibable at 'Hotmail' or 'GMX' - not at 'POP3', 'IMAP' or as complete row selection.
    Please help me!
    Thanks.
    Warlock

    Maybe this will helpimport java.awt.*;
    import javax.swing.*;
    public class Test3 extends JFrame {
      public Test3() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = getContentPane();
        String[] head = {"One", "Two"};
        String[][] data = {{"R1-C1", "R1-C2"}, {"R2-C1", "R2-C2"}};
        JTable jt = new JTable(data, head);
        jt.getColumnModel().setSelectionModel(new MyTableSelectionModel());
        content.add(new JScrollPane(jt), BorderLayout.CENTER);
        jt.setCellSelectionEnabled(true);
        jt.setRowSelectionAllowed(false);
        jt.setColumnSelectionAllowed(false);
        setSize(300, 300);
        setVisible(true);
      public static void main(String[] arghs) { new Test3(); }
    class MyTableSelectionModel extends DefaultListSelectionModel {
      public void setSelectionInterval(int index0, int index1) {
        super.setSelectionInterval(0, 0);
    }

  • Select Problem For 'Back Menus' - Zen V P

    Just got the Zen V Plus and tried to set the time/date. Followed the 'guide' and after the time/date screen pressed the 'back button'. Got the Set Alarm/Date/Time (etc) menu but when I selected an option (moved joystick down to desired option then pressed the joystick) the time/date display came up and I was NOT ABLE to set the date. Same thing occurred trying to set the date (tried it several times and it worked once .... then attempted again - several times (4) but it only worked once). Turns out I have the same problem with any option in ANY 'back' menu. Suggestion?
    Do I have a defecti've unit (can't be the 'operator' who is defecti've! haha)? Should I return it and try another?
    Actually not that interested in playing music .... it's more for playing .wma(DRM) book files.

    Latest ... updated my firmware (to ZENVPlus_PCFW_P4S_L2___0.exe) and it fixed the select problem for SET DATE/TIME etc however
    the SELECT procedure doesn't always work for 'back button' menus. Example: tried to set a bookmark... following procedure in 'guide', pressed 'back button' and held it, from 'NOW PLAYING' screen - works 2 out of 5 times. Most of the time, pressing and holding takes you back to the previous menu - not to the 'back' (or in this case the SET BOOKMARK) menu. Sounds like something for the next version of firmware ... the code doesn't always set an internal timer correctly (am a programmer of 30 years ... part of that time pgmmng firmware).

  • Print selection problem

    when i select a page to be print from my pc the page select in

    Hello. I feel your pain and frustration with the print selection problem in safari, especially in Snow Leopard. I have spent hours trawling help pages and forums etc. BUT YEE HAA (sorry got a bit excited, but it really was hours) I found the answer. So here goes.
    Click on Safari
    Scroll down to services then slide to right
    Scroll down to services preferences and click
    Scroll down to the Text section
    If you Tick the Text box it will choose all options for you. Or if you don't want all options in the Text list, then untick Text box and tick options you do want.
    BUT for your print selection problem make sure you tick NEW TEXT EDIT WINDOW CONTAINING SELECTION.
    Then when you want to select something in a web page you want to print (including pictures etc) then highlight it, then Right click. And low and behold, in the list is NEW TEXT EDIT WINDOW CONTAINING SELECTION. Click that, Then press cmd+p and your printing.
    I really hope that helps with your problem
    I can now go to sleep.

  • At Line selection problem

    hi,
    iam stuck up with AT LINE-SELECTION problem ie i designed a screen where they need month list on clicking F4. i got the month list using month_names_get in the screen but while clicking the relevant month no.it's not entering into the required parameter. i have attached the codings,
    MODULE MONTH_DIS OUTPUT.
      SUPPRESS DIALOG.
      LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0.
      SET PF-STATUS SPACE.
      NEW-PAGE NO-TITLE.
      WRITE:/ 'SELECT MONTH' COLOR COL_HEADING.
      ULINE.
      DATA: T_MNTH LIKE T247 OCCURS 12 WITH HEADER LINE.
      refresh t_mnth.
      CALL FUNCTION 'MONTH_NAMES_GET'
       EXPORTING
         LANGUAGE                    = SY-LANGU
    IMPORTING
      RETURN_CODE                 =
        TABLES
          MONTH_NAMES                 = T_MNTH
       EXCEPTIONS
         MONTH_NAMES_NOT_FOUND       = 1
         OTHERS                      = 2
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      loop at t_mnth.
        write:/ t_mnth-mnr, t_mnth-ltx.
      endloop.
      CLEAR T_MNTH-MNR.
    ENDMODULE.                 " MONTH_DIS  OUTPUT
    AT LINE-SELECTION.
      p_period = t_mnth-mnr.
      CHECK NOT p_period IS INITIAL.
      LEAVE TO SCREEN 0.
    here in the AT LINE-SELECTION, the selected month is not coming to the required parameter.
    pls help me in this issue,
    Thanks in advance,
    Premnath.

    You need to set a "Hide" after the write... I suggest you also set your own dialog PF-STATUS too so you can have just a PF2 "pick" button and a Cancel button ( this will look better to the user).
    loop at t_mnth.
      write:/ t_mnth-mnr, t_mnth-ltx.
      hide: t_mnth.  "needs this
    endloop.
    clear: t_mnth.

  • Weird BGP path selection problem

    Hi, all,
    I am seeing a weird BGP path selection problem on 4948 switch running cat4500-entservicesk9-mz.122-46.SG.bin code, this switch has two uplinks to the same ISP's different edge router, one circuit is primary the other one is strict backup, only default route is accepted from ISP. I am setting both local preference and weight to the default route advertised over backup link, however neither one is taking effect, BGP still thinks the backup link is better, what could be wrong?
    rtr#sh ip bgp 0.0.0.0/0
    BGP routing table entry for 0.0.0.0/0, version 105
    Paths: (3 available, best #2, table Default-IP-Routing-Table, not advertised to EBGP peer)
      Not advertised to any peer
      17675, (received & used)
        203.169.8.37 from 203.169.8.37 (61.211.160.150)
          Origin IGP, localpref 100, valid, external
          Community: 65001:0 no-export
      17675
        203.169.8.45 from 203.169.8.45 (61.211.160.151)
          Origin IGP, localpref 90, weight 90, valid, external, best <====
          Community: 65001:0 no-export
      17675, (received-only)
        203.169.8.45 from 203.169.8.45 (61.211.160.151)
          Origin IGP, localpref 100, valid, external
          Community: 65001:0 no-export
    Thanks

    Hi,
    On cisco routers , weight is having highest preference to decide best path. By default for received route, weight is 0 but you are setting weight 90 to backup path and that is why it is getting preferred (higher is better). Please remove weight and let local preference be 90 (lesser than route on primary path)
    --Pls dont forget to rate helpful posts--
    Regards,
    Akash

  • Cross-JTable selection

    In a scenario where there are two JTable's in order to implement "locked (frozen) columns", one has to address the cross-JTable selection issue that occurs when both tables' "columnSelection" and "rowSelection" properties are enabled, and the user clicks & drags the mouse to select a range of cells across the two JTables.
    Has anyone ever done this?
    Mert

    Interesting question - I would try to register one mouseListener to both tables that makes sure the events are redispatched if the mouse exits the one and enters the other during a addSelection.Or you can try to patch the BasicTableUI.MouseHandler to go on with addSelection even after a mouseExited during a mouseDragged. Never tried it, though. (Always assuming that one there is one selectionListener that extends a selection in one table to the other)
    Greetings
    Jeanette

  • Certificate selection problem in Safari

    Hi ,
    I have certifcates A,B,C,D for the same site , whenever i use the Mozilla it is asking which one to select , but somehow i dont know why Safari is asking the same option.
    It is forcing me to accept Certifcate A to that paricular site. How to solve this problem in safari.
    Regards
    Vikranth

    Hello. I feel your pain and frustration with the print selection problem in safari, especially in Snow Leopard. I have spent hours trawling help pages and forums etc. BUT YEE HAA (sorry got a bit excited, but it really was hours) I found the answer. So here goes.
    Click on Safari
    Scroll down to services then slide to right
    Scroll down to services preferences and click
    Scroll down to the Text section
    If you Tick the Text box it will choose all options for you. Or if you don't want all options in the Text list, then untick Text box and tick options you do want.
    BUT for your print selection problem make sure you tick NEW TEXT EDIT WINDOW CONTAINING SELECTION.
    Then when you want to select something in a web page you want to print (including pictures etc) then highlight it, then Right click. And low and behold, in the list is NEW TEXT EDIT WINDOW CONTAINING SELECTION. Click that, Then press cmd+p and your printing.
    I really hope that helps with your problem
    I can now go to sleep.

  • Intermittent sound & voice problems

    I have been having Intermittent sound & voice problems
    During the last week when making receiving the voice and sound from the speaker is distorted on both ends of the conversation
    I have to restart the mobile and it works fine for a day or so then starts again
    I reset the phone to factory setting and it seems to have no effect
    Has anyone else had these problems?

    http://www.sonymobile.com/global-en/support/contact-us/
    Update Service (SUS)
    PC Companion (PCC)
    Bridge (for Mac)
    Alternatives on How to backup Xperias
    http://talk.sonymobile.com/thread/36355
    "I'd rather be hated for who I am, than loved for who I am not." Kurt Cobain (1967-1994)

  • Selection problem in JTable

    Hello everyone,
    I've a JTable,which I'm rendering using my own renderer.When the background of any cell within the table is rendered,that particular row does not get highlighted on mouseclick.However,when only the foreground is set (without setting the background),the row is highlighted.Can anyone suggest anything on this problem.I want the row to be highlighted on mouse click even if the background of the cell is rendered.
    thanx in advance.
    J.C

    Maybe u can use this, but you might want to extend your cell renderer.
    [qouote from API docs]
    setSelectionBackground
    public void setSelectionBackground(Color selectionBackground)
    Sets the background color for selected cells. Cell renderers can use this color to the fill selected cells.
    The default value of this property is defined by the look and feel implementation.

  • Essential problem with JTable Selections?

    As far as I noticed a JTable actually consists of multiple Lists.
    For example; If I want to navigate horizontal and vertical (diagnal) from one cell to another I have to use two ListSelectionListeners.
    One ListSelectionListener to determine row-selection changes and the second ListSelectionListener to determine column-selection changes.
    table.getSelectionModel().addListSelectionListener(listener);
    table.getColumnModel().getSelectionModel().addListSelectionListener(listener);Due to this way the valueChanged(ListSelectionEvent e) method defined by the ListSelectionListener interface is called two times when navigating in two directions and called once when navigating in one dimension.
    Can this problem easily be solved or is this an idea for improvement?
    P.S. I don't need the solving of this issue to help me progress with my current dev. It's just something that cracks my mind at four o'clock in the night.

    You're completly right. I did not formulate the question good enough (ahh well.. my first post). What I meant was the detection of selection events, by a mouse click for example.
    The JTable.changeSelection(row, column, toggle, extend) is used to programmatically change the selection itself. In matter of fact, I believe the mouse and/or keyboard actions even use this method to peform their tasks when clicking on a cell.
    In my case, the row and column index of the cell being clicked have to be passed when a user clicks it in the Jtable.
    I've made a JFrame program that shows an image when a cell is clicked. When the cell that is being clicked is in the same row or in the the same column as the previous selected cell, the picture is loaded once. When the newly clicked cell is in a different row and in a different column, the picture is loaded twice.
    I've made an executable. I would like to post it, but I don't know whether that is common in this community.
    Code in DistanceFinder which extends JFrame:
    MySelectionListener listener = new MySelectionListener(cityTable, imageLabel);
            cityTable.getSelectionModel().addListSelectionListener(listener);
            cityTable.getColumnModel().getSelectionModel()
                .addListSelectionListener(listener);
    MySelectionListener:
    package gui;
    import gui.MyLabel;
    import java.awt.Toolkit;
    import javax.swing.ImageIcon;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JTable;
    import javax.swing.ListSelectionModel;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    * @author Iwan
    public class MySelectionListener implements ListSelectionListener {
         private JTable jtable;
         private MyLabel imageLabel;
         public MySelectionListener(JTable jtable, MyLabel imageLabel) {
              // TODO Auto-generated constructor stub
              this.jtable = jtable;
              this.imageLabel = imageLabel;
         /* (non-Javadoc)
          * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
         @Override
         public void valueChanged(ListSelectionEvent e) {
              // If cell selection is enabled, both row and column change events are fired
            if ((e.getSource() == jtable.getSelectionModel() || e.getSource() == jtable.getColumnModel().getSelectionModel())
                      && !e.getValueIsAdjusting()
                      && jtable.getSelectedColumn() != jtable.getSelectedRow()
                      && jtable.getSelectedColumn() != 0
                      && jtable.getSelectedRow() != 0 ){
                 imageLabel.setImage(getSelectedCell(jtable));
         private int[] getSelectedCell(JTable jtable){
              int[] selectedCell = {jtable.getSelectedColumn(), jtable.getSelectedRow()};
              return selectedCell;
         private void showInfoBox(JTable jtable, ListSelectionEvent e){
              JOptionPane.showMessageDialog(null, "Row changed to: " + jtable.getSelectedRow()
                        + "\n Column changed to: " + jtable.getSelectedColumn()
                        + "\nFirst: " + e.getFirstIndex()
                        + "\nLast: " + e.getLastIndex());
    }So the question remains:
    The valueChanged(ListSelectionEvent e) method defined by the ListSelectionListener interface is called two times when navigating in two directions and called once when navigating in one dimension.
    Can this problem easily be solved or is this an idea for improvement?

  • When drap down box is selected then Jtable visible problem

    Hi i am going to select DrapDown box then Jtable will be visible on the screen otherwise not
    i have tried with jtable.setVisible(true) and fasle cases when JComboBox going to perofrm itemstate changed event..
    any suggestions will be appreciad....

    Make a change to the above script and place on "Change" event of "legalstatus".
    if(xfa.event.newText == '1'){
    form.size.presence = "visible";
    }else{
    form.size.presence = "hidden";
    If the above script has issues, please check the hierarchy/path of the drop downs("form.size" / "form.legalstatus").
    -Raghu.

Maybe you are looking for