JTable looses selection

Hi all,
I am working with JDeveloper 9.0.3 and SuSE Linux 8.1. I used jTableName.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); to make multiple selections in my JTable possible. This works. But the JTable looses its selection when I scroll the table. I saw this working on an other (Windows) machine. Is this a known bug under Linux or what sould I do?
Thanks,
Axel

You may want to upgrade to the latest 1.3.1 on Linux. I haven't seen this myself.
Rob

Similar Messages

  • How to set special rows in jtable not selectable

    Hello programmers,
    anybody knows how to set special rows(p.E. row 0) in jtable not selectable.
    in advance thanks for your answers

    table = new JTable(...)
         public void changeSelection(int row, int column, boolean toggle, boolean extend)
              if (row == 0)
                   return;
              else
                   super.changeSelection(row, column, toggle, extend);
    };

  • JTable and selected row

    Hi,
    I'm new to Java, I'm writing a simple application using Swing, I've almost finished, almost, becose I have a jTabbedPane on 1st pane some labels and text fields, and on the second one jTable, I have to do 2 things:
    When row in JTable is selected, then the same user data should bevisible in JTabbedPane/Panel1 and if I select someon in panel1 then also the person in the jTable should be selected, what should I do? What's the function name? Please help.

    http://java.sun.com/docs/books/tutorial/uiswing/events/eventsandcomponents.html

  • JTable custom selection and mouse drag events

    Hello
    I am currently experiencing a problem when using a JTable and a custom selection. I have made a small example to demonstrate the probem. Selection works for this example by listening for when the user clicks or clicks and drags (button held down) and moves the mouse across cells in the table. For each MouseEvent received in the MouseMotionListener mouseDragged method I store the coordinates of that cell at the point of the mouse and render the cell at those coordinates with a line border allowing a more versatile cell selection. The problem that occurs is when you click+drag and move the mouse fast, it looks MouseEvents are created every x milliseconds so when you move fast there isn't a MouseEvent raised for each cell in the click+drag from A -> B. If you run the following example then click and hold down the mouse button and move fast downwards from the top of the table to the bottom you can see that not all the cells are selected vertically.
    Is there someway of increasing the mouse poll (if this is indeed the problem) during the click+drag or a better solution to this problem that any one knows!?
    I have tried attaching the example but it exceeded the message length for the forum post here is a link to code
    [http://www.oneandonlyluppy.pwp.blueyonder.co.uk/TableTest.java]
    [http://www.oneandonlyluppy.pwp.blueyonder.co.uk/TableTest.zip] <-- Contains the source and compiled classes
    I'll try adding the code again as a separate post
    Thanks
    Edited by: oneandonlyluppy on Jan 8, 2009 2:44 AM
    Edited by: oneandonlyluppy on Jan 8, 2009 2:45 AM

    AFAIK the mouse polling rate is OS dependent (being interrupt driven), and may even be affected by processor load. What you could do is store the mouse location (Point) of the last mouseDragged event, and compute a line to the current location, then use some coordinate geometry to identify any intervening cells which are presently being skipped.
    db

  • How to find out if JTable's selected row is visible?

    Hello there,
    Given:
    a JTable is inserted into a JScrollPane and the number of rows in the table is greater than the vieport size.
    A random row within the table gets programmatically selected.
    How to find out if the selected row is visible in a JTable visible area?
    Your help will be greatly appreciated.
    Tim

    That will make the row visible, but not answer whether it was visible
    in the first place. Try something like:
    public boolean isRowVisible( JTable table, int row ) {
        Rectangle rect = table.getBounds();
        int rowHeight = table.getRowHeight();
        int viewHeight = table.getParent().getHeight();
        int max = rect.y - viewHeight + 1;
        int rowPos = - rowHeight * row;
        return ( rect.y >= rowPos && rowPos > max );
    }assuming all rows have the same height.
    : jay

  • JTable Multiple Selection

    Hi,
    I am having a problem with the jTable's multiple selection.
    I apply cell renderers on a table's cells and also apply cell selection model on the table. I want to have mutliple row selection but I only get single selection.
    Could someone please explain why that is?
    Thanks
    Zweli
    <code>
    Utils.setupTableColumns(tblLookupProducts);
    Utils.setTableCellRenderer(tblLookupProducts, new CellToolTipRenderer(), -1);
    Utils.setCellFormatRenderer(tblLookupProducts, 5);
    Utils.setCellFormatRenderer(tblLookupProducts, 6);
    tblLookupProducts.setRowSelectionAllowed(true);
    cellSelectionModel = tblLookupProducts.getSelectionModel();
    cellSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    public class CellToolTipRenderer extends DefaultTableCellRenderer {
    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
    boolean hasFocus, int row, int col) {
    Component comp = super.getTableCellRendererComponent(
    table, value, isSelected, hasFocus, row, col);
    comp.setForeground(Color.black);
    comp.setBackground(Color.white);
    if (table.getSelectedRow() == row) {
    comp.setBackground(table.getSelectionBackground());
    comp.setForeground(Color.WHITE);
    setToolTipText(table.getModel().getValueAt(row, col).toString());
    return comp;
    * @author Zweli
    public class CellAlignmentRenderer extends DefaultTableCellRenderer {
    private int column;
    private NumberFormat currency = NumberFormat.getNumberInstance();
    private DecimalFormat df = new DecimalFormat("#,###,###,##0.00");
    private BigDecimal bd;
    public CellAlignmentRenderer(int column) {
    this.column = column;
    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
    boolean hasFocus, int row, int col) {
    Component comp = super.getTableCellRendererComponent(
    table, value, isSelected, hasFocus, row, col);
    comp.setForeground(Color.black);
    comp.setBackground(Color.white);
    if (table.getSelectedRow() == row) {
    comp.setBackground(table.getSelectionBackground());
    comp.setForeground(Color.WHITE);
    if (row != -1) {
    setHorizontalAlignment(SwingConstants.RIGHT);
    setToolTipText(table.getModel().getValueAt(row, col).toString());
    return comp;
    </code>

    Hello,
    Please edit your post and use proper tags.
    +if (table.getSelectedRow() == row) {+
    From the JTable API Javadoc:
    getSelectedRow()
    Returns the index of the first selected row, -1 if no row is selected.
    So this only returns +one+ index among all those selected.
    You could use <tt>getSelectedRows()</tt> (notice the +s+ !) instead, but there's a much better approach: guess what the +isSelected+ argument to <tt>getTableCellRendererComponent(...)</tt> stands for :o)
    Regards.
        J.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • JTable - row selection not working + change the text format

    Hi All,
    I have written a code to display Jtable with 2 columns, 1 column to display image+text and other is multiline.
    I have used 2 different cell renderer for achiveing the same.
    Please advice on the following:
    @ When I click on row, only one column gets selected. How to fix this?
    @ Data to be displayed in rows is fetched from database. And on some STATUS value row should be in bold text or plain text. I have achieved this but withou logic to iterate over it.
    @ When user right clicks on the row allow them to set text in the row as bold or plain.(Just like we do with mails in outlook box)
    Below is the code:
    Hi All,
    I have written a code to display Jtable with 2 columns, 1 column to display image+text and other is multiline.
    I have used 2 different cell renderer for achiveing the same.
    Please advice on the following:
    @ When I click on row, only one column gets selected. How to fix this?
    @ Data to be displayed in rows is fetched from database. And on some STATUS value row should be in bold text or plain text. I have achieved this but withou logic to iterate over it.
    @ When user right clicks on the row allow them to set text in the row as bold or plain.(Just like we do with mails in outlook box)
    Below is the code:package jtab;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.util.Vector;
    import javax.swing.ImageIcon;
    import javax.swing.JEditorPane;
    import javax.swing.JFrame;
    import javax.swing.JMenuItem;
    import javax.swing.JOptionPane;
    import javax.swing.JPopupMenu;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.table.DefaultTableCellRenderer;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableCellRenderer;
    import jtab.TestIcon.iconRenderer;
    public class SampleJtable {
         JFrame frame;
         JTable table;
         JScrollPane panel;
         JPopupMenu popupMenu ;
         public static void main(String[] args) {
              SampleJtable sample = new SampleJtable();
              sample.loadGUI();
         public void loadGUI(){
              frame = new JFrame("Sample Program for Font and ImageIcons");
              frame.setContentPane(panel);
              frame.setSize(550,250);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setVisible(true);
         public SampleJtable(){
              BufferedImage images[] = new BufferedImage[1];
              try{
                   images[0] = javax.imageio.ImageIO.read(new File("C:/go.gif"));
              }catch(Exception e){
                   e.printStackTrace();
              final Object data [][] = {{"Auftrag \n test \n 777,Abdherhalden Josef, \n 1957,Grenchen Kaufe \n P",new ImageStore(images[0],"Bourquin Rene")},
                        {"Auftrag \n test \n \n 1957,Grenchen Kaufe \n N",new ImageStore(images[0],"Bourquin Rene")}};
              String colIds [] ={"Beschrebung","Von"};
              DefaultTableModel model = new DefaultTableModel(data, colIds) {  
    public Class getColumnClass(int column) {  
    return data[0][column].getClass();
              /*Vector<Object> rowData1 = new Vector(2);
              rowData1.add("Auftrag \n test \n 777,Abdherhalden Josef, \n 1957,Grenchen Kaufe");
              rowData1.add(new ImageStore(images[0],"Bourquin Rene"));
              Vector<Object> rowData2 = new Vector(2);
              rowData2.add("Auftrag \n test \n 777,Abdherhalden Josef, \n 1957,Grenchen Kaufe");
              rowData2.add(new ImageStore(images[0],"Bourquin Rene"));
              Vector<Vector> rowData = new Vector<Vector>();
         rowData.addElement(rowData1);
         rowData.addElement(rowData2);
              Vector<String> columnNames = new Vector<String>();
         columnNames.addElement("Beschrebung");
         columnNames.addElement("Von");     
              DefaultTableModel model = new DefaultTableModel(rowData, columnNames) {  
              table = new JTable(model);
              table.setDefaultRenderer(ImageStore.class, new ImageRenderer());          
              table.getTableHeader().getColumnModel().getColumn(0).setCellRenderer(new LineCellRenderer());
              table.setRowHeight(84);
              panel = new JScrollPane(table);
              panel.setOpaque(true);
         class ImageRenderer extends DefaultTableCellRenderer {  
         public Component getTableCellRendererComponent(JTable table,
         Object value,
         boolean isSelected,
         boolean hasFocus,
         int row, int column) {  
         super.getTableCellRendererComponent(table, value, isSelected,
         hasFocus, row, column);
         ImageStore store = (ImageStore)value;
         setIcon(store.getIcon());
         setText(store.text);
         return this;
         class ImageStore {  
         ImageIcon icons;
         String text;
         int showingIndex;
         public ImageStore(BufferedImage image1,String s) {
         icons = new ImageIcon(image1);
         showingIndex = 0;
         text = s;
         public ImageIcon getIcon() {  
         return icons;
         public void toggleIndex() {  
         showingIndex = (showingIndex == 0) ? 1 : 0;
         class LineCellRenderer extends JEditorPane implements TableCellRenderer {
              public LineCellRenderer() {           
              setOpaque(true);
              setContentType("text/html");          
              public Component getTableCellRendererComponent(JTable table, Object value,
              boolean isSelected, boolean hasFocus, int row, int column) {
              //System.out.println("Whats in value = "+ value.toString());
              String [] strArray = value.toString().split("\n");
              String rtStr = null ;
              System.out.println("TYPE+ "+ strArray[strArray.length-1].toString());
              String val = strArray[strArray.length-1].toString().trim();
              if (val.equalsIgnoreCase("N")){
                   System.out.println("TYPE+ IS NEW");
                   rtStr = "<html><head></head><body><b><div style=\"color:#FF0000;font-weight:bold;\">" + strArray[0] + "</div>" +
                             " <div style=\"color:#0000FF;font-weight:bold;\">" + strArray[1] + "</div>" +
                             "<div style=\"color:#0000FF;font-weight:bold;\">" + strArray[2] + "</div>" +
                             "<div style=\"color:#0000FF;font-weight:bold;\">" + strArray[3] + "</div>" +
                             "</b></body></html>";
              else {
                   System.out.println("TYPE+ IS PENDING");
                   rtStr = "<html><head></head><body><div style=\"color:#FF0000;\">" + strArray[0] + "</div>" +
                   " <div style=\"color:#0000FF;\">" + strArray[1] + "</div>" +
                   "<div style=\"color:#0000FF;\">" + strArray[2] + "</div>" +
                   "<div style=\"color:#0000FF;\">" + strArray[3] + "</div>" +
                   "</body></html>";
              setText(rtStr);
              return this;

    Posting code again........
    package jtab;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.util.Vector;
    import javax.swing.ImageIcon;
    import javax.swing.JEditorPane;
    import javax.swing.JFrame;
    import javax.swing.JMenuItem;
    import javax.swing.JOptionPane;
    import javax.swing.JPopupMenu;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.table.DefaultTableCellRenderer;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableCellRenderer;
    import jtab.TestIcon.iconRenderer;
    public class SampleJtable {
    JFrame frame;
    JTable table;
    JScrollPane panel;
    JPopupMenu popupMenu ;
    public static void main(String[] args) {
    SampleJtable sample = new SampleJtable();
    sample.loadGUI();
    public void loadGUI(){
    frame = new JFrame("Sample Program for Font and ImageIcons");
    frame.setContentPane(panel);
    frame.setSize(550,250);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    public SampleJtable(){
    BufferedImage images[] = new BufferedImage[1];
    try{
    images[0] = javax.imageio.ImageIO.read(new File("C:/go.gif"));
    }catch(Exception e){
    e.printStackTrace();
    final Object data [][] = {{"Auftrag \n test \n 777,Abdherhalden Josef, \n 1957,Grenchen Kaufe \n P",new ImageStore(images[0],"Bourquin Rene")},
    {"Auftrag \n test \n \n 1957,Grenchen Kaufe \n N",new ImageStore(images[0],"Bourquin Rene")}};
    String colIds [] ={"Beschrebung","Von"};
    DefaultTableModel model = new DefaultTableModel(data, colIds) {
    public Class getColumnClass(int column) {
    return data[0][column].getClass();
    /Vector<Object> rowData1 = new Vector(2);
    rowData1.add("Auftrag \n test \n 777,Abdherhalden Josef, \n 1957,Grenchen Kaufe");
    rowData1.add(new ImageStore(images[0],"Bourquin Rene"));
    Vector<Object> rowData2 = new Vector(2);
    rowData2.add("Auftrag \n test \n 777,Abdherhalden Josef, \n 1957,Grenchen Kaufe");
    rowData2.add(new ImageStore(images[0],"Bourquin Rene"));
    Vector<Vector> rowData = new Vector<Vector>();
    rowData.addElement(rowData1);
    rowData.addElement(rowData2);
    Vector<String> columnNames = new Vector<String>();
    columnNames.addElement("Beschrebung");
    columnNames.addElement("Von");
    DefaultTableModel model = new DefaultTableModel(rowData, columnNames) {
    table = new JTable(model);
    table.setDefaultRenderer(ImageStore.class, new ImageRenderer());
    table.getTableHeader().getColumnModel().getColumn(0).setCellRenderer(new LineCellRenderer());
    table.setRowHeight(84);
    panel = new JScrollPane(table);
    panel.setOpaque(true);
    class ImageRenderer extends DefaultTableCellRenderer {
    public Component getTableCellRendererComponent(JTable table,
    Object value,
    boolean isSelected,
    boolean hasFocus,
    int row, int column) {
    super.getTableCellRendererComponent(table, value, isSelected,
    hasFocus, row, column);
    ImageStore store = (ImageStore)value;
    setIcon(store.getIcon());
    setText(store.text);
    return this;
    class ImageStore {
    ImageIcon icons;
    String text;
    int showingIndex;
    public ImageStore(BufferedImage image1,String s) {
    icons = new ImageIcon(image1);
    showingIndex = 0;
    text = s;
    public ImageIcon getIcon() {
    return icons;
    public void toggleIndex() {
    showingIndex = (showingIndex == 0) ? 1 : 0;
    class LineCellRenderer extends JEditorPane implements TableCellRenderer {
    public LineCellRenderer() {
    setOpaque(true);
    setContentType("text/html");
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column) {
    //System.out.println("Whats in value = " value.toString());
    String [] strArray = value.toString().split("\n");
    String rtStr = null ;
    System.out.println("TYPE " strArray[strArray.length-1].toString());
    String val = strArray[strArray.length-1].toString().trim();
    if (val.equalsIgnoreCase("N")){
    System.out.println("TYPE IS NEW");
    rtStr = "<html><head></head><body><b><div style=\"color:#FF0000;font-weight:bold;\">" strArray[0] "</div>"
    " <div style=\"color:#0000FF;font-weight:bold;\">" strArray[1] "</div>"
    "<div style=\"color:#0000FF;font-weight:bold;\">" strArray[2] "</div>"
    "<div style=\"color:#0000FF;font-weight:bold;\">" strArray[3] "</div>"
    "</b></body></html>";
    else {
    System.out.println("TYPE+ IS PENDING");
    rtStr = "<html><head></head><body><div style=\"color:#FF0000;\">" strArray[0] "</div>"
    " <div style=\"color:#0000FF;\">" strArray[1] "</div>"
    "<div style=\"color:#0000FF;\">" strArray[2] "</div>"
    "<div style=\"color:#0000FF;\">" strArray[3] "</div>"
    "</body></html>";
    setText(rtStr);
    return this;
    }

  • How prevent JTable row selection?

    there are three selection mode for JTable, MultiIntervalSelection, SingleIntervalSelection and SingleSelection. Is there a no selection mode?

    add selection listener and call table.clearSelection();or
    public class NullSelectionModel implements ListSelectionModel {
              public boolean isSelectionEmpty() { return true; }
              public boolean isSelectedIndex(int index) { return false; }
              public int getMinSelectionIndex() { return -1; }
              public int getMaxSelectionIndex() { return -1; }
              public int getLeadSelectionIndex() { return -1; }
              public int getAnchorSelectionIndex() { return -1; }
              public void setSelectionInterval(int index0, int index1) { }
              public void setLeadSelectionIndex(int index) { }
              public void setAnchorSelectionIndex(int index) { }
              public void addSelectionInterval(int index0, int index1) { }
              public void insertIndexInterval(int index, int length, boolean before) { }
              public void clearSelection() { }
              public void removeSelectionInterval(int index0, int index1) { }
              public void removeIndexInterval(int index0, int index1) { }
              public void setSelectionMode(int selectionMode) { }
              public int getSelectionMode() { return SINGLE_SELECTION; }
              public void setValueIsAdjusting(boolean valueIsAdjusting) { }
              public boolean getValueIsAdjusting() { return false; }
              public void addListSelectionListener(ListSelectionListener x) {}
              public void removeListSelectionListener(ListSelectionListener x) {}     
    table.setSelectionModel(new NullSelectionModel());no need to edit? simply use setEnabled(false);
    cheers !!
    //Ref: http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=2&t=017662

  • Multi Jtable row selection

    I am trying to allow a multi Jtable selection :
    In a JPanel, boxlayout, I have many Jtables aligned with the Y AXIS (one below the other). They have the same model and what I want is to be able, when I drag an area with the mouse, to select all the rows that are into this area event if the area covers many JTables.
    In other words, the user must be able to select rows from differents Jtables as if there was only one Jtable at all.
    Do seomeone has an Idea ?
    chmurb

    I must be doing something wrong as both not working for me...:
    On the change width - no effect at all:
            Table temp = new Table(cust.getData() , vtrColumn );
            TableColumnModel col = temp.getColumnModel();
            TableColumn tcol = col.getColumn(0) ;
            tcol.setPreferredWidth(10); // tried any other number as well...
            rtrvTable.setModel(temp.getModel());
            rtrvTable.repaint();and on the remove column - it removes it completly - not only hiding it, so I cannot get the value at the column (which I need as it is the PK of the tabe)
            JTable temp = new JTable(cust.getData() , vtrColumn );
            rtrvTable.setModel(temp.getModel());
            TableColumn col0a = rtrvTable.getColumnModel().getColumn(0);
            rtrvTable.removeColumn(0);
            System.out.println(temp.getWidth());
            rtrvTable.repaint();Is there a way only to hide it? if I can set the with to very nerrow - that can be good enough I think....

  • JTable row selection

    What technique would you recommend to programmatically select one or more rows in a basic JTable?

    I used addRowSelectionInterval to get multiple selections. Your note directed my attention to the proper method(s). Naturally I overlooked it on several occasions. Thank you DrClap.

  • JTable - loosing focus without tabbing out

    Hi all,
    I have a JTable and when the user goes to enter some text in a field I would like the value entered to persist to the underlying object as soon as the text is changed. This is without the user tabbing out of the JTable.
    Currently when a value is changed and the user hits a save button the value is not saved as the focus is still in the table, it all works fine as soon as the user enters the new value and tabs out of the table and then selects save,
    Does anyone have any suggestions?
    THanks,

    This can be done via your own TableCellEditor class. Create a TableCellEditor class. Implement KeyListener in this editor to save whenever the data is modified.
    You can set the default editor via setDefaultEditor() on JTable.

  • Multi JTable line selection

    Hi,
    How can I get the values of selected rows / columns when more than 1 at a time?
    Wha I need is the following:
    cell. What I am looking for is the values of
    multiple cells as follows:
    Col1 Col2 Col3 Col4 Col5
    row1 A B C D E
    row2 F G H I J
    row3 K L M N O
    row4 P Q R S T
    row5 U V W X Y
    when I select (highlight) any number of rows - i
    want the values in
    the left most column of all these rows. In the above
    example I should get:
    var1 = A
    var2 = F
    var3 = K

    I must be doing something wrong as both not working for me...:
    On the change width - no effect at all:
            Table temp = new Table(cust.getData() , vtrColumn );
            TableColumnModel col = temp.getColumnModel();
            TableColumn tcol = col.getColumn(0) ;
            tcol.setPreferredWidth(10); // tried any other number as well...
            rtrvTable.setModel(temp.getModel());
            rtrvTable.repaint();and on the remove column - it removes it completly - not only hiding it, so I cannot get the value at the column (which I need as it is the PK of the tabe)
            JTable temp = new JTable(cust.getData() , vtrColumn );
            rtrvTable.setModel(temp.getModel());
            TableColumn col0a = rtrvTable.getColumnModel().getColumn(0);
            rtrvTable.removeColumn(0);
            System.out.println(temp.getWidth());
            rtrvTable.repaint();Is there a way only to hide it? if I can set the with to very nerrow - that can be good enough I think....

  • Loosing selection...

    Dear Java Gurus,
    Again I have a question. The path to Jedi is a looong one :-)
    I am playing around with a default editor kit and a JTextPane/JTextArea. When I select text
    inside the text area everything works just fine, but when the text area looses focus, the
    selection is cleared. I have noticed that that is not the behaviour in other tools and the
    selection is only lost once you create a new one.
    What setting or magic do I need to perform to avoid loosing the text selection when my editor
    looses focus?
    The reasons I am asking is that if I want to implement a button for let's say cutting the
    selected text, the selection is lost just when I press the button, leaving nothing to cut out :-)
    Quite silly :-)
    Please help a confused soul?
    Best regards,
    X.

    Try to set buttons focusable property false

  • Change of Jtable feature select in 1.5?

    I have a JTable Object, with 12 columns and 32 rows.
    when the user want to populate the first eight rows there is no problem, they begin ant the rown 0 column 0, But when the user want to capture only from the 9 to 16 row, they select those range, but until the version 1.4.2, the cursos was positioned in the first row&colum selected.
    But after jdk 1.5.x, the cursor focus focus is in the last row&column selected..
    How can I make that the first position select get the focus in the JTable?
    In other worksheet have this feature, fouc son the first colun&row selected.
    why Java change it?
    Please help me out.

    The problem is not how to select an interval.
    The problem is the position of the cursor when finalizing the selection of an interval.
    In the versions prior at the 1.5 was positioned at the beginning of the selection and not to end.
    But since version 1.5, the focus on the table have the last position selected.
    Look the excel feature or another worksheet, and the focus always is the first cell selected.
    Thnaks

  • JTable about Selection Mode

    I need to implement a new selection mode similar to MULTIPLE_INTERVAL_SELECTION but every time the user clicks on the table the entire column must be selected (or deselected if the column was selected before) and the other columns must stayed selected as If control key was pressed without being pressed! Does anyone know how to figure this out?

    I have figured it out in a different way... The problem is the way the screen is refreshed... do you know a way to solve this issue?
    package mytables;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import javax.swing.DefaultListSelectionModel;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.ListSelectionModel;
    public class UsingJTable extends JFrame {
        private JPanel panel;
        private JTable table;
        private ListSelectionModel csm;
        JScrollPane scrollPane;
        boolean[] columnIsSelected;
        DefaultListSelectionModel lsm;
        public UsingJTable() {
            table = new JTable( new MyOwnTableModel() );
            table.setRowSelectionAllowed( false );
            table.setColumnSelectionAllowed( true );
            table.setSelectionMode( ListSelectionModel.MULTIPLE_INTERVAL_SELECTION );
            scrollPane = new JScrollPane( table );
            panel = new JPanel();
            panel.setOpaque( true );
            panel.add( scrollPane );
            columnIsSelected = new boolean[ table.getColumnCount()];
            csm = table.getColumnModel().getSelectionModel();
            table.addMouseListener( new MouseAdapter() {
                public void mouseClicked(MouseEvent e)
                    int index = UsingJTable.this.csm.getLeadSelectionIndex();
                    columnIsSelected[ index ] = !columnIsSelected[ index ];
                        if( columnIsSelected[ index ] )
                            table.removeColumnSelectionInterval( index, index );
                            for(int c = 0; c < columnIsSelected.length; c++ )   
                                if( c != index && columnIsSelected[ c ] )
                                    if( csm.isSelectionEmpty() )
                                        table.setColumnSelectionInterval( c, c );
                                    else
                                        table.addColumnSelectionInterval( c, c );  
                            table.addColumnSelectionInterval( index, index );
                        else
                            for(int c = 0; c < columnIsSelected.length; c++ )   
                                if( columnIsSelected[ c ] )
                                    if( csm.isSelectionEmpty() )
                                        table.setColumnSelectionInterval( c, c );
                                    else
                                        table.addColumnSelectionInterval( c, c );
                            if( csm.isSelectionEmpty() )
                                table.setColumnSelectionInterval( index, index );
                            else
                                table.addColumnSelectionInterval( index, index );
                            table.removeColumnSelectionInterval( index, index );
                    for(int c = 0; c < columnIsSelected.length; c++ )
                        System.out.print( columnIsSelected[ c ] + " " );
                    System.out.println();
                    int selectedColumns[] = table.getSelectedColumns();
                    for(int c = 0; c < selectedColumns.length; c++ )
                        System.out.print( selectedColumns[ c ] + " " );
                    System.out.println();
            this.setTitle( "Using JTable" );
            this.getContentPane().add( panel );
            this.setSize( 500, 500);
            this.setVisible( true );
            this.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        public static void main( String args[] )
            new UsingJTable();
    }

Maybe you are looking for

  • How can we assign a different scope of planning in MTO scenario?

    Hi, We are using MTO scenario. In this case, during sales order creation checking control AE is getting triggered. We want to use a different scenario during rescheduling transaction. But as per my analysis, V_V2 is also calling the same AE checking

  • Getting the ID of the page that is running an iView in EP5

    Hello, As stated in the topic, I'm using EP5. How can I get the ID of the page that is currently running an iView from within the iView code? Thanks ahead for any help, Yoav.

  • Why is the photo quality poor when view on TV?

    Before I burn a slideshow on a dvd I check to see the quality of my images and they look perfect on my mac however, the quality is greatly reduced when I watch a photo slideshow on a TV. This has occurred for one than 1 tv also (all pretty new). Any

  • Print sales and delivery no

    HI ALL MY problem is that how can we print sale order and delivery no  on a/r invoice . we can print base docnum but  we want both no  so and delivery . Let we create a sales order no is 19 and through it we  create deliver note no 25 and through del

  • Make my files move with the Finder window?

    I don't know how many of you are familiar with Windows, but in Windows Explorer, whenever you changed the size of the window you were viewing your files in, the files would move with the size of the window while still staying in the same order. When