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 8095905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:17:31+00:00 2026-06-05T21:17:31+00:00

I have 2 JPanel : Panel_S , Panel_P . The 1st listens to Station

  • 0

I have 2 JPanel: Panel_S, Panel_P. The 1st listens to Station events and the 2nd listens to Passenger events.
When new passenger is created it is added to JList in Panel_P. When passenger finished “going” to station by goToStation and getting in line by station.addPassenger(this); the station’s event fireAddPassengerEvent is fired and the passenger is added to JList in Panel_S. Now, I need some how to remove the passenger from JList in Panel_P because it finished “going” and entered the queue in station. What is the correct way to implement this? Does Panel_S should “tell” Panel_P to remove the passenger from its list once Panel_S adds passenger to its list?

If you didn’t understood my question please tell me and I’ll try to explain myself better.

public class Passenger extends Thread {
    private Station station;
    private Vector<PassengerEventsViewListener> viewListeners;

    public Passenger(Station station)
    {
        this.station = station;
    }
    private void getInLineInStation()
    {
        station.addPassenger(this);
    }
    private void fireArrivedToStationEvent(EventArgs<Passenger> args)
    {       
       for (PassengerEventsViewListener l : viewListeners) {
          l.arrivedToStationEvent(args);
       }
    }
    private void goToStation()
    {
        //going
        fireArrivedToStationEvent(this);
    }

    @Override
    public void run()
    {
       goToStation();
       getInLineInStation();
    }
}

public class Station {
     private Vector<StationEventsViewListener> viewListeners;

     private void fireAddPassengerEvent(Passenger passenger)
     {      
         for (StationEventsViewListener l : viewListeners) {
             l.addPassengerEvent(passenger);
         } 
     }
     public synchronized boolean addPassenger(Passenger p)
     {
          passengersInQueue.addLast(passenger);     
          fireAddPassengerEvent(passenger);
     }
}
  • 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-05T21:17:34+00:00Added an answer on June 5, 2026 at 9:17 pm

    No, your views should not communicate and should not be coupled. Only the models talk and see each other. Each model’s view changes accordingly.

    Back to your problem. Panel_P should be linked to a model that contains information about passengers. In the other hand, Panel_S should be linked to a model that contains information about stations. Now when a new passenger arrives to a station, the passenger model should notify the station model of the new arrival. Panel_S can then be updated from station model without caring about passenger model nor its view (Panel_P)

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

Sidebar

Related Questions

I have a class that extends JPanel. On the panel I have added an
I have a JPanel, which I would like to detect the following events (1)
I have a JPanel that looks something like this: JPanel panel = new JPanel();
I have a JPanel with components added with absolute locations (ie. pos x y),
I have a JPanel that I have created a MouseListener for and I am
Hy.. I have a JPanel, and in this contentPanel I added some other custom
I have a JPanel (A) which contains another JPanel (B). Each panel implements a
I have a JFrame with JScrollPane in it. I have JPanel inside a scrollPane.
I have a JPanel that has a button in it. The location of the
I have an JPanel populated with several opaque custom components. Now I would like

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.