Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7780697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:59:05+00:00 2026-06-01T18:59:05+00:00

I’m currently building a Java GUI application and I’m about to implement something that

  • 0

I’m currently building a Java GUI application and I’m about to implement something that seemingly requires a great deal of thinking, at least for someone as relatively inexperienced as me.

The situation

is as follows: I have a class Customer at domain level, that holds a collection of jobs, which is a class too (Job). The application is for a fictious gardening company that wants to manage its customers and the jobs it does for them.

At GUI level, I have a jList for all the customers, with a custom listmodel that extends AbstractListModel. This part of my application works perfectly, I can add/edit/remove customers easily and as it should be.

The goal

now is to implement a jTable that should show the jobs for the customer selected in the jList.

No doubt I’ll need a custom TableModel, the question is: where to get the data from? It should be noted that the collection of jobs in the Customer class is an ArrayList, and the class has no method that returns this ArrayList directly, it is only possible to get a copy, since I don’t want it to be possible to mutate the collection in the class directly from a public context.

My idea

Is to let the tablemodel have a method to change the internal collection, with a customer parameter. When the index in the jList changes, that method should be invoked, so that the jTable represents the Jobs that have been done for the customer.
When I have to edit/create/remove a job, the changes are always done on the tablemodel first, which will propagate the changes to the customer object (in case of a new job or job removal).

The question

Is that a good way to implement it? I feel it is not, because if I forget to do any changes to a Job via the tablemodel, and on the Customer or Job directly, there will be inconsistency and trouble. Are there better ways? If it involves changing other stuff, I do not mind.

(optional) Small subquestion

I lack some knowledge on the different Collections in java. I usually just go with ArrayList, like in this case in Customer for (mutable) jobs. Is there a better collection for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T18:59:06+00:00Added an answer on June 1, 2026 at 6:59 pm

    Not saying this is the best way to implement this, but this is how I would do it

    • Make sure the customer Job list is observable. Either by using a 3th party lib which provides collections which fire events (I think Google has some available), or just make sure that every method on the Customer which updates the Job collection fires events
    • The table model representing the Jobs for a certain Customer can then listen for those events and update itself accordingly
    • It is unclear whether you allow to make changes to the table ui, but if you do, the table model should be responsible to propagate those changes again to the Customer

    So nothing changes on your current edit/create/remove/add job code. That keeps working with your Customer and does not even know a TableModel exists. The TableModel works also directly against the Customer and does not even know there might be UI to edit/create/remove/add jobs. It just listens for any changes made to the job collection and updates itself accordingly.

    It seems like a very bad idea to make the changes to the job list in all parts of your code through the table model. The Customer is your model, and the JTable is the view (MVC pattern anyone). The fact the JTable needs a different representation of your model (a TableModel) is a side-effect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.