jbuilder 100例 java源码学习,非常不错,有需要朋友下来

源代码在线查看: frame1.java~25~

软件大小: 6566 K
上传用户: xiaoexiao
关键词: jbuilder java 100 源码
下载地址: 免注册下载 普通下载 VIP

相关代码

				package getmyip;								import java.awt.*;				import java.awt.event.*;				import javax.swing.*;				import java.net.*;								public class Frame1 extends JFrame {				  JPanel contentPane;				  FlowLayout flowLayout1 = new FlowLayout();				  Button button1 = new Button();				  Label label1 = new Label();				  TextField textField1 = new TextField();								  /**Construct the frame*/				  public Frame1() {				    enableEvents(AWTEvent.WINDOW_EVENT_MASK);				    try {				      jbInit();				    }				    catch(Exception e) {				      e.printStackTrace();				    }				  }				  /**Component initialization*/				  private void jbInit() throws Exception  {				    //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));				    contentPane = (JPanel) this.getContentPane();				    button1.setLabel("获取");				    button1.addActionListener(new java.awt.event.ActionListener() {				      public void actionPerformed(ActionEvent e) {				        button1_actionPerformed(e);				      }				    });				    contentPane.setLayout(flowLayout1);				    this.setResizable(false);				    this.setSize(new Dimension(281, 168));				    this.setTitle("得到本机IP地址");				    label1.setFont(new java.awt.Font("Dialog", 0, 32));				    label1.setText("本机的IP地址是:");				    textField1.setColumns(15);				    textField1.setEditable(false);				    textField1.setFont(new java.awt.Font("Dialog", 1, 20));				    contentPane.add(button1, null);				    contentPane.add(label1, null);				    contentPane.add(textField1, null);				  }				  /**Overridden so we can exit when window is closed*/				  protected void processWindowEvent(WindowEvent e) {				    super.processWindowEvent(e);				    if (e.getID() == WindowEvent.WINDOW_CLOSING) {				      System.exit(0);				    }				  }								  void button1_actionPerformed(ActionEvent e) {				    //String ipAdd =				      //InetAddress.getHostAddress(InetAddress.getLocalHost().getHostName());				      try{				        InetAddress localHost = InetAddress.getLocalHost();				        String ipAdd = localHost.getHostAddress();				        textField1.setText(ipAdd);				      }catch(Exception ex){				          textField1.setText("Error");				        }				  }				}			

相关资源