📄 openrtpdialog.java
字号:
/* * @(#)OpenRtpDialog.java 1.1 00/02/10 * * Copyright (c) 1999 Sun Microsystems, Inc. All Rights Reserved. * * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use, * modify and redistribute this software in source and binary code form, * provided that i) this copyright notice and license appear on all copies of * the software; and ii) Licensee does not utilize the software in a manner * which is disparaging to Sun. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * * This software is not designed or intended for use in on-line control of * aircraft, air traffic, aircraft navigation or aircraft communications; or in * the design, construction, operation or maintenance of any nuclear * facility. Licensee represents and warrants that it will not use or * redistribute the Software for such purposes. */package jmapps.jmstudio;import java.awt.*;import java.awt.event.*;import javax.media.rtp.*;import javax.media.control.BufferControl;import com.sun.media.util.JMFI18N;import jmapps.util.*;import jmapps.ui.*;public class OpenRtpDialog extends JMDialog implements TextListener { private TextField fieldAddress0; private TextField fieldAddress1;
private TextField fieldAddress2;
private TextField fieldAddress3;
private TextField fieldPort;
private Choice choiceTtl;
private JMAppsCfg cfgJMApps = null; private String strAddress = null; private String strPort = null; private String strTtl = null; public OpenRtpDialog ( Frame frame, JMAppsCfg cfgJMApps ) { super ( frame, JMFI18N.getResource("jmstudio.openrtp.title"), true ); this.cfgJMApps = cfgJMApps; init (); } public String getAddress () { return ( strAddress ); } public String getPort () { return ( strPort ); } public String getTtl () { return ( strTtl ); } private void init () { JMPanel panel; JMPanel panelButtons; JMPanel panelContent; this.setLayout ( new BorderLayout() ); panelContent = new JMPanel ( new BorderLayout(6,6) ); panelContent.setEmptyBorder ( 6, 6, 6, 6 ); this.add ( panelContent, BorderLayout.CENTER ); panelContent.setBackground ( Color.lightGray ); panel = createPanelSource (); panelContent.add ( panel, BorderLayout.CENTER ); panel = new JMPanel ( new FlowLayout(FlowLayout.CENTER) ); this.add ( panel, BorderLayout.SOUTH ); panelButtons = createButtonPanel ( new String[] { ACTION_OPEN, ACTION_CANCEL } ); panel.add ( panelButtons ); pack (); setResizable (false); } private JMPanel createPanelSource () { JMPanel panelSource;
JMPanel panelLabels;
JMPanel panelParams;
JMPanel panelAddress;
Label label;
JMAppsCfg.RtpData dataRtp;
dataRtp = cfgJMApps.getLastOpenRtpData();
panelSource = new JMPanel ( new BorderLayout(6,6) );
panelLabels = new JMPanel ( new GridLayout(0,1,6,6) );
panelSource.add ( panelLabels, BorderLayout.WEST );
panelParams = new JMPanel ( new GridLayout(0,1,6,6) );
panelSource.add ( panelParams, BorderLayout.CENTER );
label = new Label ( JMFI18N.getResource("jmstudio.openrtp.label.address") );
panelLabels.add ( label );
panelAddress = new JMPanel ( new GridLayout(1,0,2,2) );
panelParams.add ( panelAddress );
fieldAddress0 = new TextField ( 3 );
if ( dataRtp != null )
fieldAddress0.setText ( dataRtp.strAddress0 );
fieldAddress0.addTextListener ( this );
panelAddress.add ( fieldAddress0 );
fieldAddress1 = new TextField ( 3 );
if ( dataRtp != null )
fieldAddress1.setText ( dataRtp.strAddress1 );
fieldAddress1.addTextListener ( this );
panelAddress.add ( fieldAddress1 );
fieldAddress2 = new TextField ( 3 );
if ( dataRtp != null )
fieldAddress2.setText ( dataRtp.strAddress2 );
fieldAddress2.addTextListener ( this );
panelAddress.add ( fieldAddress2 );
fieldAddress3 = new TextField ( 3 );
if ( dataRtp != null )
fieldAddress3.setText ( dataRtp.strAddress3 );
fieldAddress3.addTextListener ( this );
panelAddress.add ( fieldAddress3 );
label = new Label ( JMFI18N.getResource("jmstudio.openrtp.label.port") );
panelLabels.add ( label );
fieldPort = new TextField ( 5 );
if ( dataRtp != null )
fieldPort.setText ( dataRtp.strPort );
panelParams.add ( fieldPort );
label = new Label ( JMFI18N.getResource("jmstudio.openrtp.label.ttl") );
panelLabels.add ( label );
choiceTtl = new Choice ();
panelParams.add ( choiceTtl );
choiceTtl.addItem ( "1" );
choiceTtl.addItem ( "2" );
choiceTtl.addItem ( "3" );
choiceTtl.addItem ( "4" );
choiceTtl.addItem ( "8" );
choiceTtl.addItem ( "16" );
choiceTtl.addItem ( "32" );
choiceTtl.addItem ( "64" );
choiceTtl.addItem ( "128" );
choiceTtl.addItem ( "255" );
if ( dataRtp != null )
choiceTtl.select ( dataRtp.strTtl );
return ( panelSource );
}
public void setVisible ( boolean show ) { super.setVisible ( show ); fieldAddress0.requestFocus (); } public void actionPerformed ( ActionEvent event ) { String strAction;
strAction = event.getActionCommand ();
if ( strAction.equals(ACTION_OPEN) ) {
if ( validateData() == true ) {
this.setAction ( strAction ); this.dispose (); } } else if ( strAction.equals(ACTION_CANCEL) ) { this.setAction ( strAction ); this.dispose (); } }
public void textValueChanged ( TextEvent event ) { Object objectSource;
TextField textField;
String strValue;
objectSource = event.getSource ();
if ( objectSource instanceof TextField ) {
textField = (TextField) objectSource;
strValue = textField.getText ();
if ( strValue.length() > 2 )
textField.transferFocus ();
}
}
public boolean validateData () {
String strValue; int nValue; JMAppsCfg.RtpData dataRtp; dataRtp = cfgJMApps.createRtpDataObject (); strValue = fieldAddress0.getText (); dataRtp.strAddress0 = strValue; try { nValue = Integer.valueOf(strValue).intValue(); } catch ( Exception exception ) { nValue = -1; } if ( nValue < 0 || nValue > 255 ) { MessageDialog.createErrorDialog ( this.frameOwner, JMFI18N.getResource("jmstudio.error.sessionaddr") ); return ( false ); } strAddress = new String ( strValue ); strValue = fieldAddress1.getText ();
dataRtp.strAddress1 = strValue;
try {
nValue = Integer.valueOf(strValue).intValue(); } catch ( Exception exception ) { nValue = -1; } if ( nValue < 0 || nValue > 255 ) {
MessageDialog.createErrorDialog ( this.frameOwner, JMFI18N.getResource("jmstudio.error.sessionaddr") ); return ( false ); } strAddress = strAddress + "." + strValue;
strValue = fieldAddress2.getText ();
dataRtp.strAddress2 = strValue;
try {
nValue = Integer.valueOf(strValue).intValue(); } catch ( Exception exception ) { nValue = -1; } if ( nValue < 0 || nValue > 255 ) {
MessageDialog.createErrorDialog ( this.frameOwner, JMFI18N.getResource("jmstudio.error.sessionaddr") ); return ( false ); } strAddress = strAddress + "." + strValue;
strValue = fieldAddress3.getText ();
dataRtp.strAddress3 = strValue;
try {
nValue = Integer.valueOf(strValue).intValue(); } catch ( Exception exception ) { nValue = -1; } if ( nValue < 0 || nValue > 255 ) {
MessageDialog.createErrorDialog ( this.frameOwner, JMFI18N.getResource("jmstudio.error.sessionaddr") ); return ( false ); } strAddress = strAddress + "." + strValue;
strPort = fieldPort.getText ();
dataRtp.strPort = strPort;
try {
nValue = Integer.valueOf(strPort).intValue(); } catch ( Exception exception ) { nValue = -1; } if ( nValue < 0 || (nValue & 0x0001) == 0x0001 ) { MessageDialog.createErrorDialog ( this.frameOwner, JMFI18N.getResource("jmstudio.error.port") ); return ( false ); }
strTtl = choiceTtl.getSelectedItem ();
dataRtp.strTtl = strTtl;
if ( cfgJMApps != null ) cfgJMApps.setLastOpenRtpData ( dataRtp );
return ( true ); }
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -