Title: Java jGrasp - JTable Swing Component
Duration: 16:22 min
Description: In this video, I am going to discuss how to create a simple JTable. It is simple because the data displayed within the table is static. We start by creating a JTable, adding the JTable to a JScrollPane, and finally adding the JScrollPane to the frame. A JTable is composed of column names and cells. Columns are created using a String , and the cells are created using a 2 dimentional Object array. These two paramenter are passed to the JTable constructor. The table is added to the center of the frame. Finally, we create a button that when clicked it displays the print dialog box to be able to print the table. Since the printing can cause an exception, we catch java.awt.print.PrinterException and print the stack trace if the exception happens.
Methodology: Good coding standards and simplified design.
Technologies: Abstract Window Toolkit, Java Swing.
Examples constructed: created an example that displays a table that contains employee information (Id, First Name, Last Name, Title and Ssalary).
Key words: AWT, Swing, JFrame, JTable, ActionListener, EventQueue, Runnable, Print, printStackTrace, JScrollPane.