JAVA写的模拟收发器设备面板工作状态并输出图形界面

2019-04-14 19:04发布

java模拟收发器工作状态,每个光口、电口、状态灯都可以跟随鼠标移动,显示提示信息。变异jiava代码生成class文件后,html文件调用。源代码发布在 http://xu-laoshi.cn/xulaoshi/1447.html
mb.java 源代码如下: import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.applet.*; import java.net.URL; import java.net.MalformedURLException; public class Mb extends Applet//机架面板 { Color BkColor=new Color(9,76,254); final Color[] mycolor={new Color(0,255,0),new Color(198,195,198)};//0在线 1下线 String ip; String JjNo; String ledvalue; String stylevalue; public void init() { ip=getParameter("ip"); JjNo=getParameter("JjNo"); this.setLayout(new GridLayout(1,16)); for(int i=0;i<16;i++) { stylevalue=getParameter("style"+Integer.toString(i)); ledvalue=getParameter("led"+Integer.toString(i)); if (stylevalue == null) { stylevalue = "255"; } if (ledvalue == null){ ledvalue = "255"; } add(new CcMb(i,stylevalue,ledvalue)); } } public boolean openurl(String avg) { URL url; try { url = new URL("http://"+ip+"/cgi-bin/ccmain?jjno="+JjNo+"&ccno="+avg); } catch(MalformedURLException _ex) { System.out.println("URL not found."); return true; } getAppletContext().showDocument(url, "_blank"); return true; } class CcMb extends JPanel implements ActionListener//插槽面板 { Button JjIndex=null; Label JjIdx=null; final String[] CcStyle={"第1型号","第2型号","第3型号"}; String ledvalue; int temp; public CcMb(int j, String style, String led) { temp=Integer.valueOf(led).intValue(); ledvalue=Integer.toBinaryString(temp); while(ledvalue.length()<8){ ledvalue="0"+ledvalue; } // this.add(new Label(ledvalue));}////////////// this.setBackground(BkColor); this.setLayout(new GridLayout(5,1)); this.setBorder(BorderFactory.createLineBorder(Color.gray)); if(Integer.parseInt(style)<16) { JjIndex=new Button(Integer.toString(j)); JjIndex.setBackground(BkColor); JjIndex.addActionListener(this); if(Integer.parseInt(style)==1)//自适应 { add(JjIndex); add(new FxPanel("电口 0",ledvalue.charAt(5)));//5 add(new FxPanel("电口 1",ledvalue.charAt(4)));//4 add(new sixLedPanel1(style,ledvalue)); add(new LxPanel("光口",ledvalue.charAt(3)));//3 } else if(Integer.parseInt(style)==2)//100M { add(JjIndex); add(new Label("")); add(new FxPanel("电口",ledvalue.charAt(4)));//4 add(new sixLedPanel2(style,ledvalue)); add(new LxPanel("光口",ledvalue.charAt(3)));//3 } }else { JjIdx=new Label(Integer.toString(j)); add(JjIdx); } } public void actionPerformed(ActionEvent ev) { String label=ev.getActionCommand(); openurl(label); } } class FxPanel extends JPanel//电口 { int cl=1; public FxPanel(String hint,char colorindex) { if(colorindex=='1') cl=0; this.setBackground(BkColor); this.setToolTipText(hint); } public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(mycolor[cl]); g.fill3DRect(5,5,20,30,false); g.fill3DRect(25,10,5,20,false); } } class LxPanel extends JPanel//光口 { int cl=1; public LxPanel(String hint,char colorindex) { if(colorindex=='1') cl=0; this.setBackground(BkColor); this.setToolTipText(hint); } public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(mycolor[cl]); g.fill3DRect(5,5,25,35,false); g.fillArc(12,10,10,10,0,360); g.fillArc(12,25,10,10,0,360); } } class sixLedPanel1 extends JPanel//6个灯 自适应 { public sixLedPanel1(String sty,String led) { this.setBackground(new Color(9,76,254)); this.setLayout(new GridLayout(2,3)); add(new LedPanel("SPD 1",led.charAt(6)));//6 add(new LedPanel("SPD 0",led.charAt(7)));//7 add(new LedPanel("电源",'1')); add(new LedPanel("电口 1 Link",led.charAt(4)));//4 add(new LedPanel("电口 0 Link",led.charAt(5)));//5 add(new LedPanel("光口Link",led.charAt(3)));//3 } } class sixLedPanel2 extends JPanel//6个灯 100M { public sixLedPanel2(String sty,String led) { this.setBackground(new Color(9,76,254)); this.setLayout(new GridLayout(2,3)); add(new LedPanel("TP_TX",led.charAt(6)));//6 add(new LedPanel("光口Link",led.charAt(3)));//3 add(new LedPanel("FDXLED",led.charAt(7)));//7 add(new LedPanel("FX-T",led.charAt(5)));//5 add(new LedPanel("电口Link",led.charAt(4)));//4 add(new LedPanel("电源",'1')); } } class LedPanel extends JPanel//一个灯 { int ledx,ledy,ledr; int cd=1; public LedPanel(String hint,char clindex) { if(clindex=='1') cd=0; this.setBackground(BkColor); this.setToolTipText(hint); } public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(mycolor[cd]); g.fillArc(0,0,8,8,0,360); } } }   mb.htm 文件如下: