Cell border removal in JTable

I've created a JTable with a DefaultCellRenderer. I need a way of removing the border that appears around each cell(deafult yellow colour) and instead replace it with no border or a border that goes around the entire row. Any ideas?

add this to your code, just after you create the table:UIManager.put("Table.focusCellHighlightBorder", BorderFactory.createEmptyBorder());

Similar Messages

  • JTable cell border color

    Hi All,
    How do i change the JTable's specific cell border color and set the cursor into that cell.
    Thanks.

    Write your own renderer.
    [Look at this example.|http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=2&t=004710]

  • Removing a JTable border

    Hey, I want to be able to remove the border from a JTable.
    I have tried:
            JTable newTable = new JTable(table, columnHeaders.toArray());
            newTable.setPreferredScrollableViewportSize(new Dimension(400, 70));
            if (!border) {
                Border empty = new EmptyBorder(0,0,0,0);
                newTable.setBorder(empty);
            }and it doesn't error, but it doesn't remove the border either.
    Any ideas? Thank-you in advance.

    Sorry for wasting your time, I already have an answer (due to double posting - again, sorry).
    For anyone interested, the response can be seen at:
    http://forum.java.sun.com/thread.jspa?messageID=9549034
    Thank-you for looking.

  • Selected Table Cell Border in 1.4.2

    Hi All!!
    I am facing a problem with JDK 1.4.2_01 & Windows L&F. I am unable to see the yellow border around the selected cell in JTable. Was working fine with 1.4.1_03.
    A bug with id: 4674205 was reported with 1.4.0 stating :
    " In the Windows Look and Feel, the selected cell in a JTree or JTable is framed with a yellow rectangle. To accurately match the real Windows UI, it should be a black and white dotted rectangle instead. (This was part of bug 4268204,which was marked fixed, but this part hasn't been fixed.) This behavior was fixed for JList, but not JTree or JTable. "
    Now it has been fixed and closed.
    May be they might have removed setting of yellow border for the selected cell to match with native windows UI.
    But selected cell border is very much necessary for my project. Can any one please suggest me a workaround.
    With Regards,
    LRK

    Hi Sai!
    Thanks for your reply. It will not be feasible in my application as it already has huge number of tables with some of them already having complex renderers and editors.
    I was looking at something which i can set globally so that it will reflect to all of the tables in the application in a particular L&F.
    I tried setting
    UIManager.getDefaults().put("Table.focusCellHighlightBorder",Color.yellow);
    and
    UIManager.put("Table.focusCellHighlightBorder",Color.yellow);
    But no luck.
    Any other inputs are most welcome.
    With Regards,
    LRK

  • Cell editor removed when table resized

    I'm using Java 1.5.0_06 in my application. I have a JFrame which contains a JTable. I use FormLayout (which is like GridBagLayout). When the frame resizes, the table resizes too.
    When I enter edit mode in a cell of the table and resize the frame (and the table), the cell exits edit mode. The editor of the cell is removed when the table is resized which causes the value that I had entered in the cell to be lost.
    Is there a way to stop cell editing when the frame is resized instead of the cell just exiting edit mode.
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.table.DefaultTableModel;
    import com.jgoodies.forms.factories.FormFactory;
    import com.jgoodies.forms.layout.CellConstraints;
    import com.jgoodies.forms.layout.ColumnSpec;
    import com.jgoodies.forms.layout.FormLayout;
    import com.jgoodies.forms.layout.RowSpec;
    public class ResizableTableTest extends JFrame {
         final JScrollPane _scrollPane;
         public static void main(String[] args) {
              ResizableTableTest frame = new ResizableTableTest();          
                frame.addWindowListener(new WindowAdapter() {
                     public void windowClosing(WindowEvent e) {
                          System.exit(0);
                frame.setSize(451, 340);
                frame.setVisible(true);
         public ResizableTableTest() {
              super();
              getContentPane().setLayout(new FormLayout(
                   new ColumnSpec[] {
                        new ColumnSpec("default:grow(1.0)"),
                        FormFactory.RELATED_GAP_COLSPEC,
                        FormFactory.DEFAULT_COLSPEC},
                   new RowSpec[] {
                        new RowSpec("default:grow(1.0)"),
                        FormFactory.RELATED_GAP_ROWSPEC,
                        FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC,
                        FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC,
                        FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC,
                        FormFactory.DEFAULT_ROWSPEC}));
              _scrollPane = new JScrollPane();
              getContentPane().add(_scrollPane, new CellConstraints(1, 1, CellConstraints.FILL, CellConstraints.FILL));
              addTableToScrollPane();
         private void addTableToScrollPane() {
               JTable table = new JTable();
             DefaultTableModel model = (DefaultTableModel)table.getModel();
             table.setRowSelectionAllowed(false);
             table.setCellSelectionEnabled(true);
             //Add some columns
             model.addColumn("column A");
             model.addColumn("column B");
             model.addRow(new Object[]{"item1", "apple"});
             model.addRow(new Object[]{"item2", "banana"});
             model.addRow(new Object[]{"item3", "carrot"});
             model.addRow(new Object[]{"item1", "grape"});        
             _scrollPane.setViewportView(table);          
    }thanks,

    I would assume that on the resize of the table the
    editing cancelled event is being fired...
    You could try overriding the method in the JTable and
    when it gets fired, fire the editing stopped method
    instead... not sure whether that will work thoughI tried that, but it didn't help. On searching for this problem, I saw a bug report on this very problem.
    Here's info on a related bug in java:
    Cell editing does not complete when JTable loses focus
    Lost newly entered data in the cell when resizing column width
    And here's an interesting article:
    Why Editable Table Cells Are Evil
    Message was edited by:
    petes1234

  • Cell border not appearing in Adobe forms

    Hi,
    We Placed a button in internal table cell and itu2019s property is set to invisible.
    This button is set to visible based on value of other column value in the same row of table.
    But border for the cell is not coming when button is invisible.
    Note: the button size is equal to cell size and so when we make the button invisible ,the cell border itself is not appearing as the whole cell is invsible.
    How make the cell border visible even the button in that cell is invisible.
    Please put your suggestions in this regard.
    Regards,
    Kranti Yamparala.

    Hi Kiran,
    Please go through the below link:
    http://help.sap.com/saphelp_nw70/helpdata/en/45/2dbb13d79f3446e10000000a155369/frameset.htm
    Here the method to hide the toolbar is given. Try passing ABAP_FALSE in method: lr_method_handler->set_hide_toolbars( abap_false ) if it works.
    Regards,
    Vaibhav

  • Cell Border Line Weight

    I would like to use different Line Weights on spreadsheet cell borders, but no matter what Line Weight I choose from the Accents window, I always get (both visually and printed) the same Line Weight (hairline?) when I set a cell border. Am I missing something?

    I didn't enter the system details because the problem appeared on all the (different) systems I tried: iBook G4 (OS X 10.3.8), iMac G4 (OS X 10.3.9), iMac G5 (OS X 10.4.?), AppleWorks 6.2.7 and 6.2.9. I understand the need in general, but since this problem persisted across all these platforms, I thought that it would either be a well-known usage problem or bug (even though my best efforts could find no mention of it).
    Thanks for your response.
    Pete

  • Cell border with categories not possible?

    Several tables in my worksheet. Those without categories... I can format cell borders. Those with categories, no way. Can't select cell borders or apply line effects to a manually-selected cell border. Is there a workaround?

    You are right. I also discoverd that .NET has an implementation for this. Well, I hate to resort to .NET but have no choice.

  • How to create a dashed line for cell border

    Hi,
    Is anyone know How to apply the style for cell border to get the dotted line in WinRT 
    In WPF i will get the dotted line for cell border using this way.
    <DrawingBrush Viewport="0,0,20,20" ViewportUnits="Absolute" TileMode="Tile">
    <DrawingBrush.Drawing>
    <DrawingGroup>
    <GeometryDrawing Brush="Black">
    <GeometryDrawing.Geometry>
    <GeometryGroup>
    <RectangleGeometry Rect="0,0,50,50" />
    <RectangleGeometry Rect="50,50,50,50" />
    </GeometryGroup>
    </GeometryDrawing.Geometry>
    </GeometryDrawing>
    </DrawingGroup>
    </DrawingBrush.Drawing>
    </DrawingBrush>
    Thanks in Advance,

    check this thread: 
    http://stackoverflow.com/questions/14673643/windows-store-apps-how-to-draw-a-dashed-line
    Fouad Roumieh

  • Smartforms - Is it possible to Customize Cell Border In Template in 4.6C

    Hi,
    In smartforms, i know that Customizing Cell border is possible with node type TEMPLATE in version 6.20
    Our system is 4.6C
    But there are many differences between 4.6C and 6.20 about SMARTFORMS.
    Is there a way to specify custom cell border without "Select Pattern" option with node type TEMPLATE in 4.6C
    thanks
    ibrahim

    Hi,
    As you identify there are some large differences between Smartforms in 4.6c and 6.20.  So there is no equivalent of the cell-specific borders in 4.6c
    Regards,
    Nick

  • Just update to Pages 5.1 - its dropped the pictures from my Pages files - 'Some features aren't supported - objects in table cells were removed' - how do I get pictures back?

    Just update to Pages 5.1 - its dropped the pictures from my old Pages files - 'Some features aren't supported - objects in table cells were removed' - how do I get the pictures back?

    Thanks Peter
    Can you just walk me through dumping Pages 5 and getting to the Applications/iWork folder - and does this mean that when I see future Pages Upgrades I should block them?
    I'm new to Apple so need a step by step
    Many thanks
    Glyptic

  • When I open an old pages doc in new pages 5.0 objects in table cells are removed. how can I stop this?

    When I open an old pages doc with new pages 5.0 - objects, specifically pictures, in table cells are removed. Is there a way I can stop this?

    nigel32,
    Gavin is right.  You are bound to lose images in tables of docs made in previous versions.  If you wish to continue using Pages 5.0 to edit docs from previous versions, you can try re-inserting your images using the following method:
    1.  Click on the cell you want to insert to.
    2.  Select CELL on the right contextual menu.
    4.  Click on FILL and select IMAGE FILL.
    5.  Click CHOOSE then select the image you need from Finder.
    6.  Tweak the appearance using the SCALE slider or drop down menu.

  • Display the background of table row alternatively and hiding cell border

    Hi all,
    I am trying to display the background of the table using different color alternative and at same time I need to hide the border of all cells.
    What I found in <af:table> is using bandingInterval="1" banding="row", but how can I set the background color? And how to hide the cell border?
    Or if there is a thing like row index so that I can mod it like rowIndex%2==0 in every column to determine the inlineStyle?
    Thanks.
    Shawn

    <af:table value="..." var="row" varStatus="status">
      <af:column inlineStyle="#{status.index % 2 > 0.5 ? 'border:none;' : ''}">
      </af:column>
    </af:table>For some reason, EL operation always seems to return a double, so the condition has to be defined with that in mind.
    Regards,
    ~ Simon

  • Tab between cells and Editor in JTable

    I placed a cell editor in a JTable column JTextField.
    After I type something in this editor and press tab it stays in the same cell and when I press tab again then it goes to the next column.
    How can I correct this so that after I type something in the cell and press tab I want it to go to the next column directly in JTable.
    Thanks.

    I'd have to see your code to tell you what's wrong. I tried it this way and had no problem.
    TableColumn tc = table.getColumnModel().getColumn(2);
    tc.setCellEditor(new DefaultCellEditor(new JTextField()));by the way, I don't think you need to explicitly set the cell editor component to JTextField. It uses that by default.

  • Tab between cells and celleditor in JTable

    I placed a cell editor in a JTable column JTextField.
    After I type something in this editor and press tab it stays in the same cell and when I press tab again then it goes to the next column.
    How can I correct this so that After I type something in the cell and press tab I want it to go to the next column directly in JTable.
    Thanks.

    I'd have to see your code to tell you what's wrong. I tried it this way and had no problem.
    TableColumn tc = table.getColumnModel().getColumn(2);
    tc.setCellEditor(new DefaultCellEditor(new JTextField()));by the way, I don't think you need to explicitly set the cell editor component to JTextField. It uses that by default.

Maybe you are looking for