Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How is the jtable used in the swing api?


Asked by Lilianna Duke on Dec 06, 2021 SWING



All components in the Swing API are built on the MVC pattern. Here, the JTable is the component which provides the view. The model is provided by an interface named TableModel. A default implementation is provided by the Swing API which is named as DefaultTableModel. This is internally used by JTable when we do not provide anything.
Accordingly,
All the components in the Swing API follow the MVC paradigm and JTable is no exception. Let us try and understand why this is needed and how this helps us. In simple terms, the Model-View-Controller paradigm dictates that the data be held in a Model.
Subsequently, The JTable component provided as part of the Swing API in Java is used to display/edit two-dimensional data. This is similar to a spreadsheet. Let us consider some examples. Say that you want to display a list of employees belonging to an organization. This should display the various attributes of employees.
Additionally,
All components in the Swing API are built on the MVC pattern. Here, the JTable is the component which provides the view. The model is provided by an interface named TableModel. A default implementation is provided by the Swing API which is named as DefaultTableModel.
Thereof,
The JTable has many facilities that make it possible to customize its rendering and editing but provides defaults for these features so that simple tables can be set up easily. For example, to set up a table with 10 rows and 10 columns of numbers: JTable s are typically placed inside of a JScrollPane.