⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timerprocess.java

📁 this is the media streaming project
💻 JAVA
字号:
/****************************************************************************************/
/* 2001-Spring: Java Network-Programming Term-Project					*/
/* Title: Streaming media generation, capture and store.				*/
/* Team Member: Yumin Yuan(yuany@rpi.edu), Rui Mu(mur@rpi.edu), Yining Hu(huyn@rpi.edu) */
/* TimerProcess.java: This class generates interface for the timing recording function	*/
/* Complile: javac TimerProcess.java							*/
/****************************************************************************************/

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;

public class TimerProcess extends JFrame{
    private static JTextField startTime, stopTime;	
    private JPanel textPanel;
    private File file=null;
    private String input=null;
    private String address=null;
    public TimerProcess(String ip, String receivePort){
	super("Timing Recording");
        input = receivePort;
        address = ip;
 
    	Container c=getContentPane();
    	c.setLayout(new BoxLayout(c,BoxLayout.Y_AXIS));

	startTime = new JTextField(10);
        JLabel startLabel = new JLabel("Starting Time (hours:min)   ");
	stopTime = new JTextField(10);
	JLabel stopLabel = new JLabel("Stop Time (hours:min)    ");

	textPanel = new JPanel();
	textPanel.setBorder(BorderFactory.createEtchedBorder());

	JPanel labelPanel=new JPanel();
	labelPanel.setLayout(new BoxLayout(labelPanel,BoxLayout.X_AXIS));

	labelPanel.add(startLabel);
	labelPanel.add(stopLabel);

	textPanel.add(startTime);
	textPanel.add(stopTime);
	
	//prompt for file name from user
	JButton saveButton = new JButton("Save As ...");
	saveButton.addActionListener(	
	    new ActionListener(){
		public void actionPerformed(ActionEvent e){
	        	final JFileChooser fc = new JFileChooser();
	     
	    		int returnVal = fc.showSaveDialog(TimerProcess.this);

	    		if (returnVal == JFileChooser.APPROVE_OPTION) {
				file = fc.getSelectedFile();
				System.out.println(file.getAbsolutePath());
	   		} 		
		}
	    }
	);

	//start the timer for recording
	JButton startButton=new JButton("Start Timing");
    	startButton.addActionListener(	
	    new ActionListener(){
		public void actionPerformed(ActionEvent e){
			String start = startTime.getText();
			String stop = stopTime.getText();
			if(start == "" || stop == "" || file == null)
		        	JOptionPane.showMessageDialog (null, "You must input Start and Stop Time, and give a file name", "Error!", JOptionPane.ERROR_MESSAGE);
			else{   //do the recording work 
				TimingRecorder tr = new TimingRecorder(address, input, start, stop, file);

			}
		
		}
	    }
	);

	JButton quitButton=new JButton("Cancel");
	quitButton.addActionListener(	
	    new ActionListener(){
		public void actionPerformed(ActionEvent e){
			setVisible(false);
                        dispose();
		}
	    }
	);

	JPanel buttonPanel=new JPanel();
	buttonPanel.setLayout(new BoxLayout(buttonPanel,BoxLayout.X_AXIS));
	buttonPanel.setBorder(BorderFactory.createEtchedBorder());
        buttonPanel.add(saveButton);
	buttonPanel.add(startButton);
	buttonPanel.add(quitButton);
   	
	c.add(labelPanel);
	c.add(textPanel);
    	c.add(buttonPanel);

	setSize(500, 150);
	show();
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -