?? timerprocess.java
字號(hào):
/****************************************************************************************/
/* 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();
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -