[SOLVED] CS * Updated: March 2022

$25

File Name: CS__*_Updated:_March_2022.zip
File Size: 235.5 KB

5/5 - (1 vote)

* Updated: March 2022
* This code may not be used without written consent of the authors.

package ca.yorku.rtsp.client.ui;

Copyright By Assignmentchef assignmentchef

import ca.yorku.rtsp.client.exception.RTSPException;
import ca.yorku.rtsp.client.model.Frame;
import ca.yorku.rtsp.client.model.Session;
import ca.yorku.rtsp.client.model.SessionListener;

import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class MainWindow extends JFrame implements SessionListener {

private Session session;

private VideoControlToolbar videoControlToolbar;
private JLabel imagePanel;
private JLabel videoNamePanel;
private SelectServerDialog selectServerDialog;

public MainWindow() {

super(Video Client);

videoControlToolbar = new VideoControlToolbar(this);
imagePanel = new JLabel();
imagePanel.setHorizontalAlignment(SwingConstants.CENTER);
imagePanel.setVerticalAlignment(SwingConstants.CENTER);
videoNamePanel = new JLabel();
videoNamePanel.setHorizontalAlignment(SwingConstants.CENTER);

this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
disconnect(false);

this.setLayout(new BorderLayout(1, 1));
this.add(imagePanel, BorderLayout.CENTER);
this.add(videoControlToolbar, BorderLayout.PAGE_START);
this.add(videoNamePanel, BorderLayout.PAGE_END);

this.setSize(1024, 600);

selectServerDialog = new SelectServerDialog(this);

public Session getSession() {
return session;

public void setSession(Session session) {
if (this.session == session) return;

if (this.session != null) {
this.session.removeSessionListener(this);
this.session.closeConnection();

this.session = session;

if (session != null) {
session.addSessionListener(this);

public synchronized void disconnect(boolean showOpenDialog) {
setSession(null);
if (showOpenDialog) showOpenDialog();
else System.exit(0);

private void showOpenDialog() {
selectServerDialog.setVisible(true);
this.setVisible(false);

public static void main(String[] args) {
SwingUtilities.invokeLater(() -> new MainWindow().showOpenDialog());

public void exceptionThrown(RTSPException exception) {
JOptionPane.showMessageDialog(this, exception.getMessage());

public void frameReceived(Frame frame) {
if (frame == null) imagePanel.setIcon(null);
Image scaledImage = frame.getImage().getScaledInstance(-imagePanel.getWidth(), imagePanel.getHeight(), Image.SCALE_FAST);
imagePanel.setIcon(new ImageIcon(scaledImage));

public void videoEnded() {
// Nothing to be done

public void videoNameChanged(String videoName) {
if (videoName == null) videoNamePanel.setText((click open to select a video));
else videoNamePanel.setText(Video: + videoName);

CS: assignmentchef QQ: 1823890830 Email: [email protected]

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS * Updated: March 2022
$25