📄 bandwidthframe.java
字号:
/*
Copyright (c) 2008, Intel Corporation.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/import java.awt.BorderLayout;import java.awt.GraphicsConfiguration;import java.awt.HeadlessException;import java.awt.Toolkit;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTabbedPane;import javax.swing.JTable;import javax.swing.table.TableModel;import com.intel.mobile.base.EventProperty;import com.intel.mobile.base.IntelMobileException;import com.intel.mobile.base.Property;import com.intel.mobile.context.BandwidthInstance;import com.intel.mobile.context.ContextClass;import java.net.*;/* * Created on 2004-6-17 * * To change the template for this generated file go to * Window>Preferences>Java>Code Generation>Code and Comments *//** * @ * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */public class BandwidthFrame extends JFrame { private javax.swing.JPanel jContentPane = null; private BandwidthInstance bandwidthInstance =null; private static ContextClass tempContextClass = null; private PropertyEventPanel jPropertyPanelEvent = null; private FunctionEventPanel jFunctionPanelEvent=null; private ThresholdsPanel jThresholdPanel=null; private JTabbedPane jTabbedPane = null; private JPanel jPanelGeneral = null; private JPanel jPanelAdvanced = null; private JPanel jPanelEvent = null; private JScrollPane jScrollPane = null; private JTable jTable = null; private TableModel dataModel = null; private javax.swing.JLabel jLabel = null; private javax.swing.JPanel jPanel = null; private javax.swing.JLabel jLabel1 = null; private javax.swing.JLabel jLabel2 = null; private javax.swing.JLabel jLabel3 = null; private javax.swing.JLabel jLabel4 = null; private javax.swing.JLabel jLabel5 = null; private javax.swing.JLabel jLabel6 = null; private javax.swing.JLabel jLabel7 = null; private javax.swing.JLabel jLabel8 = null; private javax.swing.JLabel jLabel9 = null; private javax.swing.JLabel jLabel10 = null; private javax.swing.JLabel jLabel11 = null; private javax.swing.JLabel jLabel12 = null; private JLabel jLabel13 = null; private JLabel jLabel14 = null; private JLabel jLabel15 = null; private JLabel jLabel16 = null; private JLabel jLabel17 = null; private JLabel jLabel18 = null; private JLabel jLabel19 = null; private JLabel jLabel20 = null; private JLabel jLabel21 = null; private JLabel jLabel22 = null; private JLabel jLabel23 = null; private JLabel jLabel24 = null; private JLabel jLabel25 = null; private JLabel jLabel26 = null; private JLabel jLabel27 = null; private JLabel jLabel28 = null; private JLabel jLabel29 = null; private JLabel jLabel30 = null; static { try { tempContextClass = new ContextClass(); } catch (IntelMobileException ex) { ex.printStackTrace(); } } /** * @throws java.awt.HeadlessException */ public BandwidthFrame(BandwidthInstance myInstance) throws HeadlessException, IntelMobileException { super(); bandwidthInstance = myInstance; initialize(); } public BandwidthFrame(String myInstanceKey) throws HeadlessException, IntelMobileException { super(); BandwidthInstance myInstance = (BandwidthInstance)tempContextClass.GetInstance(myInstanceKey); bandwidthInstance = myInstance; initialize(); } /** * @param arg0 */ public BandwidthFrame(GraphicsConfiguration arg0) throws IntelMobileException { super(arg0); initialize(); } /** * @param arg0 * @throws java.awt.HeadlessException *//* public LinkProtocol802_3Frame(String arg0) throws HeadlessException { super(arg0); initialize(); }*/ /** * @param arg0 * @param arg1 */ public BandwidthFrame(String arg0, GraphicsConfiguration arg1) throws IntelMobileException { super(arg0, arg1); initialize(); } /** * This method initializes this * * @return void */ private void initialize() throws IntelMobileException { DatagramSocket sock; new Thread() { public void run() { try { DatagramSocket ss = new DatagramSocket(5432); byte[] buf = new byte[10]; DatagramPacket p = new DatagramPacket(buf, 5); ss.receive(p); // System.out.println("DatagramSocket Received: " + new String(p.getData())); ss.close(); } catch (Exception ex) { ex.printStackTrace(); } } }.start(); try { sock = new DatagramSocket(); byte[] buf = "hello".getBytes(); DatagramPacket p = new DatagramPacket(buf, buf.length, InetAddress.getLocalHost(), 5432); sock.send(p); } catch (Exception ex) { ex.printStackTrace(); return; } this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/Resx/Java-app_ico16.gif"))); this.setSize(620, 400); this.setContentPane(getJContentPane()); this.setResizable(false); this.setTitle("Bandwidth Information"); } /** * This method initializes jContentPane * * @return javax.swing.JPanel */ private javax.swing.JPanel getJContentPane() throws IntelMobileException { if (jContentPane == null) { jContentPane = new javax.swing.JPanel(); jContentPane.setLayout(new java.awt.BorderLayout()); jContentPane.add(getJTabbedPane(), java.awt.BorderLayout.CENTER); } return jContentPane; } /** * This method initializes jTabbedPane * * @return javax.swing.JTabbedPane */ private JTabbedPane getJTabbedPane() throws IntelMobileException { if (jTabbedPane == null) { jTabbedPane = new JTabbedPane(); jTabbedPane.addTab("General", null, getJPanelGeneral(), null); //jTabbedPane.addTab("Advanced", null, getJPanelAdvanced(), null); jTabbedPane.addTab("Property Change Event", null, getJPanelPropertyEvent(), null); jTabbedPane.addTab("Function Event", null, getJPanelFunctionEvent(), null); jTabbedPane.addTab("Threshold", null, getJPanelThreshold(), null); initialFunctionEvent(); initialPropertyEvent(); } return jTabbedPane; } private void initialFunctionEvent() { AddFunctionEvent(this.bandwidthInstance.StatusChanged,"StatusChanged"); AddFunctionEvent(this.bandwidthInstance.BandwidthChanged,"BandwidthChanged"); } private void AddFunctionEvent(EventProperty event, String eventName) { getJPanelFunctionEvent().PropertyEventPanel.dataModel.addEventItem(event,eventName,"",this.bandwidthInstance); } private void initialPropertyEvent() { AddProperty(bandwidthInstance.Adaptive); AddProperty(bandwidthInstance.AdaptivelyLimitable); AddProperty(bandwidthInstance.FastestProtocol); AddProperty(bandwidthInstance.LimitedRx); AddProperty(bandwidthInstance.LimitedTx); AddProperty(bandwidthInstance.LimitRx); AddProperty(bandwidthInstance.LimitTx); AddProperty(bandwidthInstance.PercentRx); AddProperty(bandwidthInstance.PercentTx); AddProperty(bandwidthInstance.RateRx); AddProperty(bandwidthInstance.RateTx); AddProperty(bandwidthInstance.SystemRateRx); AddProperty(bandwidthInstance.SystemRateTx); AddProperty(bandwidthInstance.TheoreticalSystemRateRx); AddProperty(bandwidthInstance.TheoreticalSystemRateTx); } private void AddProperty(Property property) { try { if(!property.IsStatic()) { getJPanelPropertyEvent().PropertyEventPanel.dataModel.addEventItem(property,property.GetName(),"",this.bandwidthInstance); getJPanelThreshold().addPropertyItem(property); } }catch(IntelMobileException e) { } } /** * This method initializes jPanelGeneral * * @return javax.swing.JPanel */ private JPanel getJPanelGeneral() throws IntelMobileException { if (jPanelGeneral == null) { jPanelGeneral = new JPanel(); jPanelGeneral.setLayout(null); jPanelGeneral.add(getJLabel(), null); jPanelGeneral.add(getJPanel(), null); } return jPanelGeneral; } /** * This method initializes jPanelAdvanced * * @return javax.swing.JPanel */ private JPanel getJPanelAdvanced() { if(jPanelAdvanced == null) { jPanelAdvanced = new JPanel(); jPanelAdvanced.setLayout(new BorderLayout()); jPanelAdvanced.add(getJScrollPane(), BorderLayout.CENTER); } return jPanelAdvanced; } private PropertyEventPanel getJPanelPropertyEvent() { if (jPropertyPanelEvent == null) { jPropertyPanelEvent = new PropertyEventPanel(); } return jPropertyPanelEvent; } private FunctionEventPanel getJPanelFunctionEvent() { if (jFunctionPanelEvent == null) { jFunctionPanelEvent = new FunctionEventPanel(); } return jFunctionPanelEvent; } private ThresholdsPanel getJPanelThreshold() { if (jThresholdPanel == null) { jThresholdPanel = new ThresholdsPanel(); } return jThresholdPanel; } /** * This method initializes jScrollPane * * @return javax.swing.JScrollPane */ private JScrollPane getJScrollPane() { if (jScrollPane == null) { jScrollPane = new JScrollPane(); jScrollPane.setViewportView(getJTable()); } return jScrollPane; } /** * This method initializes jTable * * @return javax.swing.JTable */ private JTable getJTable() { if (jTable == null) { jTable = new JTable(dataModel); } return jTable; } private javax.swing.JLabel getJLabel() throws IntelMobileException { if(jLabel == null) { jLabel = new javax.swing.JLabel(); jLabel.setBounds(14, 8, 275, 18); jLabel.setText(bandwidthInstance.GetKey()); jLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP); } return jLabel; } /** * This method initializes jPanel * * @return javax.swing.JPanel */ private javax.swing.JPanel getJPanel() throws IntelMobileException { if(jPanel == null) { jLabel23 = new JLabel(); jLabel22 = new JLabel(); jLabel21 = new JLabel(); jLabel20 = new JLabel(); jLabel19 = new JLabel(); jLabel18 = new JLabel(); jLabel17 = new JLabel(); jLabel15 = new JLabel(); jLabel13 = new JLabel(); jPanel = new javax.swing.JPanel(); jPanel.setLayout(null); jPanel.add(getJLabel3(), null); jPanel.add(getJLabel4(), null); jPanel.add(getJLabel5(), null); jPanel.add(getJLabel6(), null); jPanel.add(getJLabel7(), null); jPanel.add(getJLabel8(), null); jPanel.add(getJLabel9(), null); jPanel.add(getJLabel10(), null); jPanel.add(getJLabel11(), null); jPanel.add(getJLabel12(), null); jPanel.setBounds(12, 32, 578, 286); jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Status", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); jLabel13.setBounds(291, 112, 72, 17); jLabel13.setText("RateTx:"); jLabel15.setBounds(24, 146, 171, 18); jLabel15.setText("TheoreticalSystemRateRx:"); jLabel17.setBounds(290, 145, 166, 19); jLabel17.setText("TheoreticalSystemRateTx:"); jLabel18.setBounds(24, 176, 96, 18); jLabel18.setText("PercentRx:"); jLabel19.setBounds(290, 174, 73, 17); jLabel19.setText("PercentTx:"); jLabel20.setBounds(24, 209, 93, 17); jLabel20.setText("LimitedRx:"); jLabel21.setBounds(291, 208, 73, 16); jLabel21.setText("LimitedTx:"); jLabel22.setBounds(24, 240, 91, 16); jLabel22.setText("Adaptive:"); jLabel23.setBounds(290, 237, 127, 17); jLabel23.setText("AdaptivelyLimitable:"); jPanel.add(jLabel13, null); jPanel.add(getJLabel14(), null); jPanel.add(jLabel15, null); jPanel.add(getJLabel16(), null); jPanel.add(getJLabel2(), null); jPanel.add(getJLabel1(), null); jPanel.add(jLabel17, null); jPanel.add(jLabel18, null); jPanel.add(jLabel19, null); jPanel.add(jLabel20, null); jPanel.add(jLabel21, null); jPanel.add(jLabel22, null); jPanel.add(jLabel23, null);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -