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

📄 testphone.java

📁 jtapi for telephone
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/**
 * Return the HookSwitch property value.
 * @return javax.swing.JToggleButton
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JToggleButton getHookSwitch() {
	if (ivjHookSwitch == null) {
		try {
			ivjHookSwitch = new javax.swing.JToggleButton();
			ivjHookSwitch.setName("HookSwitch");
			ivjHookSwitch.setToolTipText("Clickhere to pick up or put down the phone");
			ivjHookSwitch.setText("On Hook");
			// user code begin {1}
			// user code end
		} catch (java.lang.Throwable ivjExc) {
			// user code begin {2}
			// user code end
			handleException(ivjExc);
		}
	}
	return ivjHookSwitch;
}
/**
 * Insert the method's description here.
 * Creation date: (2000-02-09 10:27:27)
 * @author: 
 * @return net.sourceforge.gjtapi.raw.emulator.PhoneManager
 */
private PhoneManager getManager() {
	return manager;
}
/**
 * Insert the method's description here.
 * Creation date: (2000-02-29 13:02:24)
 * @author: 
 * @return net.sourceforge.gjtapi.raw.emulator.PhoneModel
 */
PhoneModel getModel() {
	return model;
}
/**
 * Return the PhoneLabel property value.
 * @return javax.swing.JLabel
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JLabel getPhoneLabel() {
	if (ivjPhoneLabel == null) {
		try {
			ivjPhoneLabel = new javax.swing.JLabel();
			ivjPhoneLabel.setName("PhoneLabel");
			ivjPhoneLabel.setText("Address Unknown");
			ivjPhoneLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
			// user code begin {1}
			// user code end
		} catch (java.lang.Throwable ivjExc) {
			// user code begin {2}
			// user code end
			handleException(ivjExc);
		}
	}
	return ivjPhoneLabel;
}
/**
 * Get the state of the phone
 * Creation date: (2000-02-07 16:12:52)
 * @author: Richard Deadman
 * @return The current state
 */
public int getState() {
	return this.getModel().getState();
}
/**
 * Return the StatusLine property value.
 * @return javax.swing.JTextField
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JTextField getStatusLine() {
	if (ivjStatusLine == null) {
		try {
			ivjStatusLine = new javax.swing.JTextField();
			ivjStatusLine.setName("StatusLine");
			ivjStatusLine.setEditable(false);
			// user code begin {1}
			// user code end
		} catch (java.lang.Throwable ivjExc) {
			// user code begin {2}
			// user code end
			handleException(ivjExc);
		}
	}
	return ivjStatusLine;
}
/**
 * Called whenever the part throws an exception.
 * @param exception java.lang.Throwable
 */
private void handleException(java.lang.Throwable exception) {

	/* Uncomment the following lines to print uncaught exceptions to stdout */
	System.out.println("--------- UNCAUGHT EXCEPTION ---------");
	exception.printStackTrace(System.out);
}
/**
 * Hold the phone
 */
public boolean hold() {
	return this.getModel().hold();
}
/**
 * Toggle the phone hold state
 */
public void holdButton_ActionEvents() {
	switch (this.getState()) {
		case RawPhone.ACTIVE: {
			this.hold();
			break;
		} 
		case RawPhone.HOLD: {
			this.unHold();
			break;
		} 
		case RawPhone.BRIDGED: {
			this.conference();
			break;
		} 
		default: {
			System.err.println("Error in hold button action.");
		}
	}
}
/**
 * Tell the state machine to change the phone's state
 */
public void hookSwitch_ActionEvents() {
	if (this.isOffHook()) {
		if (this.getState() == RawPhone.RINGING)	// answer
			this.answer();
		else {		// create new call
			this.createCall();
		}
	} else {
		// exit any active calls
		this.drop();
	}
}
/**
 * The call has been removed
 */
public void idle() {
	if (this.isOffHook())
		this.createCall();
	else
		this.enable("Idle", false, false, "Dial");
}
/**
 * React to the joining of a call
 */
