Based on the MVC pattern, then for the JTable element, the TableModel interface is the model. What then (what classes or interfaces) is the view and controller?

    2 answers 2

    The view is the JTable itself. The “listeners” of events act as controllers.

    Read more about this in English SO .

    Update

    Quite a lot can be done through the JTable instance. If standard methods do not work, make your Renderer .

    Update 2

    Renderer is a more detailed control of rendering (read appearance) JTable . What is impossible to implement with standard JTable tools (using the standard Renderer by default) is implemented by means of our own Renderer .

    Update 3

    Here is an example Renderer column with explanations. Here is an example Renderer cells.

    • but it cannot be changed through the JTable instance, for example, the color of the column lines !!! Probably need to use something else? - Maybe_V
    • I understand that JTable is for general settings! Rendere helps to manage, for example, the color of the lines of the columns ?? - Maybe_V
    • Please try to publish detailed answers containing a specific example of the minimum solution, supplementing them with a link to the source. Answers –references (as well as comments) do not add knowledge to the Runet. - Nicolas Chabanovsky ♦
    • @Streletz, can you link to a good example ??? - Maybe_V
    • @Vitaliy, links to examples added to the answer. - Streletz

    Model is the data that will be displayed in the JTable, View is what will form the UI (in this case, JTable and attributes that set the number of columns, etc.), Controller is responsible for user interaction via the UI. In your case, this can be a sample form from the database or buttons to hide individual columns.

    • one
      Buttons and other GUI elements have their own models, controllers and views. These are completely independent controls. - Streletz
    • one
      Nobody said they didn’t have it, just a question about the MVC pattern - and these are conventions for dividing the code into three components 1. Data - which must be provided; 2. The visual part - to display data; 3. The controller for user interaction. If you parse the JTable element separately, then you are right. - alexandr gaiduchok
    • one
      The question is not just about the MVC pattern. We are talking about MVC in the context of its specific implementation. Here the controllers are the event listener classes. Buttons, checkboxes, etc. this is the visual part, which can be changed, but the logic of processing clicks, etc. (user interaction) will remain the same regardless of whether the visibility of the columns is controlled by the button or "checkbox". Subject to the following pattern architecture. - Streletz