TAGS :Viewed: 6 - Published at: a few seconds ago

[ How to create a JTable with bordered cells in a JPanel? ]

I am new to UI designing and was wondering what I would do after I create a JPanel. Each JPanel will be treated as a standalone window and allow the user to navigate around the program. I would like a 2x3 JTable with the headers: "Item Description", "Quantity", and "Price" in the first row. The table's cells should also be visible with borders. I've played around with WindowBuilder but it doesn't seem to let me customize that well.

    JPanel panelCheckout = new JPanel();
    frame.getContentPane().add(panelCheckout, "name_1446238423153284000");
    panelCheckout.setLayout(new BoxLayout(panelCheckout, BoxLayout.X_AXIS));

This is what I have so far. I don't know what the panel layout should be set to, but the first 2 lines are the only ones that should not be changes. I tried to look for source code elsewhere but they looked too complicated than they should be.

Answer 1


To change the appearance of a JTable cell, you would create a custom cell renderer as is well described in the official JTable tutorial.