public void inCall(Leg newLeg) {
	this.enable("New Call", true, true, "Dial");
}
/**
 * Initializes connections
 * @exception java.lang.Exception The exception description.
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void initConnections() throws java.lang.Exception {
	// user code begin {1}
	// user code end
	getButton1().addActionListener(ivjEventHandler);
	getButton2().addActionListener(ivjEventHandler);
	getButton3().addActionListener(ivjEventHandler);
	getButton4().addActionListener(ivjEventHandler);
	getButton5().addActionListener(ivjEventHandler);
	getButton6().addActionListener(ivjEventHandler);
	getButton7().addActionListener(ivjEventHandler);
	getButton8().addActionListener(ivjEventHandler);
	getButton9().addActionListener(ivjEventHandler);
	getButtonStar().addActionListener(ivjEventHandler);
	getButton0().addActionListener(ivjEventHandler);
	getButtonPound().addActionListener(ivjEventHandler);
	getHookSwitch().addActionListener(ivjEventHandler);
	getDialString().addActionListener(ivjEventHandler);
	getDialButton().addActionListener(ivjEventHandler);
	getHoldButton().addActionListener(ivjEventHandler);
}
/**
 * Initialize the class.
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void initialize() {
	try {
		// user code begin {1}
		// user code end
		setName("TestPhone");
		setLayout(new java.awt.GridBagLayout());
		setSize(393, 275);

		java.awt.GridBagConstraints constraintsButton1 = new java.awt.GridBagConstraints();
		constraintsButton1.gridx = 0; constraintsButton1.gridy = 1;
		constraintsButton1.fill = java.awt.GridBagConstraints.HORIZONTAL;
		constraintsButton1.weightx = 1.0;
		constraintsButton1.insets = new java.awt.Insets(4, 4, 4, 4);
		add(getButton1(), constraintsButton1);

		java.awt.GridBagConstraints constraintsButton2 = new java.awt.GridBagConstraints();
		constraintsButton2.gridx = 1; constraintsButton2.gridy = 1;
		constraintsButton2.fill = java.awt.GridBagConstraints.HORIZONTAL;
		constraintsButton2.weightx = 1.0;
		constraintsButton2.insets = new java.awt.Insets(4, 4, 4, 4);
		add(getButton2(), constraintsButton2);

		java.awt.GridBagConstraints constraintsButton3 = new java.awt.GridBagConstraints();
		constraintsButton3.gridx = 2; constraintsButton3.gridy = 1;
		constraintsButton3.fill = java.awt.GridBagConstraints.HORIZONTAL;
		constraintsButton3.weightx = 1.0;
		constraintsButton3.insets = new java.awt.Insets(4, 4, 4, 4);
		add(getButton3(), constraintsButton3);

		java.awt.GridBagConstraints constraintsButton4 = new java.awt.GridBagConstraints();
		constraintsButton4.gridx = 0; constraintsButton4.gridy = 2;
		constraintsButton4.fill = java.awt.GridBagConstraints.HORIZONTAL;
		constraintsButton4.weightx = 1.0;
		constraintsButton4.insets = new java.awt.Insets(4, 4, 4, 4);
		add(getButton4(), constraintsButton4);

		java.awt.GridBagConstraints constraintsButton5 = new java.awt.GridBagConstraints();
		constraintsButton5.gridx = 1; constraintsButton5.gridy = 2;
		constraintsButton5.fill = java.awt.GridBagConstraints.HORIZONTAL;
		constraintsButton5.weightx = 1.0;
		constraintsButton5.insets = new java.awt.Insets(4, 4, 4, 4);
		add(getButton5(), constraintsButton5);

		java.awt.GridBagConstraints constraintsButton6 = new java.awt.GridBagConstraints();
		constraintsButton6.gridx = 2; constraintsButton6.gridy = 2;
		constraintsButton6.fill = java.awt.GridBagConstraints.HORIZONTAL;
		constraintsButton6.weightx = 1.0;
		constraintsButton6.insets = new java.awt.Insets(4, 4, 4, 4);
		add(getButton6(), constraintsButton6);

		java.awt.GridBagConstraints constraintsButton7 = new java.awt.GridBagConstraints();
		constraintsButton7.gridx = 0; constraintsButton7.gridy = 3;
		constraintsButton7.fill = java.awt.GridBagConstraints.HORIZONTAL;
		constraintsButton7.weightx = 1.0;
		constraintsButton7.insets = new java.awt.Insets(4, 4, 4, 4);
		add(getButton7(), constraintsButton7);

		java.awt.GridBagConstraints constraintsButton8 = new java.awt.GridBagConstraints();
		constraintsButton8.gridx = 1; constraintsButton8.gridy = 3;
		constraintsButton8.fill = java.awt.GridBagConstraints.HORIZONTAL;
		constraintsButton8.weightx = 1.0;
		constraintsButton8.insets = new java.awt.Insets(4, 4, 4, 4);
		add(getButton8(), constraintsButton8);

		java.awt.GridBagConstraints constraintsButton9 = new java.awt.GridBagConstraints();
		constraintsButton9.gridx = 2; constraintsButton9.gridy = 3;
		constraintsButton9.fill = java.awt.GridBagConstraints.HORIZONTAL;
		constraintsButton9.weightx = 1.0;
		constraintsButton9.insets = new java.awt.Insets(4, 4, 4, 4);
		add(getButton9(), constraintsButton9);

		java.awt.GridBagConstraints constraintsButton0 = new java.awt.GridBagConstraints();
		constraintsButton0.gridx = 1; constraintsButton0.gridy = 4;
		constraintsButton0.fill = java.awt.GridBagConstraints.HORIZONTAL;
		constraintsButton0.weightx = 1.0;
		constraintsButton0.insets = new java.awt.Insets(4, 4, 4, 4);
		add(getButton0(), constraintsButton0);

		java.awt.GridBagConstraints constraintsButtonStar = new java.awt.GridBagConstraints();
		constraintsButtonStar.gridx = 0; constraintsButtonStar.gridy = 4;
		constraintsButtonStar.fill = java.awt.GridBagConstraints.HORIZONTAL;
		constraintsButtonStar.weightx = 1.0;
		constraintsButtonStar.insets = new java.awt.Insets(4, 4, 4, 4);
		add(getButtonStar(), constraintsButtonStar);

		java.awt.GridBagConstraints constraintsButtonPound = new java.awt.GridBagConstraints();
		constraintsButtonPound.gridx = 2; constraintsButtonPound.gridy = 4;
		constraintsButtonPound.fill = java.awt.GridBagConstraints.HORIZONTAL;
		constraintsButtonPound.weightx = 1.0;
		constraintsButtonPound.insets = new java.awt.Insets(4, 4, 4, 4);
		add(getButtonPound(), constraintsButtonPound);

		java.awt.GridBagConstraints constraintsDialString = new java.awt.GridBagConstraints();
		constraintsDialString.gridx = 0; constraintsDialString.gridy = 0;
		constraintsDialString.gridwidth = 2;
		constraintsDialString.fill = java.awt.GridBagConstraints.HORIZONTAL;
		constraintsDialString.weightx = 1.0;
		constraintsDialString.insets = new java.awt.Insets(4, 4, 4, 4);
		add(getDialString(), constraintsDialString);

		java.awt.GridBagConstraints constraintsStatusLine = new java.awt.GridBagConstraints();
		constraintsStatusLine.gridx = 0; constraintsStatusLine.gridy = 5;
		constraintsStatusLine.gridwidth = 3;
		constraintsStatusLine.fill = java.awt.GridBagConstraints.HORIZONTAL;
		constraintsStatusLine.weightx = 1.0;
		constraintsStatusLine.insets = new java.awt.Insets(4, 4, 4, 4);
		add(getStatusLine(), constraintsStatusLine);

		java.awt.GridBagConstraints constraintsDialButton = new java.awt.GridBagConstraints();
		constraintsDialButton.gridx = 2; constraintsDialButton.gridy = 0;
		constraintsDialButton.fill = java.awt.GridBagConstraints.HORIZONTAL;
		constraintsDialButton.insets = new java.awt.Insets(4, 4, 4, 4);
		add(getDialButton(), constraintsDialButton);

		java.awt.GridBagConstraints constraintsHookSwitch = new java.awt.GridBagConstraints();
		constraintsHookSwitch.gridx = 0; constraintsHookSwitch.gridy = 6;
		constraintsHookSwitch.gridwidth = 2;
		constraintsHookSwitch.fill = java.awt.GridBagConstraints.HORIZONTAL;
		constraintsHookSwitch.insets = new java.awt.Insets(4, 4, 4, 4);
		add(getHookSwitch(), constraintsHookSwitch);

		java.awt.GridBagConstraints constraintsHoldButton = new java.awt.GridBagConstraints();
		constraintsHoldButton.gridx = 2; constraintsHoldButton.gridy = 6;
		constraintsHoldButton.insets = new java.awt.Insets(4, 4, 4, 4);
		add(getHoldButton(), constraintsHoldButton);

		java.awt.GridBagConstraints constraintsPhoneLabel = new java.awt.GridBagConstraints();
		constraintsPhoneLabel.gridx = 0; constraintsPhoneLabel.gridy = 7;
		constraintsPhoneLabel.gridwidth = 3;
		constraintsPhoneLabel.fill = java.awt.GridBagConstraints.HORIZONTAL;
		constraintsPhoneLabel.insets = new java.awt.Insets(4, 10, 4, 10);
		add(getPhoneLabel(), constraintsPhoneLabel);
		initConnections();
	} catch (java.lang.Throwable ivjExc) {
		handleException(ivjExc);
	}
	// user code begin {2}
	this.getPhoneLabel().setText(this.getAddress());
	// user code end
}
/**
 * Test if the phone is off-hook
 * Creation date: (2000-02-09 12:44:23)
 * @author: Richard Deadman
 * @return true if the phone is off-hook
 */
