Ask for suggestion: merge cell or multiple jtable

I would like to have a jtable like this:
+----------+------+------+------+-----+
| 1.Item no|2.Desc|3.Type|4.Size|5.Qty|
+----------+------+------+------+-----+
|    001   |  ... |  A1  |  3   |  5  |
|          |      |------|------|-----|
|          |      |  A2  |  2   |  6  |
+----------+------+------+------+-----+
|    002   |  ... |  A1  |  4   |  4  |
|          |      |------|------|-----|
|          |      |  A3  |  2   |  6  |
+----------+------+------+------+-----+For each item, it would have say, 2 types (2 rows beginning from the third column).
The question is, I'm now considering whether 1)i should use multiple jtables, one from column 1 -2 and the other from column 3 to 5. OR 2)merge cells
In fact, i just have thought of this 2 methods and not yet implemented them yet. Any suggestion?
Many thanks,
Pippen

Thanks thahn2 but I 've tried out the examples before and found them not so useful for me. And some of them even have problems running on jdk1.4.
Any suggestion on either choice will be welcomed. (or even other suggestions)

Similar Messages

  • Asking for Suggestions

    I am here to ask for suggestions as to approach with Verizon Wireless as to an error they made that they want me to pay for.
    You see, I send my payment on the 1st business day of the month, every month, even though the bill is not due until the 17th of the month.  Twice now, Verizon Wireless has not credited my payment to my account - even though the check clears my bank (with a Verizon Wireless endorsement) within 5 - 6 calendar days from check date.  I do not realize that the payment, which clears, is not properly credited to my Verizon Wireless account until the next bill is accessed and a $5 late fee is assessed.
    In July, I paid my bill on July 2, and the payment cleared the bank on July 7.  The endorsement was, in fact, Verizon Wireless.  When I received my bill at the end of July, it did not show payment and included a late fee.  I called immediately and was assured that the error would be fixed.  I paid the current amount (minus the $5 late fee) and went on my merry way.  Now, because in February of this year this happened, and all went well, I assumed that it would go well this time.  BIG MISTAKE. 
    Fast forward to the end of August.  STILL a past due (for the payment made July 2) PLUS that $5 late fee from the original "non-payment" PLUS an additional $5 late fee for the continued "non-payment."  Coming uncorked, I call Verizon Wireless again.  Basically was treated....poorly (that is being kind as to not be offensive).  And, when I explained what happened, was transferred to an immediate payment person to "take care of paying [my] past due account."
    It took seven days, but I finally got it through to Verizon that the bill had been paid.  And the account was credited the payment. 
    But
    Now the late fees are showing past due.  In my perspective, I do not owe one penny in late fees because the darn bill was paid ahead of due date.  And I won't pay one darn penny more than was used.
    So, any suggestions from any of you who may have had a similar situation where you may have gotten late fees reversed?  I am at a loss.
    Oh, yes.  The plan is being switched to that other wireless service provider because I am done with this.....
    Any suggestions would be most appreciated.

    thanks for responding
    before traveling to the Bahamas I contacted VerizonWireless and was told to make the changes which I did what wad not relayed was the fact that Verizon did not have service there and every minute would be roaming. My thought was that at best the cost would not exceed $40.00 for the 5 data which I was okay with. The most dissapointing fact was that noone could contact me and U use the phone for business also.
    This was the worst customer service that I have has since opening the account.
    I would like to see some concessions seeing how I acted totally on what was recommended by Verizon.
    Best Regards,
    Joseph
    Connected by DROID on Verizon Wirelesso

  • How to Merge Cells in a JTable?

    First, a brief background. I have a 1.3.1 Swing application, and have a custom table framework that is extended from Swing. My table model manages row classes. Each row class has its own collection of renderers and editors. Renderers and editors are never shared; each cell has its own. My custom table asks each row for the renderer/editor as needed. This allows the GUI programmer to customize every cell of a row class, down to the renderer/editor, including which cells are editable. Essentially, my custom table framework puts all the brains into row classes. Each screen has its own row class. So, it's very granular but very powerful. However, I need more power.
    I need a way to merge cells across columns (column spanning). These merged cells do NOT need to be editable for now. I don't know how I can get the table to render one cell across others in the same row. I suspect this is largely a painting issue, and could really use some help.
    Thanks!
    Andy

    Thanks for the direction, Ian! That got me on my way.
    I subclassed BasicTableUI and copy-pasted the private methods into my subclass, and made them protected. I then modified the paintCell( ) method to change the rendering for the particular table row I'm interested in (test case).
    To make the first cell span the entire row, I changed the width of the painting rectangle to be the width of the table, instead of the width of the cell. I also had to NOT render any other cells in that row, so they wouldn't "interfere" with the first renderer. In other words, if I allow cell 3 to be rendered, it will prevent cell 0 from spanning, since cell 3 is rendered AFTER cell 0.
    Here's an example of my proof-of-concept (POC):
    // For row 5, only render cell 0
    if (row == 5) {
        if (column == 0) {
            rendererPane.paintComponent(g, component, table, cellRect.x, cellRect.y, table.getWidth(), cellRect.height, true);
        return;
    }You can see that only cell 0 will be rendered, and it will be as wide as the table.
    My next step will be to experiment with multiple spans in the same row, and then having a cell in the middle span the entire row. I'll post my results for the sake of posterity.

  • Merge cells in a JTable

    Hi there,
    I'm building a class which contains a JTable, and I'd like to be able to merge cells (both rows and columns, it depends on). I've just searched help on this forum, but in many topics, answers specify a link to
    http://www2.gol.com/users/tame/swing/examples/JTableExamples4.html
    or something like that, but this link is not enabled.
    Could someone give me some help, please ??
    Thanks.

    So I found the issue, and I'm gonna talk about it, because I think many people could be interested.
    Thus, 2 lines need to be changed. Those line are identical, and are as follows :
    TableCellRenderer renderer = aColumn.getHeaderRenderer();You just have to modify it with the following code :
    TableCellRenderer renderer = header.getDefaultRenderer();Those 2 lines are located in the paintCell() and the getHeaderHeight() methods.

  • When downloading an app it asks for my apple ID password multiple times and never downloads the app

    When downloading an app on my iPad 2, it asks me to verify my account info, and when I type in my password, it does nothing except keep asking for my password.  It is not incorrect when I type it in, it just keeps asking for the password.

    Go into Settings > Store and make sure your Apple ID information is exactly as it is in your iTunes account on your computer.  Make sure your address is exactly the same.  For example if your in iTunes on your computer is 1234 Jackson Street, it can't be 1234 Jackson St., on iPad.  Make sure your credit card information matches exactly as well. 

  • Asking for suggestions as a beginner

    Hey guys, I'm new to this fantastic dreamweaver world and I've just started building my website. As a beginner, I eagerly need suggestions from you who have much more experience in terms of web designing. Here is the question bothering me since the day I started watching tutorials:
    Firstly, I could learn as detailed as I could, before I start each step. For example, before I make my spry menu bar, I could read books about it to have a thorough understanding. Then I create one and do the same preparation for the next step.
    Secondly, I could try my best to build an entire website by acquiring just the minimum knowledge about each function. After the entire structure was built, I could start looking into details and upgrade my features.
    I'm wondering which way could be more efficient: the first makes me feel confident as I carry out my construction step by step, but could be super time consuming; the second tends to be the common way for writing an article, however, as for web designing, I always have fear that I might make some fatal mistake at the beginning that couln't be corrected so I might have to rebuild the website, only finding how silly I was.
    I'm having a hard time thinking which is the better way until I realize I can ask you for help. I believe your suggesions would be much more effective than my own. Could you give me some suggesions for my problem? It would be really helpful to me.
    Looking forward to your reply!

    Hello there,
    Welcome to the forums.
    Your question is very common in most 'budding web designers/ developers'.
    My recommendation here: Dreamweaver is only an application that helps you code, it is not the 'code' itself. You should ideally begin by learning basics of CSS & HTML and a little bit of Javascript (if you're planning to do a bit more niche work). Then, start using Dreamweaver. While DW offers a lot of great support tools to help you code, it doesn't do the code itself. You should know exactly what you want before you can start creating something in DW.
    In your scenario, I'd recommend your first approach. Follow a step-by-step tutorial. Get things in place. While you're doing this, you'll learn lots more about what it is you're coding and what effect does it have on your webpage (visually). Feel free to make mistakes. That's the only way you'll learn in a self-taught mechanism.
    For starters, I'd recommend these references you can go through:
    http://www.adobe.com/devnet/dreamweaver/articles/first_website_pt1.html - This is a tutorial that guides you step-by-step  about creating your first website in Dreamweaver. Authored by David Powers - one of our senior members in this forum
    http://www.w3schools.com/css/ - Reference for CSS
    http://learncss.tutsplus.com/ - A great free resource to learn the most basics of CSS - Most recommended if you're beginning to make websites
    Also, begin here for creating a Photoshop design (for your website) which you can later code in Dreamweaver. This is very basic, but will help you understand starter concepts: http://www.youtube.com/watch?v=J4MJRhXajuw&feature=channel&list=UL - Follow all 3 parts. Once you're done with that, begin here: http://www.youtube.com/watch?v=IKeg1nhe-wE&feature=channel&list=UL - to make your Photoshop design into an actual website. This is a 6 part tutorial.
    Once you're comfortable with the basic HTML + CSS web design, you can then learn HTML5, CSS3 and jQuery concepts as this is the modern standard now. But, don't rush in! Learn the very basics first before you get into anything advanced.
    All the best.
    Feel free to post back if you need more clarifications!
    -ST

  • Tooltip for a particular cell in a Jtable

    Hi all
    I want to put a tooltip only for the cell (0,0) in my JTable.can anyone send the piece of code through which i can do it.Also i want to make this cell non-editable after or before giving the tool tip
    Prasad

    Look here
    /Patrick

  • How to merge cell in DefaultTableModel/JTable?

    I searched a lot and got some answers for this Q. but many of them referred to links which give 404 error. I want to make table like this:
    Can I make this in Java?

    looks like I'm the kucky one:
    http://www.java2s.com/Code/Java/Swing-Components/multipleRowHeaderExample.htm
    bye
    TPD

  • Merging cells in JTable...help

    Can someone give me some direction into how I can handle this....

    After hours of poking around, I figured out all i needed was an extended BasicTableUI class. With the help of tames MergedCell example, I havepulled out what I need out of his class and stripped it down alot to what I needed. hopefully this will help others also...
    package foo;
    import java.lang.*;
    import java.util.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.plaf.basic.*;
    /*This class extends BasicTableUI class which is responsible for drawing the cells in a JTable
    Functionality has been added to this class to allow a column cell to be spanned, or merged across
    the entire length of the table.*/
    See the paintRow() method to define when and how to span the cells.
    public class LogicTableUI extends BasicTableUI
         public void paint(Graphics g, JComponent c)
              //get the rectangle bounds of the current graphic to be drawn
              Rectangle oldClipBounds = g.getClipBounds();
              //makes a new rectangle the same size as the current rectangle
              Rectangle clipBounds = new Rectangle(oldClipBounds);
              //gets the width of all combined columns and assigns to tableWidth
              int tableWidth = table.getColumnModel().getTotalColumnWidth();
              //sets the width of the new rectangle to equal the either the current rect size of the table width
              clipBounds.width = Math.min(clipBounds.width, tableWidth);
              //Sets the current clip to the rectangle specified by the given coordinates
              g.setClip(clipBounds);
              //define the first and last rows that are visible
              int firstIndex = table.rowAtPoint(new Point(0, clipBounds.y));
              int lastIndex = table.getRowCount()-1;
              //define a rowRect. This is a rectangle spanning the entire visible part of the table
              Rectangle rowRect = new Rectangle(0,0,tableWidth, table.getRowHeight() + table.getRowMargin());
              rowRect.y = firstIndex*rowRect.height;
              //for every row that is visible, paint it
              for (int index = firstIndex; index <= lastIndex; index++)
                   //is the clipBounds of the current object to be drawn in this row?
                   if (rowRect.intersects(clipBounds))
                        paintRow(g, index);
                   //move to next row
                   rowRect.y += rowRect.height;
              g.setClip(oldClipBounds);
         private void paintRow(Graphics g, int row)
              //define rect as the current graphic objects bounds
              Rectangle rect = g.getClipBounds();
              //the graphic has not been drawn yet
              boolean drawn = false;
              //define how many columns we have to draw for this row
              int numColumns = table.getColumnCount();
              //for every column in the row, paint it
              for (int column = 0; column < numColumns; column++)
                   //define cellRect
                   Rectangle cellRect = table.getCellRect(row,column,true);
                   int cellRow;
                   int cellColumn;
                   cellRow = row;
                   cellColumn = column;
                   if (cellRect.intersects(rect))
                        drawn = true;
                        DefinitionTableModel tblmod = (DefinitionTableModel) table.getModel();
                        try
                             LogicGroup grp = tblmod.getLogicGroupByRow(cellRow);
                             //is this a statement row? If so, apply special treatment to the cell,
                             //otherwise paint the cell normally
                             if (grp.getEnd()==cellRow)
                                  //We are on a row we want to span. If its the 1st column, increase
                                  //the width of the rectangle to span the entire table width and
                                  //call paintCell. Otherwise, do not even paint the cell.
                                  if (cellColumn==0)
                                       cellRect.width=table.getColumnModel().getTotalColumnWidth();
                                       paintCell(g, cellRect, cellRow, cellColumn);
                             else
                                  paintCell(g, cellRect, cellRow, cellColumn);
                        catch(Exception e)
                             e.printStackTrace();
                   else
                        if (drawn)
                             break;
         private void paintCell(Graphics g, Rectangle cellRect, int row, int column)
              int spacingHeight = table.getRowMargin();
              int spacingWidth = table.getColumnModel().getColumnMargin();
              Color c = g.getColor();
              g.setColor(table.getGridColor());
              g.drawRect(cellRect.x,cellRect.y,cellRect.width-1,cellRect.height-1);
              g.setColor(c);
              cellRect.setBounds(cellRect.x + spacingWidth/2, cellRect.y + spacingHeight/2,
              cellRect.width - spacingWidth, cellRect.height - spacingHeight);
              if (table.isEditing() && table.getEditingRow()==row &&
                   table.getEditingColumn()==column)
                   Component component = table.getEditorComponent();
                   component.setBounds(cellRect);
                   component.validate();
              else
                   TableCellRenderer renderer = table.getCellRenderer(row, column);
                   Component component = table.prepareRenderer(renderer, row, column);
                   if (component.getParent() == null)
                        rendererPane.add(component);
                   rendererPane.paintComponent(g, component, table, cellRect.x, cellRect.y,
                        cellRect.width, cellRect.height, true);
    //end of class

  • How do I change the colour of a selected cell in a jTable?

    I have a Jtable that displays URL names in one column. There are several problems I'm having. The effect I'm trying to achieve is this:
    When the user runs the mouse over the URL name the cursor should change into a hand (similar to what happens in an HTML hyperlink). I'm aware that the Cursor class can set the cursor graphic so i figure that i need a listener of some sort on each cell (so the cursor can change from an arrow to a hand) and also one to indicate when the cursor is not on a cell (so that it can change from a hand back into an arrow). Is this the right track?
    Also, I've looked at the DefaultTableCellRenderer class (which, as i understand it, is responsible for how each cell in the jtable is displayed) for a method that will allow me to set the background of a selected cell (or row or column). I require this because each time i select a cell (or row) it becomes highlighted in blue. I would rather it just remained white and changed the cursor to a hand. I know there exists a method for setting the background for an unselected cell but none for a selected cell. Again, I'm not sure if I'm going down the right track with this approach.
    Lastly, if the cell has been selected (by a mouse click) the font of the writing in the cell (i.e. The name of the URL) should change. This shouldn't be too much of a problem I think.
    I do not expect anyone to provide code to do all of this but some general pointers would be extremely helpful as I do not know if I'm thinking on the right track for any of this. Having some (limited) experience with Swing I doubt there is a simple way to do this but I can only hope!
    Thanks.
    Chris

    http://www2.gol.com/users/tame/swing/examples/SwingExamples.html
    there you can find some examples with CellRenderer's and so on ...
    have fun

  • [CS3/CS4 JS] How can you get the associatedXMLElement of a merged cell in a table?

    Hi!
    Inserting a table, and autotagging it, I get a table with a number of cell elements in the XML Structure.
    Selecting an item in the table, I can find the associated XML by the following line of code:
    app.selection[0].associatedXMLElement
    My problems begin when cells are merged. Then the associatedXMLElement for the cell returns null.
    How can I find the associatedXMLElement for a merged cell?
    Using the getElements makes no difference.
    app.selection[0].getElements()[0].associatedXMLElement
    (returns null)
    In the XML structure I can see that the merged cell is still associated to an XML Element, which becomes underlined and also referrs back to the cell, selecting it when double clicking the XML Element link in the structure.
    Is there no way to get to the xml element of a merged cell?
    I have tested in CS3 and CS4 as well, and they act in the same way.
    I also found a similar, unanswered, question from Anne-Laure Jallon in the "With CS3, some things have changed" ( http://forums.adobe.com/message/1105813#1105813 ):
    Hello,
    I'm working with VBscript.
    Is there a difference between cell.associatedXmlElement in CS2 and CS3?
    All my cells in CS2 had an associatedXmlElement.
    In CS3, my table has an associatedXmlElement, but all its cells don't (The value is Nothing)
    Is this a bug? Is it linked with XML evolution?   Thanks Anne Laure
    Adding some more info:
    I made a test, by selecting the XMLElement in the structure, and from that object finding the cell, and finding back to the assiciatedXMLElement:
    app.selection[0].getElements()[0].cells[0].associatedXMLElement
    Result: [object XMLElement]
    So that kind of "chain" works.
    But with the merged cell as only reference, I can't find its associatedXMLElement. Any ideas would be appreciated.
    Best regards,
    Andreas Jansson
    Message was edited by: Andreas Jansson

    In my opinion, locate a cell according to his content is not so effortable. What happens if contents of more than two cells are equals?
    I take xml elements of associated xml element of table and put them into an array.
    This array contains associated xml elements of every cell ordered by cell positions into table.
    Now, locate associated xml element of a cell based on its array position (index) is more reliable:
    var myCell_cell = app.selection[0];
    var myElement = myCell.associateXMLElement
    if (!myElement || !myElement.isValid)  {
         var table =  myCell.parent;
         var xml_tab = table.associatedXMLElement;
         var xml_cells_arr = xml_tab.xmlElements.everyItem().getElements();
         var idx = myCell.index;
         myElement = xml_cells_arr[idx];
    Alex ;-)

  • Help with editing a cell in a JTable. DESPERATE

    Hi! Is there someone out there that could help with some source code for editing a cell in my JTable when I run it as an applet??
    It works fine when I run it as an application.
    I manage to select the row and write a number in it, but I can't get out of the cell (it seems that the program stops??). I want to enter an integer in a cell and when I click enter or with the mouse in an other cell the value that I enter should update some other cell( multiply the entered value with some fixed number and update a cell in a second coloumn)
    I am really desperate now..... I have thought about using a MouseListener....
    I am using a tablemodel that is from AbstractTableModel.

    Are you using some cell editors?
    While converting inside them, you might be getting some exceptions (like parseexception)which is stopping you from proceeding further.
    Are you using your own tablemodel with custom datatypes?
    Hope this helps,
    Ramkumar

  • [CS4/JS] Import CALS-Tables with merged cells

    Hello scripters.
    I am actually trying to import CALS-tables (which is in my imported XML) into InDesign.
    I used the convertElementToTable for this.
    That worked, except for the merged cells (only cells which are merged to two or three columns).
    How could I script the automatic generation for merged cells?
    My xml-cals-table looks the following:
    <example>
        <table class="n" width="600" border="0">
            <colgroup>
                <col width="35%"/>
                <col width="30%"/>
                <col width="35%"/>
            </colgroup>
            <tr>
                <td colspan="3">
                    <ta>content content content content content content content content</ta>
                </td>
            </tr>
            <tr>
                <td align="left" valign="top">
                    <ta>content content content content </ta>
                </td>
                <td align="left" valign="top">
                    <ta>content content </ta>
                </td>
                <td align="right" valign="top">
                    <ta>content content </ta>
                </td>
            </tr>
            <tr>
                <td align="left" valign="top">
                    <ta>content content </ta>
                </td>
                <td align="left" valign="bottom">
                    <ta>content content </ta>
                </td>
                <td align="right" valign="bottom">
                    <ta>content content </ta>
                </td>
            </tr>
        </table>
    </example>
    Thanks in advance for any help!
    Franziska

    Hello scripters.
    I am actually trying to import CALS-tables (which is in my imported XML) into InDesign.
    I used the convertElementToTable for this.
    That worked, except for the merged cells (only cells which are merged to two or three columns).
    How could I script the automatic generation for merged cells?
    My xml-cals-table looks the following:
    <example>
        <table class="n" width="600" border="0">
            <colgroup>
                <col width="35%"/>
                <col width="30%"/>
                <col width="35%"/>
            </colgroup>
            <tr>
                <td colspan="3">
                    <ta>content content content content content content content content</ta>
                </td>
            </tr>
            <tr>
                <td align="left" valign="top">
                    <ta>content content content content </ta>
                </td>
                <td align="left" valign="top">
                    <ta>content content </ta>
                </td>
                <td align="right" valign="top">
                    <ta>content content </ta>
                </td>
            </tr>
            <tr>
                <td align="left" valign="top">
                    <ta>content content </ta>
                </td>
                <td align="left" valign="bottom">
                    <ta>content content </ta>
                </td>
                <td align="right" valign="bottom">
                    <ta>content content </ta>
                </td>
            </tr>
        </table>
    </example>
    Thanks in advance for any help!
    Franziska

  • Excel export are merging cells for data on multiple lines !

    Hello,
    I'm using Crystal Report XI R2, when we are doing an export to Excel with have an unexpected formatting.
    For example the value of the name is on 2 lines:
    => So, on Excel the result is on 2 lines but merged. We want to have this result only on one cells.
    Remark: if we delete the 2nd lines, because cells are merged we obtain the expected result.
    Proposal A:
    Are they any set-up available concerning the formatting of Excel ?
    Proposal B:
    Could we run some VBA when we click on Export button to make queries on the Excel ?

    When they introduced Unicode support in Crystal 9 (I believe), they had to completely re-write the export routines. At that time, they made a decision to change the functionality of the excel export. Crystal is attempting to remain absolutely faithful to the graphical layout of the report as you see it in the viewer. So it creates merged cell sections, empty columns between columns, and empty rows to give you as close to exactly what you see in the viewer as possible. Unfortunately, the result is typically less than useful. Iu2019ve had several conversations with Business Objects (now SAP) with regards to this when they changed it between versions 8.5 and 10, and they have no intention of changing the functionality as it now exists.
    There is a document which is now likely somewhere on the SAP portal that explains what you need to do to obtain the best results when exporting to excel.
    The jist of it is this:
    Line up all of the columns detail data with thier headers, and make sure that data fields are the same size as thier headers. 
    Line up all rows (headers and detail rows). (ie: select everything in the row, right click, align tops, and make the same height)
    cram everything as close together as possible. zero space in the report translates to zero extra collumns and rows in the export.
    the other option is to use the export to data only functionality, but that may not be what you're looking for either.

  • Merge cell in JTable

    Hi
    I have some problem with JTable that have merged cell.
    Have you got any examples for JTable with merged cell.
    Thank in advance

    check this....there are plenty of examples....
    http://www2.gol.com/users/tame/swing/examples/JTableExamples4.html

Maybe you are looking for

  • Movie is not showing...

    I burnt a DVD off of a client of footage they took from a handy cam. I am trying to open and view it it but it's not showing. But a message pops up and says that the DVD is not a movie file but some other kind of pov file or something. I put it on a

  • New Finished Goods due date

    My scenario is we have a sales order which has a required due date, meaning that the FGs are required on a certain date. lets say we run the mrp and all requirments are calculated and planned orders , PRs are generated. Now, using CRP we firm the pla

  • Error Of "Difference In Content (Error Code 191)" on doing CCR After SNP

    Dear Sir / Madam, On Taking SNP Heuristics, Our ECC system is getting choked. Proper stock transfer requisitions are getting generated in APO. Though. these purchase requisitions are  getting displayed in ECC but the same number is NOT getting update

  • Airplay Question (wasn't sure where to place it)

    I know that it's only possible through the aid of third party software (such as Rogue Amoeba's Airfoil), but is there a reason that iOS devices and Macs (or even a PC running iTunes) are unable to receive Airplay data?  For instance, if I have an iPo

  • Where to assign zprogram to zform for dunning letters

    Hi All, I have created a new z print program and z sapscript for dunning letters(FI). Where can i assign my custom program so that it is used for printing the dunning z forms. In SPRO where do we maintain this configuration. Thanks, Abhishek