Código de Java - Java_ping

Imágen de perfil
Val: 19
Ha disminuido su posición en 3 puestos en Java (en relación al último mes)
Gráfica de Java

Java_pinggráfica de visualizaciones


Java

Publicado el 16 de Octubre del 2015 por Guajardo (21 códigos)
3.027 visualizaciones desde el 16 de Octubre del 2015
Verificar coneccion por medio de validacion http, en si haces un ping a x direccion , te sirve para saber cuando tienes o conexecion a la red, espero les sea util y la sepan agregar a sus proyectos, saludos

Requerimientos

eclipse

1.0

Publicado el 16 de Octubre del 2015gráfica de visualizaciones de la versión: 1.0
3.028 visualizaciones desde el 16 de Octubre del 2015
estrellaestrellaestrellaestrellaestrella
estrellaestrellaestrellaestrella
estrellaestrellaestrella
estrellaestrella
estrella

2
3
1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package datos;
 
import java.awt.EventQueue;
 
import javax.swing.JFrame;
import javax.net.ssl.HttpsURLConnection;
import javax.swing.JButton;
import javax.swing.JTextField;
import java.awt.Font;
import javax.swing.SwingConstants;
import javax.swing.JLabel;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.URL;
import java.net.UnknownHostException;
import java.awt.event.ActionEvent;
import java.awt.Color;
import javax.swing.ImageIcon;
 
public class Ping {
 
	private JFrame frame;
	private JTextField txt_url;
	private JLabel lblNewLabel;
	private JLabel lb1;
	private JLabel lb2;
 
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Ping window = new Ping();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
 
	/**
	 * Create the application.
	 */
	public Ping() {
		initialize();
	}
 
	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
 
		frame = new JFrame();
		frame.getContentPane().setBackground(Color.BLACK);
		frame.setBounds(100, 100, 456, 282);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
		frame.setLocationRelativeTo(null);
		JLabel blping = new JLabel("");
		blping.setForeground(Color.GRAY);
		blping.setHorizontalAlignment(SwingConstants.CENTER);
 
 
 
 
		JButton bt_ping = new JButton("---PING---");
		bt_ping.setIcon(new ImageIcon("C:\\Users\\ACER\\Pictures\\click32.png"));
		bt_ping.setSelectedIcon(null);
		bt_ping.setBackground(Color.BLACK);
		bt_ping.setForeground(Color.BLUE);
		bt_ping.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				String url=null;
						try {
							url=txt_url.getText();
							URL host=new URL("http://"+url);
						     HttpURLConnection http=(HttpURLConnection) host.openConnection();
						     http.connect();
						     blping.setForeground(Color.green);
							 blping.setText("Tienes conexión exitosa");
							 lb1.setVisible(true);
							 lb2.setVisible(false);
						  } catch (IOException e) {
							  blping.setForeground(Color.red);
							 blping.setText("Verifica tu configuración y vuelve a intentar");
							 lb1.setVisible(false);
							 lb2.setVisible(true);
 
						}
			}
		});
		bt_ping.setFont(new Font("Tahoma", Font.BOLD, 18));
		bt_ping.setBounds(10, 142, 82, 91);
		frame.getContentPane().add(bt_ping);
 
		txt_url = new JTextField();
		txt_url.setHorizontalAlignment(SwingConstants.CENTER);
		txt_url.setFont(new Font("Tahoma", Font.BOLD, 25));
		txt_url.setText("www.google.com");
		txt_url.setBounds(10, 43, 420, 44);
		frame.getContentPane().add(txt_url);
		txt_url.setColumns(10);
 
 
		blping.setFont(new Font("Tahoma", Font.BOLD, 18));
		blping.setBounds(10, 98, 420, 31);
		frame.getContentPane().add(blping);
 
		lblNewLabel = new JLabel("By Andrax1990  ");
		lblNewLabel.setFont(new Font("Agency FB", Font.BOLD, 26));
		lblNewLabel.setForeground(Color.WHITE);
		lblNewLabel.setBounds(10, 0, 220, 38);
		frame.getContentPane().add(lblNewLabel);
 
		lb1 = new JLabel("");
		lb1.setIcon(new ImageIcon("C:\\Users\\ACER\\Pictures\\cloud306.png"));
		lb1.setForeground(Color.WHITE);
		lb1.setBounds(355, 174, 75, 59);
		frame.getContentPane().add(lb1);
 
		lb2 = new JLabel("");
		lb2.setIcon(new ImageIcon("C:\\Users\\ACER\\Pictures\\cloud307.png"));
		lb2.setForeground(Color.WHITE);
		lb2.setBounds(355, 155, 75, 78);
		frame.getContentPane().add(lb2);
 
		 lb1.setVisible(false);
		 lb2.setVisible(false);
	}
}



Comentarios sobre la versión: 1.0 (0)


No hay comentarios
 

Comentar la versión: 1.0

Nombre
Correo (no se visualiza en la web)
Valoración
Comentarios...
CerrarCerrar
CerrarCerrar
Cerrar

Tienes que ser un usuario registrado para poder insertar imágenes, archivos y/o videos.

Puedes registrarte o validarte desde aquí.

Codigo
Negrita
Subrayado
Tachado
Cursiva
Insertar enlace
Imagen externa
Emoticon
Tabular
Centrar
Titulo
Linea
Disminuir
Aumentar
Vista preliminar
sonreir
dientes
lengua
guiño
enfadado
confundido
llorar
avergonzado
sorprendido
triste
sol
estrella
jarra
camara
taza de cafe
email
beso
bombilla
amor
mal
bien
Es necesario revisar y aceptar las políticas de privacidad

http://lwp-l.com/s3313