private boolean isOffHook() {
	return this.getHookSwitch().isSelected();
}
/**
 * Tell the phone to go on or off hook
 */
public boolean offHook(boolean off) {
	JToggleButton tog = this.getHookSwitch();
	if (this.isOffHook() != off)
		tog.doClick();
	return this.isOffHook();
}
/**
 * onHold method comment.
 */
public boolean onHold() {
	this.enable("On Hold", true, true, "Dial");
	this.getHoldButton().setText("Unhold");
	return true;
}
/**
 * Note the reception or DTMF digits
 */
public void receiveDTMF(String digits) {
	this.getModel().receiveDTMF(digits);
	this.setStatus("Received DTMF: " + digits);
}
/**
 * receiving method comment.
 */
public void receiving(String digits) {
	this.enable("Receiving " + digits, true, true, null);
}
/**
 * drop method comment.
 */
public boolean remove(Leg leg) {
	this.enable("Call Dropped", false, false, "Dial");
	return true;
}
/**
 * reportDTMF method comment.
 */
public String reportDTMF(int num) {
	return this.getModel().reportDTMF(num);
}
/**
 * ringing method comment.
 */
public void ringing() {
	this.enable("Ringing", false, false, null);
}
/**
 * Notes whether to send detected DTMF signals as events
 * Creation date: (2000-05-10 13:57:17)
 * @author: Richard Deadman
 * @param flag if true, send the events, otherwise suppress them
 */
