How to remove cells interection line in JTable

Hello
I am new to Java Programming
I am facing a problem which i did not know how to solve so i need help from experts of this forum
I have JTable of lets say 5 columns and from that i want to hide some columsn e.g i want to get only column 0(or ist column) and column 5(5th column) visible to me and not the inbetween columns(i.e 2,3,4) so i coded it like this:
for(int count=0;count< ConnectedDrivestable.getColumnCount();count++)
               tcm = ConnectedDrivestable.getColumnModel();
               cm=tcm.getColumn(count);
              if( count==0 || count==4)
                   cm.setPreferredWidth(15);
               cm.setMinWidth(0);                   
                   cm.setMaxWidth(15);                   
              else {
                   //ConnectedDrivestable.removeColumn(cm);
                       //ConnectedDrivestable.removeColumn(tcm.getColumn(count));
                   cm.setPreferredWidth(0);
               cm.setMinWidth(0);          
                   cm.setMaxWidth(0);
          }where ConnectedDrivestable is my JTable of lets say 5 rows and 5 columns
tcm is TableColumnModel and cm is TableColumn object
But the problem is that i am getting vertical line in between and that is the intersection line of column 1 and column 5(i.e the intersection line of two columns that are visible) i dont want this in between vertical line to appear
I really dont know how to fix this problem i have searched on internet but unable to find the appropriate solution to it
Also as shown in my code i tried to work with removeColumn method which documentation says should remove the desired columns but i dont know why it is not functioing for my case the way i acpected am i doing something wrong or?
So urgent help from people here is required
Thanks in advance
Imran

Hello
Thanks for reply and thanks for help
Do please tell me that i am rendering cells of JTable with JLabel it is working fine but i want to span JLabel onto multicells in the same row
Second i want to change the size of JLabel so that if not needed JLabel did not cover the whole Cell
A bit of code which i am using to do cel rendering is attched for your kind considerations
ConnectedDrivestable.getColumnModel().getColumn(1).setCellRenderer((new  DefaultTableCellRenderer ()
               public Component getTableCellRendererComponent(JTable table, Object value,
                         boolean isSelected,
                         boolean hasFocus,
                         int row, int column)
                    JLabel Jlbl=new JLabel();
                    if(row==2)
                         ((JComponent)Jlbl).setOpaque(true); //if comp is a JLabel:Necessary
                         //Jlbl.setBorder(BorderFactory.createLineBorder(Color.BLACK));
                         Jlbl.setBackground(Color.GREEN);
                         Jlbl.setLocation(row,column);
                         System.out.print("The Column number is : "+column);
                         System.out.print("The answer is: "+ column+2);
                         ((JComponent)Jlbl).setMinimumSize(new Dimension(1,1));
                         ((JComponent)Jlbl).setMaximumSize(new Dimension(0,0));
                    return Jlbl;
                    //return comp;
          }));Another piece of code which i got from internet for doing the same is
ConnectedDrivestable.getColumnModel().getColumn(2).setCellRenderer((new  DefaultTableCellRenderer ()
               public Component getTableCellRendererComponent(JTable table, Object value,
                         boolean isSelected,
                         boolean hasFocus,
                         int row, int column)
                    Component comp = super.getTableCellRendererComponent
                         (table, value, isSelected, hasFocus, row, column);                         
                    //((JComponent)comp).setBorder(new LineBorder(Color.BLACK));                         
                    if(row==2 && column==2)
                         //((JComponent)comp).setBorder(new LineBorder(Color.BLACK));
                         comp.setBackground(Color.GREEN);
                         ((JComponent)comp).setMinimumSize(new Dimension(1,1));
                         ((JComponent)comp).setMaximumSize(new Dimension(1,1));                                   
                    else
                         comp.setBackground(Color.white);
                    return comp;
          }));These both work but as i tried to change the size of JLabel in the Cells it did not work also if i wanted to span JLabels to multiple cells(Column) is it not working
Also as in code snippet i am trying to set the border which works fine but what i want is that after spanning JLabel to multiple cells then i want border along this how to do this help in this regard too?might if i could span JLabel to diffrent columns might i able to set border aroung them too
I am putting under old forum topic this question as it is realted to my same problem so do please apologize me.
I do need urgent help in this regard so kind help is needed
Regards

