📄 clientui.java
字号:
}
}
}
//--------------------------handleClearYesNo-----------------------------
/**
* handleClearYesNoThis method handles clear yes and no
* @param users the list of all users
*/
private void handleClearYesNo(Hashtable users) {
userListDisplay.displayUserPanel(users);
if (myCategory == Constants.USER) {
if (yesButton.isSelected()) {
yesButton.setSelected(false);
yesButton.setBorder(mytoolBar.compoundBorder);
}
else if (noButton.isSelected()) {
noButton.setSelected(false);
noButton.setBorder(mytoolBar.compoundBorder);
}
}
}
///---------------------- handleStepInOut ----------------------------
/**
* handleStepInOut handles steping in and out
* @param usersConfig the list of all users
*/
private void handleStepInOut(Hashtable users) {
userListDisplay.displayUserPanel(users);
}
///------------------------- handleStartSession ---------------------
/* handleStartSession handles starting sessions
*/
private void handleStartSession ()
{
boolean isInsession = true;
userListDisplay.displayUserPanel(client.getUsersConfig());
inOutSession.setText("In Session");
if (myCategory != Constants.PRESENTER)
{
contentManager.enableContentManager(!isInsession, myCategory);
mytoolBar.setUserUI(true);
}
else {
//mytoolBar.setPresenterUI(isInsession);
}
//raise voiceChatButton if it is down now
if (myCategory == Constants.USER) {
if (voiceChatButton.isSelected()) {
voiceChatButton.setSelected(false);
voiceChatButton.setBorder(mytoolBar.compoundBorder);
}
}
//end of raise voiceChatButton if it is down now
if (!userListDisplay.getMicAvailable()) {
voiceChatButton.setIcon(new javax.swing.ImageIcon(
Toolkit.getDefaultToolkit().getImage(getClass().getResource("icon1/voice_gray.gif"))));
}
else {
voiceChatButton.setIcon(new javax.swing.ImageIcon(
Toolkit.getDefaultToolkit().getImage(getClass().getResource("icon1/voice.gif"))));
}
}
//------------------------------------Handle Stop Session------------------------------
/* handleStopSession handles stoping session
*/
private void handleStopSession () {
boolean session = false;
userListDisplay.displayUserPanel(client.getUsersConfig());
inOutSession.setText("Out of Session");
mytoolBar.setUserUI(false);
if (myCategory != Constants.PRESENTER)
{
contentManager.enableContentManager(!session, myCategory);
}
if (userListDisplay.getMicAvailable()) {
voiceChatButton.setIcon(new javax.swing.ImageIcon(
Toolkit.getDefaultToolkit().getImage(getClass().getResource("icon1/voice.gif"))));
}
}
//------------------------- handleVoiceChat -----------------------
/** handleVoiceChat handles voice chat start ans stop
* @return true if can start voice
*/
private boolean handleVoiceChat() {
return false;
}
//------------------------- handleBroadcastMessage ------------------
/**
* handleBroadcastMessage send chat messages to all
* @param msgVector the broadcasted message
*/
public void handleBroadcastMessage(Vector msgVec) {
String msg = (String)msgVec.elementAt(0);
String sender = (String)msgVec.elementAt(1);
String receiver = (String)msgVec.elementAt(2);
Integer type = (Integer) msgVec.elementAt(3);
client.broadcastMessage(msg,sender,receiver,type);
}
//---------------------Disable Every Components ------------------------
/**
* disableEveryComponentv disalbes all components if user step out
* @param stepin if user is in
*/
private void disableEveryComponent(boolean stepin) {
if (stepin/*&&!isInSession()*/) {//already stepout
if (myCategory == Constants.USER) {
if (handButton.isSelected()) {
/* handButton.setBorder(mytoolBar.compoundBorder);
handButton.setSelected(false);
*/ client.lowerHand();
}
/*handButton.setIcon(mytoolBar.hand_grayIcon);
yesButton.setIcon(mytoolBar.yes_grayIcon);
noButton.setIcon(mytoolBar.no_grayIcon);
*/
mytoolBar.setEnabledHand(false);
mytoolBar.setEnabledYes(false);
mytoolBar.setEnabledNo(false);
sendFeedbackMenuItem.setEnabled(false);
raiseHandMenuItem.setEnabled(false);
sayYesMenuItem.setEnabled(false);
sayNoMenuItem.setEnabled(false);
}
else if (myCategory == Constants.PRESENTER) {
/* lowHandButton.setIcon(mytoolBar.lowhand_grayIcon);
clearYesNoButton.setIcon(mytoolBar.clearyesno_grayIcon);
giveMicToNextButton.setIcon(mytoolBar.mic_grayIcon);
*/
mytoolBar.setEnabledLowHand(false);
mytoolBar.setEnabledMicrophone(false);
mytoolBar.setEnabledClearYesNo(false);
if (isInSession()) {
/* sessionInButton.setIcon(new javax.swing.ImageIcon(
Toolkit.getDefaultToolkit().getImage(getClass().getResource("icon1/end_session_gray.gif"))));
*/ mytoolBar.setEnabledEndSession(false);
}
else {
/* sessionInButton.setIcon(new javax.swing.ImageIcon(
Toolkit.getDefaultToolkit().getImage(getClass().getResource("icon1/begin_session_gray.gif"))));
*/ mytoolBar.setEnabledBeginSession(false);
}
lowerAllHandMenuItem.setEnabled(false);
clearYesNoMenuItem.setEnabled(false);
giveMicToNextMenuItem.setEnabled(false);
sessionInMenuItem.setEnabled(false);
receiveFeedbackMenuItem.setEnabled(false);
}
/* voiceChatButton.setIcon(mytoolBar.voicechat_grayIcon);
feedbackButton.setIcon(mytoolBar.feedback_grayIcon);
*/
mytoolBar.setEnabledVoiceChat(false);
mytoolBar.setEnabledFeedback(false);
}
else if (!stepin){
if (myCategory == Constants.USER&&isInSession()) {
/* handButton.setIcon(mytoolBar.handIcon);
yesButton.setIcon(mytoolBar.yesIcon);
noButton.setIcon(mytoolBar.noIcon);
*/
mytoolBar.setEnabledHand(true);
mytoolBar.setEnabledYes(true);
mytoolBar.setEnabledNo(true);
raiseHandMenuItem.setEnabled(true);
sayYesMenuItem.setEnabled(true);
sayNoMenuItem.setEnabled(true);
sendFeedbackMenuItem.setEnabled(true);
}
else if (myCategory == Constants.PRESENTER) {
if (isInSession()) {
/* lowHandButton.setIcon(mytoolBar.lowhandIcon);
clearYesNoButton.setIcon(mytoolBar.clearyesnoIcon);
giveMicToNextButton.setIcon(mytoolBar.micIcon);
sessionInButton.setIcon(mytoolBar.endsessionIcon);
*/
mytoolBar.setEnabledLowHand(true);
mytoolBar.setEnabledClearYesNo(true);
mytoolBar.setEnabledMicrophone(true);
mytoolBar.setEnabledEndSession(true);
mytoolBar.setEnabledVoiceChat(true);
mytoolBar.setEnabledFeedback(true);
lowerAllHandMenuItem.setEnabled(true);
clearYesNoMenuItem.setEnabled(true);
giveMicToNextMenuItem.setEnabled(true);
}
else {
/* lowHandButton.setIcon(mytoolBar.lowhand_grayIcon);
clearYesNoButton.setIcon(mytoolBar.clearyesno_grayIcon);
giveMicToNextButton.setIcon(mytoolBar.mic_grayIcon);
sessionInButton.setIcon(mytoolBar.beginsessionIcon);
*/
mytoolBar.setEnabledLowHand(false);
mytoolBar.setEnabledClearYesNo(false);
mytoolBar.setEnabledMicrophone(false);
mytoolBar.setEnabledBeginSession(true);
mytoolBar.setEnabledVoiceChat(false);
mytoolBar.setEnabledFeedback(false);
lowerAllHandMenuItem.setEnabled(false);
clearYesNoMenuItem.setEnabled(false);
giveMicToNextMenuItem.setEnabled(false);
}
sessionInMenuItem.setEnabled(true);
receiveFeedbackMenuItem.setEnabled(true);
}
/* voiceChatButton.setIcon(mytoolBar.voicechatIcon);
feedbackButton.setIcon(mytoolBar.feedbackIcon);
mytoolBar.setEnabledVoiceChat(true);
mytoolBar.setEnabledFeedback(true);
*/ }
}
/**
* setSpeaker sets Speaker icon if there is someone speaking
* @param speaker the current speaking user name
*/
private void setSpeaker(String speaker) {
//System.out.println("speaker is: " + "'" + speaker + "'");
if ((speaker==null) || speaker.equals("")) {
speakerButton.setIcon(new javax.swing.ImageIcon(iconDir + ""));
speakerButton.setText("");
}
else {
speakerButton.setIcon(new javax.swing.ImageIcon(
Toolkit.getDefaultToolkit().getImage(getClass().getResource("icon1/speaker.gif"))));
speakerButton.setText(speaker);
}
}
/**
* setPresenterMenu sets Presenter's menu
*/
private void setPresenterMenu() {
//-----------Tools menu --------
toolsMenu.removeAll();
textChatMenuItem.setText("Text Chat");
toolsMenu.add(textChatMenuItem);
//------------set menu for USER/PRESENTER-------
if(myCategory==Constants.USER)
{
sendFeedbackMenuItem = new JMenuItem("Send FeedBack");
sendFeedbackMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
SendFeedbackAction();
}
});
toolsMenu.add(sendFeedbackMenuItem);
}
else if(myCategory==Constants.PRESENTER)
{
receiveFeedbackMenuItem = new JMenuItem("Receive FeedBack");
receiveFeedbackMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ReceiveFeedbackAction();
}
});
toolsMenu.add(receiveFeedbackMenuItem);
}
//menuBar.add(toolsMenu);
toolsMenu.validate();
//----------Actions menu --------------
actionsMenu.removeAll();
if(myCategory==Constants.PRESENTER)
{
lowerAllHandMenuItem = new JMenuItem("Lower All Hand");
lowerAllHandMenuItem.setEnabled(false);
lowerAllHandMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
LowerAllHandAction();
}
});
actionsMenu.add(lowerAllHandMenuItem);
}
else if(myCategory==Constants.USER)
{
raiseHandMenuItem = new JMenuItem("Raise Hand");
raiseHandMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (handButton.isSelected()) {
handButton.setSelected(false);
}
else {
handButton.setSelected(true);
}
RaiseHandAction();
}
});
actionsMenu.add(raiseHandMenuItem);
}
//--------
if(myCategory==Constants.USER)
{
sayYesMenuItem = new JMenuItem("Say Yes");
sayYesMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (yesButton.isSelected()) {
yesButton.setSelected(false);
}
else {
yesButton.setSelected(true);
}
YesAction();
}
});
actionsMenu.add(sayYesMenuItem);
sayNoMenuItem = new JMenuItem("Say No");
sayNoMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (noButton.isSelected()) {
noButton.setSelected(false);
}
else {
noButton.setSelected(true);
}
NoAction();
}
});
actionsMenu.add(sayNoMenuItem);
}
else if(myCategory==Constants.PRESENTER)
{
clearYesNoMenuItem = new JMenuItem("Clear Yes/No");
clearYesNoMenuItem.setEnabled(false);
clearYesNoMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ClearYesNoAction();
}
});
actionsMenu.add(clearYesNoMenuItem);
sessionInMenuItem = new JMenuItem("Begin Session");
sessionInMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (sessionInButton.isSelected()) {
sessionInButton.setSelected(false);
}
else {
sessionInButton.setSelected(true);
}
SessionInAction();
}
});
actionsMenu.add(sessionInMenuItem);
giveMicToNextMenuItem = new JMenuItem("Give Min To Next");
giveMicToNextMenuItem.setEnabled(false);
giveMicToNextMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
GiveMicToNextAction();
}
});
actionsMenu.add(giveMicToNextMenuItem);
}
//-------------------------
stepOutMenuItem = new JMenuItem("Step In/Out");
stepOutMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (stepInButton.isSelected()) {
stepInButton.setSelected(false);
}
else {
stepInButton.setSelected(true);
}
StepOutAction();
}
});
actionsMenu.add(stepOutMenuItem);
logoutMenuItem.setText("Log Out");
actionsMenu.add(logoutMenuItem);
actionsMenu.validate();
}
private class uploadBox extends JDialog
{
/**
* CustomDialog creates the Custom
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -