import java.net.InetAddress;
import java.net.UnknownHostException;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class dns implements ActionListener {
JLabel domain1,ip1;
JTextField dom,ip;
JButton getip,getdom;
public static void main(String[] args) {
dns obj = new dns();
obj.createui();
}
private void createui()
{
JFrame frame = new JFrame("JDBC All in One");
Container c = frame.getContentPane();
c.setLayout(new BoxLayout(c,BoxLayout.Y_AXIS));
domain1=new JLabel("domain:");
ip1=new JLabel("ip address:");
dom = new JTextField();
ip = new JTextField();
JPanel pnlInput = new JPanel(new GridLayout(1,2));
pnlInput.add(domain1);
pnlInput.add(dom);
pnlInput.add(ip1);
pnlInput.add(ip);
getip = new JButton("getip");
getip.addActionListener(this);
getdom=new JButton("getdom");
getdom.addActionListener(this);
JPanel pnlButton = new JPanel(new GridLayout(1,2));
pnlButton.add(getip);
pnlButton.add(getdom);
frame.add(pnlInput);
frame.add(pnlButton);
frame.setSize(400,100);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent evt)
{
String cmd = evt.getActionCommand();
if(cmd.equals("getip"))
{
try
{
InetAddress thisIp = java.net.InetAddress.getByName(dom.getText());;
ip.setText(thisIp.getHostAddress());
}
catch(Exception e)
{
e.printStackTrace();
}
}
else if(cmd.equals("getdom"))
{
try
{
InetAddress x=InetAddress.getByName(ip.getText());
String hostname = x.getHostName();
dom.setText(hostname);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
}
import java.net.UnknownHostException;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class dns implements ActionListener {
JLabel domain1,ip1;
JTextField dom,ip;
JButton getip,getdom;
public static void main(String[] args) {
dns obj = new dns();
obj.createui();
}
private void createui()
{
JFrame frame = new JFrame("JDBC All in One");
Container c = frame.getContentPane();
c.setLayout(new BoxLayout(c,BoxLayout.Y_AXIS));
domain1=new JLabel("domain:");
ip1=new JLabel("ip address:");
dom = new JTextField();
ip = new JTextField();
JPanel pnlInput = new JPanel(new GridLayout(1,2));
pnlInput.add(domain1);
pnlInput.add(dom);
pnlInput.add(ip1);
pnlInput.add(ip);
getip = new JButton("getip");
getip.addActionListener(this);
getdom=new JButton("getdom");
getdom.addActionListener(this);
JPanel pnlButton = new JPanel(new GridLayout(1,2));
pnlButton.add(getip);
pnlButton.add(getdom);
frame.add(pnlInput);
frame.add(pnlButton);
frame.setSize(400,100);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent evt)
{
String cmd = evt.getActionCommand();
if(cmd.equals("getip"))
{
try
{
InetAddress thisIp = java.net.InetAddress.getByName(dom.getText());;
ip.setText(thisIp.getHostAddress());
}
catch(Exception e)
{
e.printStackTrace();
}
}
else if(cmd.equals("getdom"))
{
try
{
InetAddress x=InetAddress.getByName(ip.getText());
String hostname = x.getHostName();
dom.setText(hostname);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
}
No comments:
Post a Comment