Similar Messages

  • How to remove the black line from a stacked canvas at run time???

    Hi All,
    I've developed a stacked canvas within a content canvas, when I run the form the stacked canvas apeared with a black line takes it.
    How to remove this line or how to disappear this line at run time??
    I tried to do this by putting (no line) in tools palette to the line color tool after selecting the black line one and after selecting the stacked canvas another once, but this did not resolve the problem!
    I need something else:
    I put the stacked canvas at detail data block and it didn't appear since I execute query in master data block
    How to appear the stacked canvas directly before executing query in master data block???

    Hi,
    u mean the border line? In stacked canvas property, select contour/outline and set it to none.
    Make sure, the stacked canvas is behind the content canvas in the objectnavigator. Then check your
    properties of the stacked canvas:
    - Position on content canvas
    - size
    - size of clipping
    Set stacked canvas property automatic visible to yes.
    Make sure the stacked canvas is not overlayed by other stacked canvas or items.
    Attackwave

  • How to remove dotted green lines in pages 5.2 documents?

    How do i remove dotted green lines in Pages 5.2 documents?

    That's right. Use Pages '09.
    You can export to Pages '09 from Pages 5.2.
    Peter

  • How to remove the blank lines at the end of the JTextArea .

    Hi,
    I need to remove the blank lines in the JTextArea at the end. Suppose i am giving 'A' in the first line and press the enter key two times, after i am giving the 'B' in the third line and press enter key for two times. I need to remove, the last two lines of JTextAreae, . How i can remove these lines?

    String#trim() removes all whitespace from both ends of the String.
    The requirement was to remove line breaks from the end of the String only.
    String#replaceAll with a suitable regex would do the trick. Untested regex for this:text.replaceAll("[\\n\\r]+$", "")db

  • How to remove the thick line at the end of each page of my report

    Please how do I remove the thick line that appears at the end of each page of my report anytime I publish the report unto the Web.

    Bring up the property inspector against the report object. In here you will see the settings for HTML output. Remove the entry against the "After Page Value" property.

  • How to remove the gray line in JDeveloper?

    Hello,
    I'm working with JDev now.Now I'm facing a problem, when I want to format my codes in JDev I find many lines of code changed to double. I also notice that the point for newline is the gray line in the coding area.
    Now I want to remove the gray line or move it more right so I can format my codes really more beautiful.
    If there is anybody knows the way,please show me how to deal it.Thank you.

    Sorry,your answer has not figure my issue. The link you gave me does not contain my question.Thank you for your answer.

  • How to Remove the Last line of Instance in subform ?

    I thought I ran across an example in this forum of how to specify which instance you want to delete from a subform but I can not find it. I can get removeInstance to work but it removes the top line and I just want it to remove the bottom or last instance that was added. I can do it if I only had 2 instances and tell it to removeInstance(1); but the form is going to be dynamic and there will be more than 2 lines when people start to use the form.

    I've found the reason... :-)
    I'm using the designer from Acrobat professional instead of the designer from Adobe LiveCycle.
    I've got Acrobat professionnal 7.0.0 and trying your sample it didn't function.
    Knowing that there was a new version of Acrobat professional (7.0.7)I've installed it, and now your sample function.
    I have to mention that the count method is not listed in the choice menu that appears when you're typing code inside the designer. It means that some functions have to be tryed even if the popup menu of the list of available methods doesn't mention it.. (in this case it's the count method)... :-)
    There are a lot of things like that (for example there is the checkbox problems that are not good managed before Acrobat Reader 7.0.7, and Acrobat professional 7.0.7)
    So I suggest to the developpers that are reading this post to always install the last version of Acrobat Reader, Acrobat Professionnal, Designer, in order that everything goes well with the product.
    gpalmieri

  • How to Remove the Vertical Line in Forward Mail

    when using apple's mail program how do I remove the vertical line when I forward email ?
    Thanks

    If you are doing this on an iPhone:
    For forwarding or replying to an email without the Blue Vertical line to the left of the text...
    - Open the email
    - Select Forward or reply (this will open a new window)
    - Select All of the text in the new email.
    - In the pop-up bar that says "cut, copy, paste" select the right arrow for more options.
    - Select Quote Level
    - Select Decrease
    Voila!

  • How to remove the last line of  SUBTOTAL_TEXT ?

    i have used this event but i am totaling displaying at bottom rather than total i am getting another line 
    that i no need so given a some idea a if possible give some code.
    it like as:
    saleso  item no quan  net amt
    5063        10       47.23   554.23
    5063         20      40.00   665.25
    TOTAL                87.23    1219.48
    ---> iam getting extra line  want to delete it give me some solution.
    thanks to all,
    shabeer ahmed

    >5063 10 47.23 554.23
    >5063 20 40.00 665.25
    >TOTAL 87.23 1219.48
    >---> iam getting extra line want to delete it give me some solution.
    what is that extra line, is it total line..?
    if You want to remove the total line
    layout-no_totalline = 'X'.

  • How to remove end of line from string?

    Hello,
    I'd like to remove ends of line from the string. I've tried:
        static final Pattern END_LINE_PATTERN = Pattern.compile("$+");
        strBuf.append(input);
        Matcher m = END_LINE_PATTERN.matcher(input);
        int startIndex = -1;
        int endIndex;
        while (m.find()) {
         startIndex = m.start();
         endIndex = m.end();
         if (endIndex == strBuf.length() - 1) break;
        if (startIndex > -1) {
         strBuf.setLength(startIndex);
        }For strings "hello\n" and "hello\r" it works properly, but for string "hello\n\n" I get first occurrence at index 6 (at second \n), so as the result I get "hello\n". For the string "hello\r\n" I get first occurrence at index 5 (it's OK), but the end index is 5 as well, and the next occurrence I get at index 7, which doesn't give me any sense.
    Hope somebody can help me.
    Agata

    What you're trying to do is remove one or more line separators from the end of a string ("\n", "\r", and "\r\n" each count as one line separator, but "\n\n" is two line separators). This is all you need to do: str = str.replaceAll("[\r\n]+$", ""); "$" doesn't match any characters, line separators or otherwise; it matches the position at the end of the string. In MULTILINE mode, it also matches the position before a line separator, but it still doesn't match the separator itself.

  • How to remove a service line item from a service related PO

    Guys,
    I am doing a report thro' which a user can upload the details for a Service related PO. If the PO contains more Service Line Item than the upload file, then I want to remove those Service Line Items. I used BAPI_PO_CHANGE to upload the details. But I am trying to remove those additional Service Line Items using BDC in ME22 transaction. But it is not working correctly. Is there any program(s) thro' which I can remove those Service Line Items? Any expert thoughts....
    Advance Thanks
    Ramesh

    I did it through BDC.

  • How to remove effect of defaultHighlighter in JTable ???

    I am working on code of "find"(ctrl+f) function , which ll highlight the 'search keyword' after clicking on 'find/find All' buttons...
    eg. - If text in cell is "I Love My India" .. if search keyword is "Ind" then it ll highlight that particular characters only....
    Now I want to deselect(ie. it should not be highlighted) the highlighted word.
    How do I do this???
    [ I have used tableCellRenderer  & defaultHighlighter to highlight the search  keyword ]
    Thanks in advance
    Suyog

    I have used these classes to highlight keyword inside the JTable cell...Like I said there is no such thing as a "default highlighter" for a JTable.
    The default renderer for a table is a JLabel. As I told you in your other posting a JLabel does not support a "highlighter".
    So it would appear that you are now using a JTextField as a renderer. This means you have written custom code to do the highlighting, so you should be able to modify your code to remove the highlighting.
    I just want to know is there any ready made method or trick to remove highlight effect...The trick would be to read the API that you quoted. I would guess the "remove" methods would do what you want.

  • How to remove a row from a jtable with DefaultTableModel

    Hi to all,]
    I want to remove a row from jtable. I am using DefaultTableModel.
    I have got some example but every example is given with AbstractTableModel
    Please help me...
    Thanks and Regards

    I want to remove a row from jtable. I am using DefaultTableModel.How do you program without reading the API.
    The name of the method you use is "removeRow". How hard is that to find by reading the API?
    Not only do you not bother to read the API, you don't even bother to read and respond to your old postings when you get help:
    http://forum.java.sun.com/thread.jspa?threadID=5137773
    http://forum.java.sun.com/thread.jspa?threadID=5134667
    http://forum.java.sun.com/thread.jspa?threadID=5131162
    Your on your own in the future.

  • IOS XR - How to remove a comment line?

    Hello
    I've got the following comment lines in my Router config.  Would anyone advise how I can remove those lines?
    router static
    address-family ipv4 unicast
      !* 203.117.111.65/32 GigabitEthernet0/0/0/0 116.0.67.133
    !* 218.213.224.16/28 GigabitEthernet3/40.2265 218.213.250.242
      !* 218.213.224.32/28 GigabitEthernet3/40.2263 218.213.224.206
    Thanks.
    Adrian

    You can use:  "clear comment".
    http://www.cisco.com/c/en/us/td/docs/routers/xr12000/software/xr12k_r3-9/system_management/command/reference/yr39xr12k_chapter5.html#wp227891472
    Ricardo

  • Second request; How canyou remove a power line with PS CC?

    Hi,
    I konw there is a terrific new feature in PS CC (I have used it before!) but I just can't find any explanation on how to to do it!
    The question is how do you remove, from an imge, a power line, or a telephone line by symply clicking on both ends of those lines in order to remove them?
    Thanks
    Serge

    Hi,
    Thanks to you and others on this.
    They all finally brought me to the solution even by haphazard ways.
    It turns out the the feasture was able under PS CS5 (which I didn't have).
    However the feature under cc is slightly different and here it is FWIW.
    1) Use the Spot healing brush tool
    2) Make sure the content awareness is checked.
    3) I checked also "sample all layers"
    4) clik on one end
    5) clic on the other end with shift-click
    and the nasty little wire is gone.
    I don't understand why such a neat feature like this is still not much advertised.
    Regarss
    Serge

Maybe you are looking for