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

📄 hostname.java

📁 取得WEB客户机器主机名信息。
💻 JAVA
字号:
/* HostName.java   * * Raven * raven@ravenmatrix.com * http://www.ravenmatrix.com  * * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details at http://www.gnu.org  */import java.applet.*;
import java.awt.*;
import java.net.*;
public class HostName extends Applet
{
String NameOfHost;
public void init()
{
try
{
InetAddress localAddress = InetAddress.getLocalHost();
NameOfHost = localAddress.getHostName();
}catch(UnknownHostException e)
{
NameOfHost = "Unknown";
}
}
public void paint(Graphics g)
{
String VisitorMessage = "Welcome to Code Collection visitor from: "+NameOfHost;
g.setFont(new Font("Courier", Font.PLAIN, 12));
FontMetrics fm = g.getFontMetrics ();
int vmWidth = fm.stringWidth(VisitorMessage);
Dimension aSize = size(); // call getSize() in Java 1.2
int x = aSize.width/2 - vmWidth/2;
int y = aSize.height/2;
g.drawString (VisitorMessage, x, y);
}
}

⌨️ 快捷键说明

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