public class NewClass extends JFrame {
private JPanel panel;
private JScrollPane scroll;
private JTable inventoryTable;
public NewClass() {
initComponents();
}
private void initComponents() {
final String[] columnNames = {"Item Code", "Item Quantity", "Item Desciption", "Item Cost",
"Cost Extension", "Retail", "Retail Extension", "Expiration Code"};
Object[][] data = {{"1000008", new Integer(32), "TOBI MIX NUTS 45g", new Double(18.52), new Double(100.50),
new Double(21.75), new Double(150.50), new Long(100142)},
{"1000013", new Integer(45), "TOBI MIX NUTS 45g", new Double(30.00), new Double(100.50),
new Double(21.75), new Double(150.50), new Long(100142)},
{"1000002", new Integer(15), "TOBI MIX NUTS 45g", new Double(39.59), new Double(100.50),
new Double(21.75), new Double(150.50), new Long(100142)} ,
{"1000015", new Integer(323), "TOBI MIX NUTS 45g", new Double(31.35), new Double(100.50),
new Double(21.75), new Double(150.50), new Long(100142)},
{"1000018", new Integer(64), "TOBI MIX NUTS 45g", new Double(26.36), new Double(100.50),
new Double(21.75), new Double(150.50), new Long(100142)},
{"1000005", new Integer(123), "TOBI MIX NUTS 45g", new Double(45.41), new Double(100.50),
new Double(21.75), new Double(150.50), new Long(100142)},
{"1000021", new Integer(154), "TOBI MIX NUTS 45g", new Double(8.54), new Double(100.50),
new Double(21.75), new Double(150.50), new Long(100142)},
{"1000010", new Integer(235), "TOBI MIX NUTS 45g", new Double(5.08), new Double(100.50),
new Double(21.75), new Double(150.50), new Long(100142)},
{"1000007", new Integer(346), "TOBI MIX NUTS 45g", new Double(7.66), new Double(100.50),
new Double(21.75), new Double(150.50), new Long(100142)},
{"1000001", new Integer(234), "TOBI MIX NUTS 45g", new Double(6.19), new Double(100.50),
new Double(21.75), new Double(150.50), new Long(100142)},
{"1000019", new Integer(98), "TOBI MIX NUTS 45g", new Double(5.43), new Double(100.50),
new Double(21.75), new Double(150.50), new Long(100142)},
{"1000014", new Integer(65), "TOBI MIX NUTS 45g", new Double(37.35), new Double(100.50),
new Double(21.75), new Double(150.50), new Long(100142)},
{"1000017", new Integer(101), "TOBI MIX NUTS 45g", new Double(12.86), new Double(100.50),
new Double(21.75), new Double(150.50), new Long(100142)},
{"1000022", new Integer(56), "TOBI MIX NUTS 45g", new Double(12.86), new Double(100.50),
new Double(21.75), new Double(150.50), new Long(100142)},
{"1000004", new Integer(22), "TOBI MIX NUTS 45g", new Double(12.86), new Double(100.50),
new Double(21.75), new Double(150.50), new Long(100142)},
{"1000020", new Integer(10), "TOBI MIX NUTS 45g", new Double(12.86), new Double(100.50),
new Double(21.75), new Double(150.50), new Long(100142)},
{"1000012", new Integer(36), "TOBI MIX NUTS 45g", new Double(20.39), new Double(100.50),
new Double(21.75), new Double(150.50), new Long(100142)},
{"1000006", new Integer(98), "TOBI MIX NUTS 45g", new Double(20.39), new Double(100.50),
new Double(21.75), new Double(150.50), new Long(100142)},
{"1000009", new Integer(195), "TOBI MIX NUTS 45g", new Double(22.01), new Double(100.50),
new Double(21.75), new Double(150.50), new Long(100142)},
{"1000016", new Integer(234), "TOBI MIX NUTS 45g", new Double(22.01), new Double(100.50),
new Double(21.75), new Double(150.50), new Long(100142)},
{"1000011", new Integer(89), "TOBI MIX NUTS 45g", new Double(22.01), new Double(100.50),
new Double(21.75), new Double(150.50), new Long(100142)},
{"1000003", new Integer(40), "TOBI MIX NUTS 45g", new Double(20.39), new Double(100.50),
new Double(21.75), new Double(150.50), new Long(100142)}};
inventoryTable = new JTable(data, columnNames);
inventoryTable.setGridColor(Color.BLACK);
inventoryTable.setFont(new Font("Arial", Font.BOLD, 11));
inventoryTable.setPreferredScrollableViewportSize(new Dimension(500, 70));
inventoryTable.setAutoCreateRowSorter(true);
inventoryTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
inventoryTable.getColumnModel().getColumn(0).setPreferredWidth(150);
inventoryTable.getColumnModel().getColumn(1).setPreferredWidth(150);
inventoryTable.getColumnModel().getColumn(2).setPreferredWidth(360);
inventoryTable.getColumnModel().getColumn(3).setPreferredWidth(140);
inventoryTable.getColumnModel().getColumn(4).setPreferredWidth(140);
inventoryTable.getColumnModel().getColumn(5).setPreferredWidth(140);
inventoryTable.getColumnModel().getColumn(6).setPreferredWidth(150);
inventoryTable.getColumnModel().getColumn(7).setPreferredWidth(160);
panel = new JPanel();
scroll = new JScrollPane(inventoryTable);
panel.setLayout(null);
scroll.setBounds(0, 300, 1395, 444);
panel.add(scroll);
getContentPane().add(panel);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setSize(1400, 800);
setLocationRelativeTo(null);
setResizable(false);
setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new NewClass();
}
});
}
}