public void sendDetectedDtmf(boolean flag) {
	this.getModel().sendDetectedDtmf(flag);
}
/**
 * Forward the message (DTMF signals) to all call participants
 */
public void sendDTMF(java.lang.String msg) {
	this.getModel().sendDTMF(msg);
}
/**
 * sending method comment.
 */
public void sending() {
	this.enable("Sending DTMF...", true, true, null);
}
/**
 * Insert the method's description here.
 * Creation date: (2000-02-09 10:27:27)
 * @author: 
 * @param newManager net.sourceforge.gjtapi.raw.emulator.PhoneManager
 */
private void setManager(PhoneManager newManager) {
	manager = newManager;
}
/**
 * Insert the method's description here.
 * Creation date: (2000-02-29 13:02:24)
 * @author: 
 * @param newModel net.sourceforge.gjtapi.raw.emulator.PhoneModel
 */
private void setModel(PhoneModel newModel) {
	model = newModel;
}
/**
 * Set the status for the phone
 * Creation date: (2000-02-07 15:48:32)
 * @author: Richard Deadman
 */
public void setStatus(String status) {
	javax.swing.text.Document d = this.getStatusLine().getDocument();
	int length = d.getLength();
	try {
		d.remove(0, length);
		d.insertString(0, status, null);
	} catch (javax.swing.text.BadLocationException ble) {
		System.out.println("Bad Status Location: " + (d.getEndPosition().getOffset() - 1));
	}
}
/**
 * swap method comment.
 */
public void swap(Leg oldLeg, Leg newLeg) {
	this.getModel().swap(oldLeg, newLeg);
}
/**
 * swap method comment.
 */
public Leg swap(RawCall call, Leg oldLeg, TelephonyListener sink) {
	return this.getModel().swap(call, oldLeg, sink);
}
/**
 * Describe myself
 * @return a string representation of the receiver
 */
public String toString() {
	return "TestPhone with address: " + this.getAddress() + ".  Currently in state: " + this.getState();
}
/**
 * unHold method comment.
 */
public boolean unHold() {
	boolean res = this.getModel().unHold();
	if (res) {
		this.enable("Off Hold", true, true, "Send");
		this.getHoldButton().setText("Hold");
	}
	return res;
		
}
}

⌨️ 快捷键说明

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